blob: af9bb96d6849267c386854842564a213baf44e87 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200297 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100298};
299
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100300struct alc_fixup;
301
Takashi Iwaice764ab2011-04-27 16:35:23 +0200302struct alc_multi_io {
303 hda_nid_t pin; /* multi-io widget pin NID */
304 hda_nid_t dac; /* DAC to be connected */
305 unsigned int ctl_in; /* cached input-pin control value */
306};
307
Takashi Iwaid922b512011-04-28 12:18:53 +0200308enum {
Takashi Iwai3b8510c2011-04-28 14:03:24 +0200309 ALC_AUTOMUTE_PIN, /* change the pin control */
310 ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */
311 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */
Takashi Iwaid922b512011-04-28 12:18:53 +0200312};
313
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314struct alc_spec {
315 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100316 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100318 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100319 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200321 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200322 * don't forget NULL
323 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200324 */
325 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200327 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 struct hda_pcm_stream *stream_analog_playback;
329 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100330 struct hda_pcm_stream *stream_analog_alt_playback;
331 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200333 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 struct hda_pcm_stream *stream_digital_playback;
335 struct hda_pcm_stream *stream_digital_capture;
336
337 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200338 struct hda_multi_out multiout; /* playback set-up
339 * max_channels, dacs must be set
340 * dig_out_nid and hp_nid are optional
341 */
Takashi Iwai63300792008-01-24 15:31:36 +0100342 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100343 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100344 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
346 /* capture */
347 unsigned int num_adc_nids;
348 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100349 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200350 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
Takashi Iwai840b64c2010-07-13 22:49:01 +0200352 /* capture setup for dynamic dual-adc switch */
353 unsigned int cur_adc_idx;
354 hda_nid_t cur_adc;
355 unsigned int cur_adc_stream_tag;
356 unsigned int cur_adc_format;
357
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200359 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 const struct hda_input_mux *input_mux;
361 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200362 struct alc_mic_route ext_mic;
363 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364
365 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100366 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200368 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200369 int const_channel_count;
370 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
372 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100373 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200374
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200375 /* dynamic controls, init_verbs and input_mux */
376 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100377 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200378 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200379 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200380 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200381 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
382 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100383
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100384 /* hooks */
385 void (*init_hook)(struct hda_codec *codec);
386 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100387#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500388 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100389#endif
Takashi Iwai1c7161532011-04-07 10:37:16 +0200390 void (*shutup)(struct hda_codec *codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100391
Takashi Iwai834be882006-03-01 14:16:17 +0100392 /* for pin sensing */
393 unsigned int sense_updated: 1;
394 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100395 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200396 unsigned int auto_mic:1;
Takashi Iwaid922b512011-04-28 12:18:53 +0200397 unsigned int automute:1; /* HP automute enabled */
Takashi Iwaicb53c622007-08-10 17:21:45 +0200398
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100399 /* other flags */
400 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200401 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai584c0c42011-03-10 12:51:11 +0100402 unsigned int single_input_src:1;
Takashi Iwaid922b512011-04-28 12:18:53 +0200403
404 /* auto-mute control */
405 int automute_mode;
Takashi Iwai3b8510c2011-04-28 14:03:24 +0200406 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
Takashi Iwaid922b512011-04-28 12:18:53 +0200407
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200408 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200409 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100410
Takashi Iwai2134ea42008-01-10 16:53:55 +0100411 /* for virtual master */
412 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200413#ifdef CONFIG_SND_HDA_POWER_SAVE
414 struct hda_loopback_check loopback;
415#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200416
417 /* for PLL fix */
418 hda_nid_t pll_nid;
419 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100420
421 /* fix-up list */
422 int fixup_id;
423 const struct alc_fixup *fixup_list;
424 const char *fixup_name;
Takashi Iwaice764ab2011-04-27 16:35:23 +0200425
426 /* multi-io */
427 int multi_ios;
428 struct alc_multi_io multi_io[4];
Kailang Yangdf694da2005-12-05 19:42:22 +0100429};
430
431/*
432 * configuration template - to be copied to the spec instance
433 */
434struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435 struct snd_kcontrol_new *mixers[5]; /* should be identical size
436 * with spec
437 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100438 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100439 const struct hda_verb *init_verbs[5];
440 unsigned int num_dacs;
441 hda_nid_t *dac_nids;
442 hda_nid_t dig_out_nid; /* optional */
443 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800444 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100445 unsigned int num_adc_nids;
446 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100447 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100448 hda_nid_t dig_in_nid;
449 unsigned int num_channel_mode;
450 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200451 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200452 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200453 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100454 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100455 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200456 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100457 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200458#ifdef CONFIG_SND_HDA_POWER_SAVE
459 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500460 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200461#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462};
463
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464
465/*
466 * input MUX handling
467 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200473 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
474 if (mux_idx >= spec->num_mux_defs)
475 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100476 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
477 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200478 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479}
480
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200481static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
482 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483{
484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
485 struct alc_spec *spec = codec->spec;
486 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
487
488 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
489 return 0;
490}
491
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200492static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
493 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494{
495 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
496 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100497 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100499 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100500 hda_nid_t nid = spec->capsrc_nids ?
501 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200502 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
Takashi Iwaicd896c32008-11-18 12:36:33 +0100504 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
505 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100506 if (!imux->num_items && mux_idx > 0)
507 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100508
Takashi Iwaia22d5432009-07-27 12:54:26 +0200509 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200510 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100511 /* Matrix-mixer style (e.g. ALC882) */
512 unsigned int *cur_val = &spec->cur_mux[adc_idx];
513 unsigned int i, idx;
514
515 idx = ucontrol->value.enumerated.item[0];
516 if (idx >= imux->num_items)
517 idx = imux->num_items - 1;
518 if (*cur_val == idx)
519 return 0;
520 for (i = 0; i < imux->num_items; i++) {
521 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
522 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
523 imux->items[i].index,
524 HDA_AMP_MUTE, v);
525 }
526 *cur_val = idx;
527 return 1;
528 } else {
529 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100530 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100531 &spec->cur_mux[adc_idx]);
532 }
533}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200534
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535/*
536 * channel mode setting
537 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540{
541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
542 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100543 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
544 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545}
546
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200547static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549{
550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100552 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200553 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200554 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555}
556
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200557static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
558 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559{
560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
561 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200562 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
563 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200564 &spec->ext_channel_count);
565 if (err >= 0 && !spec->const_channel_count) {
566 spec->multiout.max_channels = spec->ext_channel_count;
567 if (spec->need_dac_fix)
568 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
569 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200570 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571}
572
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200575 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 * being part of a format specifier. Maximum allowed length of a value is
577 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100578 *
579 * Note: some retasking pin complexes seem to ignore requests for input
580 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
581 * are requested. Therefore order this list so that this behaviour will not
582 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200583 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
584 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200585 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100586static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100587 "Mic 50pc bias", "Mic 80pc bias",
588 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100589};
590static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100591 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592};
593/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200594 * in the pin being assumed to be exclusively an input or an output pin. In
595 * addition, "input" pins may or may not process the mic bias option
596 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
597 * accept requests for bias as of chip versions up to March 2006) and/or
598 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100599 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200600#define ALC_PIN_DIR_IN 0x00
601#define ALC_PIN_DIR_OUT 0x01
602#define ALC_PIN_DIR_INOUT 0x02
603#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
604#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100605
Kailang Yangea1fb292008-08-26 12:58:38 +0200606/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100607 * For each direction the minimum and maximum values are given.
608 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200609static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100610 { 0, 2 }, /* ALC_PIN_DIR_IN */
611 { 3, 4 }, /* ALC_PIN_DIR_OUT */
612 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200613 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
614 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100615};
616#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
617#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
618#define alc_pin_mode_n_items(_dir) \
619 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
620
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200621static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200623{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100624 unsigned int item_num = uinfo->value.enumerated.item;
625 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
626
627 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200628 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100629 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
630
631 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
632 item_num = alc_pin_mode_min(dir);
633 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200634 return 0;
635}
636
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200637static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200639{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100640 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
642 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100643 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200644 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200645 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
646 AC_VERB_GET_PIN_WIDGET_CONTROL,
647 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200648
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100649 /* Find enumerated value for current pinctl setting */
650 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200651 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100652 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200653 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100654 return 0;
655}
656
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200657static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
658 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100659{
660 signed int change;
661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
662 hda_nid_t nid = kcontrol->private_value & 0xffff;
663 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
664 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200665 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
666 AC_VERB_GET_PIN_WIDGET_CONTROL,
667 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100668
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200669 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100670 val = alc_pin_mode_min(dir);
671
672 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100673 if (change) {
674 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200675 snd_hda_codec_write_cache(codec, nid, 0,
676 AC_VERB_SET_PIN_WIDGET_CONTROL,
677 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100678
Kailang Yangea1fb292008-08-26 12:58:38 +0200679 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100680 * for the requested pin mode. Enum values of 2 or less are
681 * input modes.
682 *
683 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200684 * reduces noise slightly (particularly on input) so we'll
685 * do it. However, having both input and output buffers
686 * enabled simultaneously doesn't seem to be problematic if
687 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100688 */
689 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200690 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
691 HDA_AMP_MUTE, HDA_AMP_MUTE);
692 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
693 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100694 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200695 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
696 HDA_AMP_MUTE, HDA_AMP_MUTE);
697 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
698 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100699 }
700 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200701 return change;
702}
703
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100704#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200705 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100706 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100707 .info = alc_pin_mode_info, \
708 .get = alc_pin_mode_get, \
709 .put = alc_pin_mode_put, \
710 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100711
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100712/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
713 * together using a mask with more than one bit set. This control is
714 * currently used only by the ALC260 test model. At this stage they are not
715 * needed for any "production" models.
716 */
717#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200718#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200719
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
721 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100722{
723 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
724 hda_nid_t nid = kcontrol->private_value & 0xffff;
725 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
726 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200727 unsigned int val = snd_hda_codec_read(codec, nid, 0,
728 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100729
730 *valp = (val & mask) != 0;
731 return 0;
732}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200733static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
734 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100735{
736 signed int change;
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 hda_nid_t nid = kcontrol->private_value & 0xffff;
739 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
740 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200741 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
742 AC_VERB_GET_GPIO_DATA,
743 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100744
745 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200746 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
747 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100748 gpio_data &= ~mask;
749 else
750 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200751 snd_hda_codec_write_cache(codec, nid, 0,
752 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100753
754 return change;
755}
756#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
757 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100758 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100759 .info = alc_gpio_data_info, \
760 .get = alc_gpio_data_get, \
761 .put = alc_gpio_data_put, \
762 .private_value = nid | (mask<<16) }
763#endif /* CONFIG_SND_DEBUG */
764
Jonathan Woithe92621f12006-02-28 11:47:47 +0100765/* A switch control to allow the enabling of the digital IO pins on the
766 * ALC260. This is incredibly simplistic; the intention of this control is
767 * to provide something in the test model allowing digital outputs to be
768 * identified if present. If models are found which can utilise these
769 * outputs a more complete mixer control can be devised for those models if
770 * necessary.
771 */
772#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200773#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200774
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200775static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
776 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100777{
778 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
779 hda_nid_t nid = kcontrol->private_value & 0xffff;
780 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
781 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200782 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100783 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100784
785 *valp = (val & mask) != 0;
786 return 0;
787}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200788static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
789 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100790{
791 signed int change;
792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
793 hda_nid_t nid = kcontrol->private_value & 0xffff;
794 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
795 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200796 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100797 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200798 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100799
800 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200801 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100802 if (val==0)
803 ctrl_data &= ~mask;
804 else
805 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200806 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
807 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100808
809 return change;
810}
811#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
812 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100813 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100814 .info = alc_spdif_ctrl_info, \
815 .get = alc_spdif_ctrl_get, \
816 .put = alc_spdif_ctrl_put, \
817 .private_value = nid | (mask<<16) }
818#endif /* CONFIG_SND_DEBUG */
819
Jonathan Woithef8225f62008-01-08 12:16:54 +0100820/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
821 * Again, this is only used in the ALC26x test models to help identify when
822 * the EAPD line must be asserted for features to work.
823 */
824#ifdef CONFIG_SND_DEBUG
825#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
826
827static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
828 struct snd_ctl_elem_value *ucontrol)
829{
830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
831 hda_nid_t nid = kcontrol->private_value & 0xffff;
832 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
833 long *valp = ucontrol->value.integer.value;
834 unsigned int val = snd_hda_codec_read(codec, nid, 0,
835 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
836
837 *valp = (val & mask) != 0;
838 return 0;
839}
840
841static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
842 struct snd_ctl_elem_value *ucontrol)
843{
844 int change;
845 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
846 hda_nid_t nid = kcontrol->private_value & 0xffff;
847 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
848 long val = *ucontrol->value.integer.value;
849 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
850 AC_VERB_GET_EAPD_BTLENABLE,
851 0x00);
852
853 /* Set/unset the masked control bit(s) as needed */
854 change = (!val ? 0 : mask) != (ctrl_data & mask);
855 if (!val)
856 ctrl_data &= ~mask;
857 else
858 ctrl_data |= mask;
859 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
860 ctrl_data);
861
862 return change;
863}
864
865#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
866 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100867 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100868 .info = alc_eapd_ctrl_info, \
869 .get = alc_eapd_ctrl_get, \
870 .put = alc_eapd_ctrl_put, \
871 .private_value = nid | (mask<<16) }
872#endif /* CONFIG_SND_DEBUG */
873
Kailang Yangdf694da2005-12-05 19:42:22 +0100874/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100875 * set up the input pin config (depending on the given auto-pin type)
876 */
877static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
878 int auto_pin_type)
879{
880 unsigned int val = PIN_IN;
881
Takashi Iwai86e29592010-09-09 14:50:17 +0200882 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100883 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200884 unsigned int oldval;
885 oldval = snd_hda_codec_read(codec, nid, 0,
886 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100887 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100888 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200889 /* if the default pin setup is vref50, we give it priority */
890 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100891 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200892 else if (pincap & AC_PINCAP_VREF_50)
893 val = PIN_VREF50;
894 else if (pincap & AC_PINCAP_VREF_100)
895 val = PIN_VREF100;
896 else if (pincap & AC_PINCAP_VREF_GRD)
897 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100898 }
899 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
900}
901
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200902static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
903{
904 struct alc_spec *spec = codec->spec;
905 struct auto_pin_cfg *cfg = &spec->autocfg;
906
907 if (!cfg->line_outs) {
908 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
909 cfg->line_out_pins[cfg->line_outs])
910 cfg->line_outs++;
911 }
912 if (!cfg->speaker_outs) {
913 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
914 cfg->speaker_pins[cfg->speaker_outs])
915 cfg->speaker_outs++;
916 }
917 if (!cfg->hp_outs) {
918 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
919 cfg->hp_pins[cfg->hp_outs])
920 cfg->hp_outs++;
921 }
922}
923
Takashi Iwai23f0c042009-02-26 13:03:58 +0100924/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100925 */
926static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
927{
928 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
929 return;
930 spec->mixers[spec->num_mixers++] = mix;
931}
932
933static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
934{
935 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
936 return;
937 spec->init_verbs[spec->num_init_verbs++] = verb;
938}
939
940/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100941 * set up from the preset table
942 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200943static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200944 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100945{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200946 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100947 int i;
948
949 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100950 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100951 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200952 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
953 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100954 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200955
Kailang Yangdf694da2005-12-05 19:42:22 +0100956 spec->channel_mode = preset->channel_mode;
957 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200958 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200959 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100960
Hector Martin3b315d72009-06-02 10:54:19 +0200961 if (preset->const_channel_count)
962 spec->multiout.max_channels = preset->const_channel_count;
963 else
964 spec->multiout.max_channels = spec->channel_mode[0].channels;
965 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100966
967 spec->multiout.num_dacs = preset->num_dacs;
968 spec->multiout.dac_nids = preset->dac_nids;
969 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800970 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100971 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200972
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200973 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200974 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200975 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100976 spec->input_mux = preset->input_mux;
977
978 spec->num_adc_nids = preset->num_adc_nids;
979 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100980 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100981 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100982
983 spec->unsol_event = preset->unsol_event;
984 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200985#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100986 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200987 spec->loopback.amplist = preset->loopbacks;
988#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200989
990 if (preset->setup)
991 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200992
993 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100994}
995
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200996/* Enable GPIO mask and set output */
997static struct hda_verb alc_gpio1_init_verbs[] = {
998 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
999 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1000 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1001 { }
1002};
1003
1004static struct hda_verb alc_gpio2_init_verbs[] = {
1005 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1006 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1007 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1008 { }
1009};
1010
Kailang Yangbdd148a2007-05-08 15:19:08 +02001011static struct hda_verb alc_gpio3_init_verbs[] = {
1012 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
1013 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
1014 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
1015 { }
1016};
1017
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02001018/*
1019 * Fix hardware PLL issue
1020 * On some codecs, the analog PLL gating control must be off while
1021 * the default value is 1.
1022 */
1023static void alc_fix_pll(struct hda_codec *codec)
1024{
1025 struct alc_spec *spec = codec->spec;
1026 unsigned int val;
1027
1028 if (!spec->pll_nid)
1029 return;
1030 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1031 spec->pll_coef_idx);
1032 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1033 AC_VERB_GET_PROC_COEF, 0);
1034 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1035 spec->pll_coef_idx);
1036 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1037 val & ~(1 << spec->pll_coef_bit));
1038}
1039
1040static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1041 unsigned int coef_idx, unsigned int coef_bit)
1042{
1043 struct alc_spec *spec = codec->spec;
1044 spec->pll_nid = nid;
1045 spec->pll_coef_idx = coef_idx;
1046 spec->pll_coef_bit = coef_bit;
1047 alc_fix_pll(codec);
1048}
1049
Kailang Yang9ad0e492010-09-14 23:22:00 +02001050static int alc_init_jacks(struct hda_codec *codec)
1051{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001052#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001053 struct alc_spec *spec = codec->spec;
1054 int err;
1055 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1056 unsigned int mic_nid = spec->ext_mic.pin;
1057
Takashi Iwai265a0242010-09-21 11:26:21 +02001058 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001059 err = snd_hda_input_jack_add(codec, hp_nid,
1060 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001061 if (err < 0)
1062 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001063 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001064 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001065
Takashi Iwai265a0242010-09-21 11:26:21 +02001066 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001067 err = snd_hda_input_jack_add(codec, mic_nid,
1068 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001069 if (err < 0)
1070 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001071 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001072 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001073#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001074 return 0;
1075}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001076
Takashi Iwaid922b512011-04-28 12:18:53 +02001077static void alc_hp_automute(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +02001078{
1079 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001080 unsigned int mute;
1081 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001082 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001083
Takashi Iwaid922b512011-04-28 12:18:53 +02001084 if (!spec->automute)
1085 return;
1086
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001087 spec->jack_present = 0;
1088 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1089 nid = spec->autocfg.hp_pins[i];
1090 if (!nid)
1091 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001092 snd_hda_input_jack_report(codec, nid);
David Henningssonf0ce2792011-02-28 15:58:07 +01001093 spec->jack_present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001094 }
1095
1096 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1097 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001098 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1099 nid = spec->autocfg.speaker_pins[i];
1100 if (!nid)
1101 break;
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001102 switch (spec->automute_mode) {
1103 case ALC_AUTOMUTE_PIN:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001104 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001105 AC_VERB_SET_PIN_WIDGET_CONTROL,
1106 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001107 break;
1108 case ALC_AUTOMUTE_AMP:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001109 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1110 HDA_AMP_MUTE, mute);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001111 break;
1112 case ALC_AUTOMUTE_MIXER:
1113 nid = spec->automute_mixer_nid[i];
1114 if (!nid)
1115 break;
1116 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
1117 HDA_AMP_MUTE, mute);
1118 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
1119 HDA_AMP_MUTE, mute);
1120 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001121 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001122 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001123}
1124
Takashi Iwai6c819492009-08-10 18:47:44 +02001125static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1126 hda_nid_t nid)
1127{
1128 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1129 int i, nums;
1130
1131 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1132 for (i = 0; i < nums; i++)
1133 if (conn[i] == nid)
1134 return i;
1135 return -1;
1136}
1137
Takashi Iwai840b64c2010-07-13 22:49:01 +02001138/* switch the current ADC according to the jack state */
1139static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1140{
1141 struct alc_spec *spec = codec->spec;
1142 unsigned int present;
1143 hda_nid_t new_adc;
1144
1145 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1146 if (present)
1147 spec->cur_adc_idx = 1;
1148 else
1149 spec->cur_adc_idx = 0;
1150 new_adc = spec->adc_nids[spec->cur_adc_idx];
1151 if (spec->cur_adc && spec->cur_adc != new_adc) {
1152 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001153 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001154 spec->cur_adc = new_adc;
1155 snd_hda_codec_setup_stream(codec, new_adc,
1156 spec->cur_adc_stream_tag, 0,
1157 spec->cur_adc_format);
1158 }
1159}
1160
Kailang Yang7fb0d782008-10-15 11:12:35 +02001161static void alc_mic_automute(struct hda_codec *codec)
1162{
1163 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001164 struct alc_mic_route *dead, *alive;
1165 unsigned int present, type;
1166 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001167
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001168 if (!spec->auto_mic)
1169 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001170 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1171 return;
1172 if (snd_BUG_ON(!spec->adc_nids))
1173 return;
1174
Takashi Iwai840b64c2010-07-13 22:49:01 +02001175 if (spec->dual_adc_switch) {
1176 alc_dual_mic_adc_auto_switch(codec);
1177 return;
1178 }
1179
Takashi Iwai6c819492009-08-10 18:47:44 +02001180 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1181
Wu Fengguang864f92b2009-11-18 12:38:02 +08001182 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001183 if (present) {
1184 alive = &spec->ext_mic;
1185 dead = &spec->int_mic;
1186 } else {
1187 alive = &spec->int_mic;
1188 dead = &spec->ext_mic;
1189 }
1190
Takashi Iwai6c819492009-08-10 18:47:44 +02001191 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1192 if (type == AC_WID_AUD_MIX) {
1193 /* Matrix-mixer style (e.g. ALC882) */
1194 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1195 alive->mux_idx,
1196 HDA_AMP_MUTE, 0);
1197 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1198 dead->mux_idx,
1199 HDA_AMP_MUTE, HDA_AMP_MUTE);
1200 } else {
1201 /* MUX style (e.g. ALC880) */
1202 snd_hda_codec_write_cache(codec, cap_nid, 0,
1203 AC_VERB_SET_CONNECT_SEL,
1204 alive->mux_idx);
1205 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001206 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001207
1208 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001209}
1210
Kailang Yangc9b58002007-10-16 14:30:01 +02001211/* unsolicited event for HP jack sensing */
1212static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1213{
1214 if (codec->vendor_id == 0x10ec0880)
1215 res >>= 28;
1216 else
1217 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001218 switch (res) {
1219 case ALC880_HP_EVENT:
Takashi Iwaid922b512011-04-28 12:18:53 +02001220 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001221 break;
1222 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001223 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001224 break;
1225 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001226}
1227
1228static void alc_inithook(struct hda_codec *codec)
1229{
Takashi Iwaid922b512011-04-28 12:18:53 +02001230 alc_hp_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001231 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001232}
1233
Kailang Yangf9423e72008-05-27 12:32:25 +02001234/* additional initialization for ALC888 variants */
1235static void alc888_coef_init(struct hda_codec *codec)
1236{
1237 unsigned int tmp;
1238
1239 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1240 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1241 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001242 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001243 /* alc888S-VC */
1244 snd_hda_codec_read(codec, 0x20, 0,
1245 AC_VERB_SET_PROC_COEF, 0x830);
1246 else
1247 /* alc888-VB */
1248 snd_hda_codec_read(codec, 0x20, 0,
1249 AC_VERB_SET_PROC_COEF, 0x3030);
1250}
1251
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001252static void alc889_coef_init(struct hda_codec *codec)
1253{
1254 unsigned int tmp;
1255
1256 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1257 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1258 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1259 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1260}
1261
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001262/* turn on/off EAPD control (only if available) */
1263static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1264{
1265 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1266 return;
1267 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1268 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1269 on ? 2 : 0);
1270}
1271
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001272/* turn on/off EAPD controls of the codec */
1273static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
1274{
1275 /* We currently only handle front, HP */
1276 switch (codec->vendor_id) {
1277 case 0x10ec0260:
1278 set_eapd(codec, 0x0f, on);
1279 set_eapd(codec, 0x10, on);
1280 break;
1281 case 0x10ec0262:
1282 case 0x10ec0267:
1283 case 0x10ec0268:
1284 case 0x10ec0269:
1285 case 0x10ec0270:
1286 case 0x10ec0272:
1287 case 0x10ec0660:
1288 case 0x10ec0662:
1289 case 0x10ec0663:
1290 case 0x10ec0665:
1291 case 0x10ec0862:
1292 case 0x10ec0889:
1293 case 0x10ec0892:
1294 set_eapd(codec, 0x14, on);
1295 set_eapd(codec, 0x15, on);
1296 break;
1297 }
1298}
1299
Takashi Iwai1c7161532011-04-07 10:37:16 +02001300/* generic shutup callback;
1301 * just turning off EPAD and a little pause for avoiding pop-noise
1302 */
1303static void alc_eapd_shutup(struct hda_codec *codec)
1304{
1305 alc_auto_setup_eapd(codec, false);
1306 msleep(200);
1307}
1308
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001309static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001310{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001311 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001312
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001313 switch (type) {
1314 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001315 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1316 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001317 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001318 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1319 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001320 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001321 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1322 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001323 case ALC_INIT_DEFAULT:
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001324 alc_auto_setup_eapd(codec, true);
Kailang Yangc9b58002007-10-16 14:30:01 +02001325 switch (codec->vendor_id) {
1326 case 0x10ec0260:
1327 snd_hda_codec_write(codec, 0x1a, 0,
1328 AC_VERB_SET_COEF_INDEX, 7);
1329 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1330 AC_VERB_GET_PROC_COEF, 0);
1331 snd_hda_codec_write(codec, 0x1a, 0,
1332 AC_VERB_SET_COEF_INDEX, 7);
1333 snd_hda_codec_write(codec, 0x1a, 0,
1334 AC_VERB_SET_PROC_COEF,
1335 tmp | 0x2010);
1336 break;
1337 case 0x10ec0262:
1338 case 0x10ec0880:
1339 case 0x10ec0882:
1340 case 0x10ec0883:
1341 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001342 case 0x10ec0887:
Takashi Iwai20b67dd2011-03-23 22:54:32 +01001343 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001344 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001346 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001347 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001348 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001349#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001350 case 0x10ec0267:
1351 case 0x10ec0268:
1352 snd_hda_codec_write(codec, 0x20, 0,
1353 AC_VERB_SET_COEF_INDEX, 7);
1354 tmp = snd_hda_codec_read(codec, 0x20, 0,
1355 AC_VERB_GET_PROC_COEF, 0);
1356 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001357 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001358 snd_hda_codec_write(codec, 0x20, 0,
1359 AC_VERB_SET_PROC_COEF,
1360 tmp | 0x3000);
1361 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001362#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001363 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001364 break;
1365 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001366}
Kailang Yangea1fb292008-08-26 12:58:38 +02001367
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001368static void alc_init_auto_hp(struct hda_codec *codec)
1369{
1370 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001371 struct auto_pin_cfg *cfg = &spec->autocfg;
1372 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001373
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001374 if (!cfg->hp_pins[0]) {
1375 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001376 return;
1377 }
1378
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001379 if (!cfg->speaker_pins[0]) {
1380 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1381 return;
1382 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1383 sizeof(cfg->speaker_pins));
1384 cfg->speaker_outs = cfg->line_outs;
1385 }
1386
1387 if (!cfg->hp_pins[0]) {
1388 memcpy(cfg->hp_pins, cfg->line_out_pins,
1389 sizeof(cfg->hp_pins));
1390 cfg->hp_outs = cfg->line_outs;
1391 }
1392
1393 for (i = 0; i < cfg->hp_outs; i++) {
1394 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1395 cfg->hp_pins[i]);
1396 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001397 AC_VERB_SET_UNSOLICITED_ENABLE,
1398 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaid922b512011-04-28 12:18:53 +02001399 spec->automute = 1;
1400 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001401 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001402 spec->unsol_event = alc_sku_unsol_event;
1403}
1404
Takashi Iwai6c819492009-08-10 18:47:44 +02001405static void alc_init_auto_mic(struct hda_codec *codec)
1406{
1407 struct alc_spec *spec = codec->spec;
1408 struct auto_pin_cfg *cfg = &spec->autocfg;
1409 hda_nid_t fixed, ext;
1410 int i;
1411
1412 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001413 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001414 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001415 return;
1416
1417 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001418 for (i = 0; i < cfg->num_inputs; i++) {
1419 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001420 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001421 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001422 switch (snd_hda_get_input_pin_attr(defcfg)) {
1423 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001424 if (fixed)
1425 return; /* already occupied */
1426 fixed = nid;
1427 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001428 case INPUT_PIN_ATTR_UNUSED:
1429 return; /* invalid entry */
1430 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001431 if (ext)
1432 return; /* already occupied */
1433 ext = nid;
1434 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001435 }
1436 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001437 if (!ext || !fixed)
1438 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001439 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1440 return; /* no unsol support */
1441 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1442 ext, fixed);
1443 spec->ext_mic.pin = ext;
1444 spec->int_mic.pin = fixed;
1445 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1446 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1447 spec->auto_mic = 1;
1448 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1449 AC_VERB_SET_UNSOLICITED_ENABLE,
1450 AC_USRSP_EN | ALC880_MIC_EVENT);
1451 spec->unsol_event = alc_sku_unsol_event;
1452}
1453
David Henningsson90622912010-10-14 14:50:18 +02001454/* Could be any non-zero and even value. When used as fixup, tells
1455 * the driver to ignore any present sku defines.
1456 */
1457#define ALC_FIXUP_SKU_IGNORE (2)
1458
Kailang Yangda00c242010-03-19 11:23:45 +01001459static int alc_auto_parse_customize_define(struct hda_codec *codec)
1460{
1461 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001462 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001463 struct alc_spec *spec = codec->spec;
1464
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001465 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1466
David Henningsson90622912010-10-14 14:50:18 +02001467 if (spec->cdefine.fixup) {
1468 ass = spec->cdefine.sku_cfg;
1469 if (ass == ALC_FIXUP_SKU_IGNORE)
1470 return -1;
1471 goto do_sku;
1472 }
1473
Kailang Yangda00c242010-03-19 11:23:45 +01001474 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001475 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001476 goto do_sku;
1477
1478 nid = 0x1d;
1479 if (codec->vendor_id == 0x10ec0260)
1480 nid = 0x17;
1481 ass = snd_hda_codec_get_pincfg(codec, nid);
1482
1483 if (!(ass & 1)) {
1484 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1485 codec->chip_name, ass);
1486 return -1;
1487 }
1488
1489 /* check sum */
1490 tmp = 0;
1491 for (i = 1; i < 16; i++) {
1492 if ((ass >> i) & 1)
1493 tmp++;
1494 }
1495 if (((ass >> 16) & 0xf) != tmp)
1496 return -1;
1497
1498 spec->cdefine.port_connectivity = ass >> 30;
1499 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1500 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1501 spec->cdefine.customization = ass >> 8;
1502do_sku:
1503 spec->cdefine.sku_cfg = ass;
1504 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1505 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1506 spec->cdefine.swap = (ass & 0x2) >> 1;
1507 spec->cdefine.override = ass & 0x1;
1508
1509 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1510 nid, spec->cdefine.sku_cfg);
1511 snd_printd("SKU: port_connectivity=0x%x\n",
1512 spec->cdefine.port_connectivity);
1513 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1514 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1515 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1516 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1517 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1518 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1519 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1520
1521 return 0;
1522}
1523
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001524/* check subsystem ID and set up device-specific initialization;
1525 * return 1 if initialized, 0 if invalid SSID
1526 */
1527/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1528 * 31 ~ 16 : Manufacture ID
1529 * 15 ~ 8 : SKU ID
1530 * 7 ~ 0 : Assembly ID
1531 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1532 */
1533static int alc_subsystem_id(struct hda_codec *codec,
1534 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001535 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001536{
1537 unsigned int ass, tmp, i;
1538 unsigned nid;
1539 struct alc_spec *spec = codec->spec;
1540
David Henningsson90622912010-10-14 14:50:18 +02001541 if (spec->cdefine.fixup) {
1542 ass = spec->cdefine.sku_cfg;
1543 if (ass == ALC_FIXUP_SKU_IGNORE)
1544 return 0;
1545 goto do_sku;
1546 }
1547
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001548 ass = codec->subsystem_id & 0xffff;
1549 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1550 goto do_sku;
1551
1552 /* invalid SSID, check the special NID pin defcfg instead */
1553 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001554 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001555 * 29~21 : reserve
1556 * 20 : PCBEEP input
1557 * 19~16 : Check sum (15:1)
1558 * 15~1 : Custom
1559 * 0 : override
1560 */
1561 nid = 0x1d;
1562 if (codec->vendor_id == 0x10ec0260)
1563 nid = 0x17;
1564 ass = snd_hda_codec_get_pincfg(codec, nid);
1565 snd_printd("realtek: No valid SSID, "
1566 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001567 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001568 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001569 return 0;
1570 if ((ass >> 30) != 1) /* no physical connection */
1571 return 0;
1572
1573 /* check sum */
1574 tmp = 0;
1575 for (i = 1; i < 16; i++) {
1576 if ((ass >> i) & 1)
1577 tmp++;
1578 }
1579 if (((ass >> 16) & 0xf) != tmp)
1580 return 0;
1581do_sku:
1582 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1583 ass & 0xffff, codec->vendor_id);
1584 /*
1585 * 0 : override
1586 * 1 : Swap Jack
1587 * 2 : 0 --> Desktop, 1 --> Laptop
1588 * 3~5 : External Amplifier control
1589 * 7~6 : Reserved
1590 */
1591 tmp = (ass & 0x38) >> 3; /* external Amp control */
1592 switch (tmp) {
1593 case 1:
1594 spec->init_amp = ALC_INIT_GPIO1;
1595 break;
1596 case 3:
1597 spec->init_amp = ALC_INIT_GPIO2;
1598 break;
1599 case 7:
1600 spec->init_amp = ALC_INIT_GPIO3;
1601 break;
1602 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001603 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001604 spec->init_amp = ALC_INIT_DEFAULT;
1605 break;
1606 }
1607
1608 /* is laptop or Desktop and enable the function "Mute internal speaker
1609 * when the external headphone out jack is plugged"
1610 */
1611 if (!(ass & 0x8000))
1612 return 1;
1613 /*
1614 * 10~8 : Jack location
1615 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1616 * 14~13: Resvered
1617 * 15 : 1 --> enable the function "Mute internal speaker
1618 * when the external headphone out jack is plugged"
1619 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001620 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001621 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001622 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1623 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001624 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001625 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001626 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001627 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001628 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001629 else if (tmp == 3)
1630 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001631 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001632 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001633 for (i = 0; i < spec->autocfg.line_outs; i++)
1634 if (spec->autocfg.line_out_pins[i] == nid)
1635 return 1;
1636 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001637 }
1638
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001639 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001640 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001641 return 1;
1642}
Kailang Yangea1fb292008-08-26 12:58:38 +02001643
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001644static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001645 hda_nid_t porta, hda_nid_t porte,
1646 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001647{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001648 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001649 struct alc_spec *spec = codec->spec;
1650 snd_printd("realtek: "
1651 "Enable default setup for auto mode as fallback\n");
1652 spec->init_amp = ALC_INIT_DEFAULT;
1653 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001654 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001655 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001656}
1657
Takashi Iwai41e41f12005-06-08 14:48:49 +02001658/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001659 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001660 */
1661
1662struct alc_pincfg {
1663 hda_nid_t nid;
1664 u32 val;
1665};
1666
Todd Broche1eb5f12010-12-06 11:19:51 -08001667struct alc_model_fixup {
1668 const int id;
1669 const char *name;
1670};
1671
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001672struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001673 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001674 bool chained;
1675 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001676 union {
1677 unsigned int sku;
1678 const struct alc_pincfg *pins;
1679 const struct hda_verb *verbs;
1680 void (*func)(struct hda_codec *codec,
1681 const struct alc_fixup *fix,
1682 int action);
1683 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001684};
1685
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001686enum {
1687 ALC_FIXUP_INVALID,
1688 ALC_FIXUP_SKU,
1689 ALC_FIXUP_PINS,
1690 ALC_FIXUP_VERBS,
1691 ALC_FIXUP_FUNC,
1692};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001693
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001694enum {
1695 ALC_FIXUP_ACT_PRE_PROBE,
1696 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001697 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001698};
1699
1700static void alc_apply_fixup(struct hda_codec *codec, int action)
1701{
1702 struct alc_spec *spec = codec->spec;
1703 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001704#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001705 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001706#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001707 int depth = 0;
1708
1709 if (!spec->fixup_list)
1710 return;
1711
1712 while (id >= 0) {
1713 const struct alc_fixup *fix = spec->fixup_list + id;
1714 const struct alc_pincfg *cfg;
1715
1716 switch (fix->type) {
1717 case ALC_FIXUP_SKU:
1718 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1719 break;;
1720 snd_printdd(KERN_INFO "hda_codec: %s: "
1721 "Apply sku override for %s\n",
1722 codec->chip_name, modelname);
1723 spec->cdefine.sku_cfg = fix->v.sku;
1724 spec->cdefine.fixup = 1;
1725 break;
1726 case ALC_FIXUP_PINS:
1727 cfg = fix->v.pins;
1728 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1729 break;
1730 snd_printdd(KERN_INFO "hda_codec: %s: "
1731 "Apply pincfg for %s\n",
1732 codec->chip_name, modelname);
1733 for (; cfg->nid; cfg++)
1734 snd_hda_codec_set_pincfg(codec, cfg->nid,
1735 cfg->val);
1736 break;
1737 case ALC_FIXUP_VERBS:
1738 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1739 break;
1740 snd_printdd(KERN_INFO "hda_codec: %s: "
1741 "Apply fix-verbs for %s\n",
1742 codec->chip_name, modelname);
1743 add_verb(codec->spec, fix->v.verbs);
1744 break;
1745 case ALC_FIXUP_FUNC:
1746 if (!fix->v.func)
1747 break;
1748 snd_printdd(KERN_INFO "hda_codec: %s: "
1749 "Apply fix-func for %s\n",
1750 codec->chip_name, modelname);
1751 fix->v.func(codec, fix, action);
1752 break;
1753 default:
1754 snd_printk(KERN_ERR "hda_codec: %s: "
1755 "Invalid fixup type %d\n",
1756 codec->chip_name, fix->type);
1757 break;
1758 }
1759 if (!fix[id].chained)
1760 break;
1761 if (++depth > 10)
1762 break;
1763 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001764 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001765}
1766
Todd Broche1eb5f12010-12-06 11:19:51 -08001767static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001768 const struct alc_model_fixup *models,
1769 const struct snd_pci_quirk *quirk,
1770 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001771{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001772 struct alc_spec *spec = codec->spec;
1773 int id = -1;
1774 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001775
Todd Broche1eb5f12010-12-06 11:19:51 -08001776 if (codec->modelname && models) {
1777 while (models->name) {
1778 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001779 id = models->id;
1780 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001781 break;
1782 }
1783 models++;
1784 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001785 }
1786 if (id < 0) {
1787 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1788 if (quirk) {
1789 id = quirk->value;
1790#ifdef CONFIG_SND_DEBUG_VERBOSE
1791 name = quirk->name;
1792#endif
1793 }
1794 }
1795
1796 spec->fixup_id = id;
1797 if (id >= 0) {
1798 spec->fixup_list = fixlist;
1799 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001800 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001801}
1802
Kailang Yang274693f2009-12-03 10:07:50 +01001803static int alc_read_coef_idx(struct hda_codec *codec,
1804 unsigned int coef_idx)
1805{
1806 unsigned int val;
1807 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1808 coef_idx);
1809 val = snd_hda_codec_read(codec, 0x20, 0,
1810 AC_VERB_GET_PROC_COEF, 0);
1811 return val;
1812}
1813
Kailang Yang977ddd62010-09-15 10:02:29 +02001814static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1815 unsigned int coef_val)
1816{
1817 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1818 coef_idx);
1819 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1820 coef_val);
1821}
1822
Takashi Iwai757899a2010-07-30 10:48:14 +02001823/* set right pin controls for digital I/O */
1824static void alc_auto_init_digital(struct hda_codec *codec)
1825{
1826 struct alc_spec *spec = codec->spec;
1827 int i;
1828 hda_nid_t pin;
1829
1830 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1831 pin = spec->autocfg.dig_out_pins[i];
1832 if (pin) {
1833 snd_hda_codec_write(codec, pin, 0,
1834 AC_VERB_SET_PIN_WIDGET_CONTROL,
1835 PIN_OUT);
1836 }
1837 }
1838 pin = spec->autocfg.dig_in_pin;
1839 if (pin)
1840 snd_hda_codec_write(codec, pin, 0,
1841 AC_VERB_SET_PIN_WIDGET_CONTROL,
1842 PIN_IN);
1843}
1844
1845/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1846static void alc_auto_parse_digital(struct hda_codec *codec)
1847{
1848 struct alc_spec *spec = codec->spec;
1849 int i, err;
1850 hda_nid_t dig_nid;
1851
1852 /* support multiple SPDIFs; the secondary is set up as a slave */
1853 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1854 err = snd_hda_get_connections(codec,
1855 spec->autocfg.dig_out_pins[i],
1856 &dig_nid, 1);
1857 if (err < 0)
1858 continue;
1859 if (!i) {
1860 spec->multiout.dig_out_nid = dig_nid;
1861 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1862 } else {
1863 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1864 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1865 break;
1866 spec->slave_dig_outs[i - 1] = dig_nid;
1867 }
1868 }
1869
1870 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001871 dig_nid = codec->start_nid;
1872 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1873 unsigned int wcaps = get_wcaps(codec, dig_nid);
1874 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1875 continue;
1876 if (!(wcaps & AC_WCAP_DIGITAL))
1877 continue;
1878 if (!(wcaps & AC_WCAP_CONN_LIST))
1879 continue;
1880 err = get_connection_index(codec, dig_nid,
1881 spec->autocfg.dig_in_pin);
1882 if (err >= 0) {
1883 spec->dig_in_nid = dig_nid;
1884 break;
1885 }
1886 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001887 }
1888}
1889
Takashi Iwaif95474e2007-07-10 00:47:43 +02001890/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001891 * ALC888
1892 */
1893
1894/*
1895 * 2ch mode
1896 */
1897static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1898/* Mic-in jack as mic in */
1899 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1900 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1901/* Line-in jack as Line in */
1902 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1903 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1904/* Line-Out as Front */
1905 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1906 { } /* end */
1907};
1908
1909/*
1910 * 4ch mode
1911 */
1912static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1913/* Mic-in jack as mic in */
1914 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1915 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1916/* Line-in jack as Surround */
1917 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1918 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1919/* Line-Out as Front */
1920 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1921 { } /* end */
1922};
1923
1924/*
1925 * 6ch mode
1926 */
1927static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1928/* Mic-in jack as CLFE */
1929 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1930 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1931/* Line-in jack as Surround */
1932 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1933 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1934/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1935 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1936 { } /* end */
1937};
1938
1939/*
1940 * 8ch mode
1941 */
1942static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1943/* Mic-in jack as CLFE */
1944 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1945 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1946/* Line-in jack as Surround */
1947 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1948 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1949/* Line-Out as Side */
1950 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1951 { } /* end */
1952};
1953
1954static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1955 { 2, alc888_4ST_ch2_intel_init },
1956 { 4, alc888_4ST_ch4_intel_init },
1957 { 6, alc888_4ST_ch6_intel_init },
1958 { 8, alc888_4ST_ch8_intel_init },
1959};
1960
1961/*
1962 * ALC888 Fujitsu Siemens Amillo xa3530
1963 */
1964
1965static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1966/* Front Mic: set to PIN_IN (empty by default) */
1967 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1968/* Connect Internal HP to Front */
1969 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1972/* Connect Bass HP to Front */
1973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1974 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1976/* Connect Line-Out side jack (SPDIF) to Side */
1977 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1978 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1979 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1980/* Connect Mic jack to CLFE */
1981 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1982 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1983 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1984/* Connect Line-in jack to Surround */
1985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1986 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1988/* Connect HP out jack to Front */
1989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1990 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1991 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1992/* Enable unsolicited event for HP jack and Line-out jack */
1993 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1994 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1995 {}
1996};
1997
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001998static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001999{
2000 struct alc_spec *spec = codec->spec;
2001
2002 spec->autocfg.hp_pins[0] = 0x15;
2003 spec->autocfg.speaker_pins[0] = 0x14;
2004 spec->autocfg.speaker_pins[1] = 0x16;
2005 spec->autocfg.speaker_pins[2] = 0x17;
2006 spec->autocfg.speaker_pins[3] = 0x19;
2007 spec->autocfg.speaker_pins[4] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02002008 spec->automute = 1;
2009 spec->automute_mode = ALC_AUTOMUTE_AMP;
Wu Fengguang6732bd02009-07-30 09:19:14 +02002010}
2011
2012static void alc889_intel_init_hook(struct hda_codec *codec)
2013{
2014 alc889_coef_init(codec);
Takashi Iwaid922b512011-04-28 12:18:53 +02002015 alc_hp_automute(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02002016}
2017
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002018static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002019{
2020 struct alc_spec *spec = codec->spec;
2021
2022 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
2023 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
2024 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
2025 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaid922b512011-04-28 12:18:53 +02002026 spec->automute = 1;
2027 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002028}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002029
2030/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002031 * ALC888 Acer Aspire 4930G model
2032 */
2033
2034static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
2035/* Front Mic: set to PIN_IN (empty by default) */
2036 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2037/* Unselect Front Mic by default in input mixer 3 */
2038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002039/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002040 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2041/* Connect Internal HP to front */
2042 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2043 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2044 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2045/* Connect HP out to front */
2046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2047 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2048 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002049 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002050 { }
2051};
2052
Hector Martin3b315d72009-06-02 10:54:19 +02002053/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002054 * ALC888 Acer Aspire 6530G model
2055 */
2056
2057static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002058/* Route to built-in subwoofer as well as speakers */
2059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2061 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2062 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002063/* Bias voltage on for external mic port */
2064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002065/* Front Mic: set to PIN_IN (empty by default) */
2066 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2067/* Unselect Front Mic by default in input mixer 3 */
2068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002069/* Enable unsolicited event for HP jack */
2070 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2071/* Enable speaker output */
2072 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2073 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002074 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002075/* Enable headphone output */
2076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002079 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002080 { }
2081};
2082
2083/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002084 *ALC888 Acer Aspire 7730G model
2085 */
2086
2087static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2088/* Bias voltage on for external mic port */
2089 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2090/* Front Mic: set to PIN_IN (empty by default) */
2091 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2092/* Unselect Front Mic by default in input mixer 3 */
2093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2094/* Enable unsolicited event for HP jack */
2095 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2096/* Enable speaker output */
2097 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2098 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2099 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2100/* Enable headphone output */
2101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2102 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2103 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2104 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2105/*Enable internal subwoofer */
2106 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2107 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2108 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2109 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2110 { }
2111};
2112
2113/*
Hector Martin018df412009-06-04 00:13:40 +02002114 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002115 */
2116
Hector Martin018df412009-06-04 00:13:40 +02002117static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002118/* Front Mic: set to PIN_IN (empty by default) */
2119 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2120/* Unselect Front Mic by default in input mixer 3 */
2121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2122/* Enable unsolicited event for HP jack */
2123 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2124/* Connect Internal Front to Front */
2125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2126 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2127 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2128/* Connect Internal Rear to Rear */
2129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2130 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2131 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2132/* Connect Internal CLFE to CLFE */
2133 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2134 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2135 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2136/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002138 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2139 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2140/* Enable all DACs */
2141/* DAC DISABLE/MUTE 1? */
2142/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2143 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2144 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2145/* DAC DISABLE/MUTE 2? */
2146/* some bit here disables the other DACs. Init=0x4900 */
2147 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2148 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002149/* DMIC fix
2150 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2151 * which makes the stereo useless. However, either the mic or the ALC889
2152 * makes the signal become a difference/sum signal instead of standard
2153 * stereo, which is annoying. So instead we flip this bit which makes the
2154 * codec replicate the sum signal to both channels, turning it into a
2155 * normal mono mic.
2156 */
2157/* DMIC_CONTROL? Init value = 0x0001 */
2158 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2159 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002160 { }
2161};
2162
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002163static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002164 /* Front mic only available on one ADC */
2165 {
2166 .num_items = 4,
2167 .items = {
2168 { "Mic", 0x0 },
2169 { "Line", 0x2 },
2170 { "CD", 0x4 },
2171 { "Front Mic", 0xb },
2172 },
2173 },
2174 {
2175 .num_items = 3,
2176 .items = {
2177 { "Mic", 0x0 },
2178 { "Line", 0x2 },
2179 { "CD", 0x4 },
2180 },
2181 }
2182};
2183
Tony Vroond2fd4b02009-06-21 00:40:10 +01002184static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2185 /* Interal mic only available on one ADC */
2186 {
Tony Vroon684a8842009-06-26 09:27:50 +01002187 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002188 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002189 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002190 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002191 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002192 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002193 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002194 },
2195 },
2196 {
Tony Vroon684a8842009-06-26 09:27:50 +01002197 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002198 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002199 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002200 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002201 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002202 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002203 },
2204 }
2205};
2206
Hector Martin018df412009-06-04 00:13:40 +02002207static struct hda_input_mux alc889_capture_sources[3] = {
2208 /* Digital mic only available on first "ADC" */
2209 {
2210 .num_items = 5,
2211 .items = {
2212 { "Mic", 0x0 },
2213 { "Line", 0x2 },
2214 { "CD", 0x4 },
2215 { "Front Mic", 0xb },
2216 { "Input Mix", 0xa },
2217 },
2218 },
2219 {
2220 .num_items = 4,
2221 .items = {
2222 { "Mic", 0x0 },
2223 { "Line", 0x2 },
2224 { "CD", 0x4 },
2225 { "Input Mix", 0xa },
2226 },
2227 },
2228 {
2229 .num_items = 4,
2230 .items = {
2231 { "Mic", 0x0 },
2232 { "Line", 0x2 },
2233 { "CD", 0x4 },
2234 { "Input Mix", 0xa },
2235 },
2236 }
2237};
2238
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002239static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002240 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2241 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2242 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2243 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2244 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2245 HDA_OUTPUT),
2246 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2247 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2248 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2249 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2250 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2251 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2252 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2254 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002256 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002257 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002258 { } /* end */
2259};
2260
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002261static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2262 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2263 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2264 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2265 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002266 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002267 HDA_OUTPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002268 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2269 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2270 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2271 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2272 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002273 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2274 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2275 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2276 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2279 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2280 { } /* end */
2281};
2282
Hector Martin556eea92009-12-20 22:51:23 +01002283static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2284 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2285 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2286 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2287 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2288 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2289 HDA_OUTPUT),
2290 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2291 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2292 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2293 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2294 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002296 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2298 { } /* end */
2299};
2300
2301
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002302static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002303{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002304 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002305
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002306 spec->autocfg.hp_pins[0] = 0x15;
2307 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002308 spec->autocfg.speaker_pins[1] = 0x16;
2309 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002310 spec->automute = 1;
2311 spec->automute_mode = ALC_AUTOMUTE_AMP;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002312}
2313
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002314static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002315{
2316 struct alc_spec *spec = codec->spec;
2317
2318 spec->autocfg.hp_pins[0] = 0x15;
2319 spec->autocfg.speaker_pins[0] = 0x14;
2320 spec->autocfg.speaker_pins[1] = 0x16;
2321 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002322 spec->automute = 1;
2323 spec->automute_mode = ALC_AUTOMUTE_AMP;
Emilio López320d5922009-06-25 08:18:44 +02002324}
2325
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002326static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2327{
2328 struct alc_spec *spec = codec->spec;
2329
2330 spec->autocfg.hp_pins[0] = 0x15;
2331 spec->autocfg.speaker_pins[0] = 0x14;
2332 spec->autocfg.speaker_pins[1] = 0x16;
2333 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002334 spec->automute = 1;
2335 spec->automute_mode = ALC_AUTOMUTE_AMP;
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002336}
2337
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002338static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002339{
2340 struct alc_spec *spec = codec->spec;
2341
2342 spec->autocfg.hp_pins[0] = 0x15;
2343 spec->autocfg.speaker_pins[0] = 0x14;
2344 spec->autocfg.speaker_pins[1] = 0x16;
2345 spec->autocfg.speaker_pins[2] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02002346 spec->automute = 1;
2347 spec->automute_mode = ALC_AUTOMUTE_AMP;
Hector Martin3b315d72009-06-02 10:54:19 +02002348}
2349
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002350/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002351 * ALC880 3-stack model
2352 *
2353 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002354 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2355 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 */
2357
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002358static hda_nid_t alc880_dac_nids[4] = {
2359 /* front, rear, clfe, rear_surr */
2360 0x02, 0x05, 0x04, 0x03
2361};
2362
2363static hda_nid_t alc880_adc_nids[3] = {
2364 /* ADC0-2 */
2365 0x07, 0x08, 0x09,
2366};
2367
2368/* The datasheet says the node 0x07 is connected from inputs,
2369 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002370 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002372static hda_nid_t alc880_adc_nids_alt[2] = {
2373 /* ADC1-2 */
2374 0x08, 0x09,
2375};
2376
2377#define ALC880_DIGOUT_NID 0x06
2378#define ALC880_DIGIN_NID 0x0a
2379
2380static struct hda_input_mux alc880_capture_source = {
2381 .num_items = 4,
2382 .items = {
2383 { "Mic", 0x0 },
2384 { "Front Mic", 0x3 },
2385 { "Line", 0x2 },
2386 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002387 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002388};
2389
2390/* channel source setting (2/6 channel selection for 3-stack) */
2391/* 2ch mode */
2392static struct hda_verb alc880_threestack_ch2_init[] = {
2393 /* set line-in to input, mute it */
2394 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2395 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2396 /* set mic-in to input vref 80%, mute it */
2397 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2398 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002399 { } /* end */
2400};
2401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002402/* 6ch mode */
2403static struct hda_verb alc880_threestack_ch6_init[] = {
2404 /* set line-in to output, unmute it */
2405 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2406 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2407 /* set mic-in to output, unmute it */
2408 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2409 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2410 { } /* end */
2411};
2412
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002413static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002414 { 2, alc880_threestack_ch2_init },
2415 { 6, alc880_threestack_ch6_init },
2416};
2417
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002418static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002419 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002420 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002421 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002422 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002423 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2424 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002425 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2426 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2428 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2429 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2430 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002436 {
2437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2438 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002439 .info = alc_ch_mode_info,
2440 .get = alc_ch_mode_get,
2441 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002442 },
2443 { } /* end */
2444};
2445
2446/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002447static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2448 struct snd_ctl_elem_info *uinfo)
2449{
2450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2451 struct alc_spec *spec = codec->spec;
2452 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002453
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002454 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002455 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2456 HDA_INPUT);
2457 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002458 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002459 return err;
2460}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002462static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2463 unsigned int size, unsigned int __user *tlv)
2464{
2465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2466 struct alc_spec *spec = codec->spec;
2467 int err;
2468
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002469 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002470 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2471 HDA_INPUT);
2472 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002473 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002474 return err;
2475}
2476
2477typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2478 struct snd_ctl_elem_value *ucontrol);
2479
2480static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2481 struct snd_ctl_elem_value *ucontrol,
2482 getput_call_t func)
2483{
2484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2485 struct alc_spec *spec = codec->spec;
2486 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2487 int err;
2488
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002489 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002490 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2491 3, 0, HDA_INPUT);
2492 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002493 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002494 return err;
2495}
2496
2497static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2498 struct snd_ctl_elem_value *ucontrol)
2499{
2500 return alc_cap_getput_caller(kcontrol, ucontrol,
2501 snd_hda_mixer_amp_volume_get);
2502}
2503
2504static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2505 struct snd_ctl_elem_value *ucontrol)
2506{
2507 return alc_cap_getput_caller(kcontrol, ucontrol,
2508 snd_hda_mixer_amp_volume_put);
2509}
2510
2511/* capture mixer elements */
2512#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2513
2514static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2515 struct snd_ctl_elem_value *ucontrol)
2516{
2517 return alc_cap_getput_caller(kcontrol, ucontrol,
2518 snd_hda_mixer_amp_switch_get);
2519}
2520
2521static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2522 struct snd_ctl_elem_value *ucontrol)
2523{
2524 return alc_cap_getput_caller(kcontrol, ucontrol,
2525 snd_hda_mixer_amp_switch_put);
2526}
2527
Takashi Iwaia23b6882009-03-23 15:21:36 +01002528#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002529 { \
2530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2531 .name = "Capture Switch", \
2532 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2533 .count = num, \
2534 .info = alc_cap_sw_info, \
2535 .get = alc_cap_sw_get, \
2536 .put = alc_cap_sw_put, \
2537 }, \
2538 { \
2539 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2540 .name = "Capture Volume", \
2541 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2542 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2543 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2544 .count = num, \
2545 .info = alc_cap_vol_info, \
2546 .get = alc_cap_vol_get, \
2547 .put = alc_cap_vol_put, \
2548 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002549 }
2550
2551#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002552 { \
2553 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2554 /* .name = "Capture Source", */ \
2555 .name = "Input Source", \
2556 .count = num, \
2557 .info = alc_mux_enum_info, \
2558 .get = alc_mux_enum_get, \
2559 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002560 }
2561
2562#define DEFINE_CAPMIX(num) \
2563static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2564 _DEFINE_CAPMIX(num), \
2565 _DEFINE_CAPSRC(num), \
2566 { } /* end */ \
2567}
2568
2569#define DEFINE_CAPMIX_NOSRC(num) \
2570static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2571 _DEFINE_CAPMIX(num), \
2572 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002573}
2574
2575/* up to three ADCs */
2576DEFINE_CAPMIX(1);
2577DEFINE_CAPMIX(2);
2578DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002579DEFINE_CAPMIX_NOSRC(1);
2580DEFINE_CAPMIX_NOSRC(2);
2581DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002582
2583/*
2584 * ALC880 5-stack model
2585 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002586 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2587 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2589 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2590 */
2591
2592/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002593static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002594 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002595 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 { } /* end */
2597};
2598
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002599/* channel source setting (6/8 channel selection for 5-stack) */
2600/* 6ch mode */
2601static struct hda_verb alc880_fivestack_ch6_init[] = {
2602 /* set line-in to input, mute it */
2603 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2604 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002605 { } /* end */
2606};
2607
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608/* 8ch mode */
2609static struct hda_verb alc880_fivestack_ch8_init[] = {
2610 /* set line-in to output, unmute it */
2611 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2612 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2613 { } /* end */
2614};
2615
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002616static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617 { 6, alc880_fivestack_ch6_init },
2618 { 8, alc880_fivestack_ch8_init },
2619};
2620
2621
2622/*
2623 * ALC880 6-stack model
2624 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002625 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2626 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002627 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2628 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2629 */
2630
2631static hda_nid_t alc880_6st_dac_nids[4] = {
2632 /* front, rear, clfe, rear_surr */
2633 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002634};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002635
2636static struct hda_input_mux alc880_6stack_capture_source = {
2637 .num_items = 4,
2638 .items = {
2639 { "Mic", 0x0 },
2640 { "Front Mic", 0x1 },
2641 { "Line", 0x2 },
2642 { "CD", 0x4 },
2643 },
2644};
2645
2646/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002647static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648 { 8, NULL },
2649};
2650
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002651static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002652 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002653 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002654 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002655 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002656 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2657 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002658 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2659 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002661 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2665 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2668 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2669 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 {
2671 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2672 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002673 .info = alc_ch_mode_info,
2674 .get = alc_ch_mode_get,
2675 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002676 },
2677 { } /* end */
2678};
2679
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680
2681/*
2682 * ALC880 W810 model
2683 *
2684 * W810 has rear IO for:
2685 * Front (DAC 02)
2686 * Surround (DAC 03)
2687 * Center/LFE (DAC 04)
2688 * Digital out (06)
2689 *
2690 * The system also has a pair of internal speakers, and a headphone jack.
2691 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002692 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002693 * There is a variable resistor to control the speaker or headphone
2694 * volume. This is a hardware-only device without a software API.
2695 *
2696 * Plugging headphones in will disable the internal speakers. This is
2697 * implemented in hardware, not via the driver using jack sense. In
2698 * a similar fashion, plugging into the rear socket marked "front" will
2699 * disable both the speakers and headphones.
2700 *
2701 * For input, there's a microphone jack, and an "audio in" jack.
2702 * These may not do anything useful with this driver yet, because I
2703 * haven't setup any initialization verbs for these yet...
2704 */
2705
2706static hda_nid_t alc880_w810_dac_nids[3] = {
2707 /* front, rear/surround, clfe */
2708 0x02, 0x03, 0x04
2709};
2710
2711/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002712static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002713 { 6, NULL }
2714};
2715
2716/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002717static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002718 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002719 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002720 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002721 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2723 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002724 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2725 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002726 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2727 { } /* end */
2728};
2729
2730
2731/*
2732 * Z710V model
2733 *
2734 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002735 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2736 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002737 */
2738
2739static hda_nid_t alc880_z71v_dac_nids[1] = {
2740 0x02
2741};
2742#define ALC880_Z71V_HP_DAC 0x03
2743
2744/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002745static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746 { 2, NULL }
2747};
2748
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002749static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002751 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002752 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002753 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2758 { } /* end */
2759};
2760
2761
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002762/*
2763 * ALC880 F1734 model
2764 *
2765 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2766 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2767 */
2768
2769static hda_nid_t alc880_f1734_dac_nids[1] = {
2770 0x03
2771};
2772#define ALC880_F1734_HP_DAC 0x02
2773
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002774static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002775 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002776 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002777 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2778 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002779 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2780 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002783 { } /* end */
2784};
2785
Takashi Iwai937b4162008-02-11 14:52:36 +01002786static struct hda_input_mux alc880_f1734_capture_source = {
2787 .num_items = 2,
2788 .items = {
2789 { "Mic", 0x1 },
2790 { "CD", 0x4 },
2791 },
2792};
2793
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002794
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795/*
2796 * ALC880 ASUS model
2797 *
2798 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2799 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2800 * Mic = 0x18, Line = 0x1a
2801 */
2802
2803#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2804#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2805
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002806static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002807 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002808 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002809 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002810 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002811 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2812 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002813 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2814 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002821 {
2822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2823 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002824 .info = alc_ch_mode_info,
2825 .get = alc_ch_mode_get,
2826 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002827 },
2828 { } /* end */
2829};
2830
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002831/*
2832 * ALC880 ASUS W1V model
2833 *
2834 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2835 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2836 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2837 */
2838
2839/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002840static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002841 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2842 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002843 { } /* end */
2844};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002845
Kailang Yangdf694da2005-12-05 19:42:22 +01002846/* TCL S700 */
2847static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2848 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2849 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2851 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2852 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2855 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2856 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002857 { } /* end */
2858};
2859
Kailang Yangccc656c2006-10-17 12:32:26 +02002860/* Uniwill */
2861static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002862 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2863 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2864 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2865 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002866 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2867 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2868 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2869 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2870 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2871 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2872 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2873 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2876 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002878 {
2879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2880 .name = "Channel Mode",
2881 .info = alc_ch_mode_info,
2882 .get = alc_ch_mode_get,
2883 .put = alc_ch_mode_put,
2884 },
2885 { } /* end */
2886};
2887
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002888static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2889 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2890 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2891 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2892 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002897 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2898 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002899 { } /* end */
2900};
2901
Kailang Yangccc656c2006-10-17 12:32:26 +02002902static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002903 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2904 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2905 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2906 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2909 { } /* end */
2910};
2911
Linus Torvalds1da177e2005-04-16 15:20:36 -07002912/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002913 * virtual master controls
2914 */
2915
2916/*
2917 * slave controls for virtual master
2918 */
Takashi Iwaiea734962011-01-17 11:29:34 +01002919static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002920 "Front Playback Volume",
2921 "Surround Playback Volume",
2922 "Center Playback Volume",
2923 "LFE Playback Volume",
2924 "Side Playback Volume",
2925 "Headphone Playback Volume",
2926 "Speaker Playback Volume",
2927 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002928 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002929 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002930 NULL,
2931};
2932
Takashi Iwaiea734962011-01-17 11:29:34 +01002933static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002934 "Front Playback Switch",
2935 "Surround Playback Switch",
2936 "Center Playback Switch",
2937 "LFE Playback Switch",
2938 "Side Playback Switch",
2939 "Headphone Playback Switch",
2940 "Speaker Playback Switch",
2941 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002942 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002943 "Line-Out Playback Switch",
2944 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002945 NULL,
2946};
2947
2948/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002949 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002951
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002952#define NID_MAPPING (-1)
2953
2954#define SUBDEV_SPEAKER_ (0 << 6)
2955#define SUBDEV_HP_ (1 << 6)
2956#define SUBDEV_LINE_ (2 << 6)
2957#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2958#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2959#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2960
Takashi Iwai603c4012008-07-30 15:01:44 +02002961static void alc_free_kctls(struct hda_codec *codec);
2962
Takashi Iwai67d634c2009-11-16 15:35:59 +01002963#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002964/* additional beep mixers; the actual parameters are overwritten at build */
2965static struct snd_kcontrol_new alc_beep_mixer[] = {
2966 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002967 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002968 { } /* end */
2969};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002970#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002971
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972static int alc_build_controls(struct hda_codec *codec)
2973{
2974 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002975 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002976 struct snd_kcontrol_new *knew;
2977 int i, j, err;
2978 unsigned int u;
2979 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002980
2981 for (i = 0; i < spec->num_mixers; i++) {
2982 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2983 if (err < 0)
2984 return err;
2985 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002986 if (spec->cap_mixer) {
2987 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2988 if (err < 0)
2989 return err;
2990 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002991 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002992 err = snd_hda_create_spdif_out_ctls(codec,
2993 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994 if (err < 0)
2995 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002996 if (!spec->no_analog) {
2997 err = snd_hda_create_spdif_share_sw(codec,
2998 &spec->multiout);
2999 if (err < 0)
3000 return err;
3001 spec->multiout.share_spdif = 1;
3002 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003 }
3004 if (spec->dig_in_nid) {
3005 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
3006 if (err < 0)
3007 return err;
3008 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01003009
Takashi Iwai67d634c2009-11-16 15:35:59 +01003010#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003011 /* create beep controls if needed */
3012 if (spec->beep_amp) {
3013 struct snd_kcontrol_new *knew;
3014 for (knew = alc_beep_mixer; knew->name; knew++) {
3015 struct snd_kcontrol *kctl;
3016 kctl = snd_ctl_new1(knew, codec);
3017 if (!kctl)
3018 return -ENOMEM;
3019 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003020 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003021 if (err < 0)
3022 return err;
3023 }
3024 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01003025#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003026
Takashi Iwai2134ea42008-01-10 16:53:55 +01003027 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003028 if (!spec->no_analog &&
3029 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003030 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01003031 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003032 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003033 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003034 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003035 if (err < 0)
3036 return err;
3037 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003038 if (!spec->no_analog &&
3039 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003040 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
3041 NULL, alc_slave_sws);
3042 if (err < 0)
3043 return err;
3044 }
3045
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003046 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02003047 if (spec->capsrc_nids || spec->adc_nids) {
3048 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3049 if (!kctl)
3050 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3051 for (i = 0; kctl && i < kctl->count; i++) {
3052 hda_nid_t *nids = spec->capsrc_nids;
3053 if (!nids)
3054 nids = spec->adc_nids;
3055 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3056 if (err < 0)
3057 return err;
3058 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003059 }
3060 if (spec->cap_mixer) {
3061 const char *kname = kctl ? kctl->id.name : NULL;
3062 for (knew = spec->cap_mixer; knew->name; knew++) {
3063 if (kname && strcmp(knew->name, kname) == 0)
3064 continue;
3065 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3066 for (i = 0; kctl && i < kctl->count; i++) {
3067 err = snd_hda_add_nid(codec, kctl, i,
3068 spec->adc_nids[i]);
3069 if (err < 0)
3070 return err;
3071 }
3072 }
3073 }
3074
3075 /* other nid->control mapping */
3076 for (i = 0; i < spec->num_mixers; i++) {
3077 for (knew = spec->mixers[i]; knew->name; knew++) {
3078 if (knew->iface != NID_MAPPING)
3079 continue;
3080 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3081 if (kctl == NULL)
3082 continue;
3083 u = knew->subdevice;
3084 for (j = 0; j < 4; j++, u >>= 8) {
3085 nid = u & 0x3f;
3086 if (nid == 0)
3087 continue;
3088 switch (u & 0xc0) {
3089 case SUBDEV_SPEAKER_:
3090 nid = spec->autocfg.speaker_pins[nid];
3091 break;
3092 case SUBDEV_LINE_:
3093 nid = spec->autocfg.line_out_pins[nid];
3094 break;
3095 case SUBDEV_HP_:
3096 nid = spec->autocfg.hp_pins[nid];
3097 break;
3098 default:
3099 continue;
3100 }
3101 err = snd_hda_add_nid(codec, kctl, 0, nid);
3102 if (err < 0)
3103 return err;
3104 }
3105 u = knew->private_value;
3106 for (j = 0; j < 4; j++, u >>= 8) {
3107 nid = u & 0xff;
3108 if (nid == 0)
3109 continue;
3110 err = snd_hda_add_nid(codec, kctl, 0, nid);
3111 if (err < 0)
3112 return err;
3113 }
3114 }
3115 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003116
3117 alc_free_kctls(codec); /* no longer needed */
3118
Linus Torvalds1da177e2005-04-16 15:20:36 -07003119 return 0;
3120}
3121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122
Linus Torvalds1da177e2005-04-16 15:20:36 -07003123/*
3124 * initialize the codec volumes, etc
3125 */
3126
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127/*
3128 * generic initialization of ADC, input mixers and output mixers
3129 */
3130static struct hda_verb alc880_volume_init_verbs[] = {
3131 /*
3132 * Unmute ADC0-2 and set the default input to mic-in
3133 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003134 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003136 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003138 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003140
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003141 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3142 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003143 * Note: PASD motherboards uses the Line In 2 as the input for front
3144 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003145 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003146 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3153 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003155 /*
3156 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003157 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003158 /* set vol=0 to output mixers */
3159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3160 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3161 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3163 /* set up input amps for analog loopback */
3164 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003165 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3166 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003169 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003171 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3172 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003173
3174 { }
3175};
3176
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177/*
3178 * 3-stack pin configuration:
3179 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3180 */
3181static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3182 /*
3183 * preset connection lists of input pins
3184 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3185 */
3186 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3187 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3188 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3189
3190 /*
3191 * Set pin mode and muting
3192 */
3193 /* set front pin widgets 0x14 for output */
3194 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3195 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3196 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3197 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3198 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3199 /* Mic2 (as headphone out) for HP output */
3200 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3201 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3202 /* Line In pin widget for input */
3203 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3204 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3205 /* Line2 (as front mic) pin widget for input and vref at 80% */
3206 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3207 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3208 /* CD pin widget for input */
3209 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3210
3211 { }
3212};
3213
3214/*
3215 * 5-stack pin configuration:
3216 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3217 * line-in/side = 0x1a, f-mic = 0x1b
3218 */
3219static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3220 /*
3221 * preset connection lists of input pins
3222 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3223 */
3224 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3225 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3226
3227 /*
3228 * Set pin mode and muting
3229 */
3230 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3232 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3233 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3234 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 /* unmute pins for output (no gain on this amp) */
3236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3238 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3239 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3240
Linus Torvalds1da177e2005-04-16 15:20:36 -07003241 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003242 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3244 /* Mic2 (as headphone out) for HP output */
3245 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003246 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247 /* Line In pin widget for input */
3248 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3249 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3250 /* Line2 (as front mic) pin widget for input and vref at 80% */
3251 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3252 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3253 /* CD pin widget for input */
3254 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003255
3256 { }
3257};
3258
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259/*
3260 * W810 pin configuration:
3261 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3262 */
3263static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003264 /* hphone/speaker input selector: front DAC */
3265 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3266
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3268 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3269 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3270 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3271 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3272 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3273
3274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003275 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003276
Linus Torvalds1da177e2005-04-16 15:20:36 -07003277 { }
3278};
3279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280/*
3281 * Z71V pin configuration:
3282 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3283 */
3284static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003285 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003289
Takashi Iwai16ded522005-06-10 19:58:24 +02003290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003291 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003292 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003294
3295 { }
3296};
3297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003298/*
3299 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003300 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3301 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003302 */
3303static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3304 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3305
Takashi Iwai16ded522005-06-10 19:58:24 +02003306 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003308 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003310 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003312 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3314
Takashi Iwai16ded522005-06-10 19:58:24 +02003315 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003316 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003317 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003321 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003322 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003323 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003324
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003325 { }
3326};
Takashi Iwai16ded522005-06-10 19:58:24 +02003327
Kailang Yangccc656c2006-10-17 12:32:26 +02003328/*
3329 * Uniwill pin configuration:
3330 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3331 * line = 0x1a
3332 */
3333static struct hda_verb alc880_uniwill_init_verbs[] = {
3334 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3335
3336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3337 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3340 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3341 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3342 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3343 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3350
3351 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3352 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3353 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3355 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3356 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3357 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3358 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3359 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3360
3361 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3362 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3363
3364 { }
3365};
3366
3367/*
3368* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003369* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003370 */
3371static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3372 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3373
3374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3375 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3377 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3378 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3379 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3382 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3384 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3386
3387 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3388 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3389 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3390 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3393
3394 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3395 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3396
3397 { }
3398};
3399
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003400static struct hda_verb alc880_beep_init_verbs[] = {
3401 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3402 { }
3403};
3404
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003405/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003406static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003407{
3408 unsigned int present;
3409 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003410
Wu Fengguang864f92b2009-11-18 12:38:02 +08003411 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003412 bits = present ? HDA_AMP_MUTE : 0;
3413 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003414}
3415
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003416static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003418 struct alc_spec *spec = codec->spec;
3419
3420 spec->autocfg.hp_pins[0] = 0x14;
3421 spec->autocfg.speaker_pins[0] = 0x15;
3422 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02003423 spec->automute = 1;
3424 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003425}
3426
3427static void alc880_uniwill_init_hook(struct hda_codec *codec)
3428{
Takashi Iwaid922b512011-04-28 12:18:53 +02003429 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003430 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003431}
3432
3433static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3434 unsigned int res)
3435{
3436 /* Looks like the unsol event is incompatible with the standard
3437 * definition. 4bit tag is placed at 28 bit!
3438 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003439 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003440 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003441 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003442 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003443 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02003444 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003445 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003446 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003447}
3448
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003449static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003450{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003451 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003452
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003453 spec->autocfg.hp_pins[0] = 0x14;
3454 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02003455 spec->automute = 1;
3456 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangccc656c2006-10-17 12:32:26 +02003457}
3458
3459static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3460{
3461 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003462
Kailang Yangccc656c2006-10-17 12:32:26 +02003463 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003464 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3465 present &= HDA_AMP_VOLMASK;
3466 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3467 HDA_AMP_VOLMASK, present);
3468 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3469 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003470}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003471
Kailang Yangccc656c2006-10-17 12:32:26 +02003472static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3473 unsigned int res)
3474{
3475 /* Looks like the unsol event is incompatible with the standard
3476 * definition. 4bit tag is placed at 28 bit!
3477 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003478 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003479 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003480 else
Takashi Iwaid922b512011-04-28 12:18:53 +02003481 alc_sku_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003482}
3483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003484/*
3485 * F1734 pin configuration:
3486 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3487 */
3488static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003489 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003490 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3491 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3492 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3493 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3494
3495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3499
3500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3501 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3505 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3506 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3507 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3508 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003509
Takashi Iwai937b4162008-02-11 14:52:36 +01003510 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3511 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3512
Takashi Iwai16ded522005-06-10 19:58:24 +02003513 { }
3514};
3515
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003516/*
3517 * ASUS pin configuration:
3518 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3519 */
3520static struct hda_verb alc880_pin_asus_init_verbs[] = {
3521 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3522 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3523 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3524 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3525
3526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3529 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3530 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3532 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3534
3535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3536 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3537 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3541 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3542 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3543 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003544
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 { }
3546};
3547
3548/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003549#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3550#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003551#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552
Kailang Yangdf694da2005-12-05 19:42:22 +01003553/* Clevo m520g init */
3554static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3555 /* headphone output */
3556 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3557 /* line-out */
3558 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3559 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3560 /* Line-in */
3561 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3562 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3563 /* CD */
3564 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3565 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3566 /* Mic1 (rear panel) */
3567 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3568 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3569 /* Mic2 (front panel) */
3570 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3571 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3572 /* headphone */
3573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3575 /* change to EAPD mode */
3576 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3577 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3578
3579 { }
3580};
3581
3582static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003583 /* change to EAPD mode */
3584 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3585 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3586
Kailang Yangdf694da2005-12-05 19:42:22 +01003587 /* Headphone output */
3588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3589 /* Front output*/
3590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3591 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3592
3593 /* Line In pin widget for input */
3594 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3595 /* CD pin widget for input */
3596 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3597 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3599
3600 /* change to EAPD mode */
3601 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3602 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3603
3604 { }
3605};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003606
3607/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003608 * LG m1 express dual
3609 *
3610 * Pin assignment:
3611 * Rear Line-In/Out (blue): 0x14
3612 * Build-in Mic-In: 0x15
3613 * Speaker-out: 0x17
3614 * HP-Out (green): 0x1b
3615 * Mic-In/Out (red): 0x19
3616 * SPDIF-Out: 0x1e
3617 */
3618
3619/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3620static hda_nid_t alc880_lg_dac_nids[3] = {
3621 0x05, 0x02, 0x03
3622};
3623
3624/* seems analog CD is not working */
3625static struct hda_input_mux alc880_lg_capture_source = {
3626 .num_items = 3,
3627 .items = {
3628 { "Mic", 0x1 },
3629 { "Line", 0x5 },
3630 { "Internal Mic", 0x6 },
3631 },
3632};
3633
3634/* 2,4,6 channel modes */
3635static struct hda_verb alc880_lg_ch2_init[] = {
3636 /* set line-in and mic-in to input */
3637 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3638 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3639 { }
3640};
3641
3642static struct hda_verb alc880_lg_ch4_init[] = {
3643 /* set line-in to out and mic-in to input */
3644 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3645 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3646 { }
3647};
3648
3649static struct hda_verb alc880_lg_ch6_init[] = {
3650 /* set line-in and mic-in to output */
3651 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3652 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3653 { }
3654};
3655
3656static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3657 { 2, alc880_lg_ch2_init },
3658 { 4, alc880_lg_ch4_init },
3659 { 6, alc880_lg_ch6_init },
3660};
3661
3662static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003663 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3664 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003665 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3666 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3667 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3668 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3669 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3670 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3672 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3673 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3674 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3675 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3676 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3677 {
3678 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3679 .name = "Channel Mode",
3680 .info = alc_ch_mode_info,
3681 .get = alc_ch_mode_get,
3682 .put = alc_ch_mode_put,
3683 },
3684 { } /* end */
3685};
3686
3687static struct hda_verb alc880_lg_init_verbs[] = {
3688 /* set capture source to mic-in */
3689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3690 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3691 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3692 /* mute all amp mixer inputs */
3693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003696 /* line-in to input */
3697 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3699 /* built-in mic */
3700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3701 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3702 /* speaker-out */
3703 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3705 /* mic-in to input */
3706 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3707 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3709 /* HP-out */
3710 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3711 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3712 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3713 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003714 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003715 { }
3716};
3717
3718/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003719static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003720{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003721 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003722
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003723 spec->autocfg.hp_pins[0] = 0x1b;
3724 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02003725 spec->automute = 1;
3726 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003727}
3728
3729/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003730 * LG LW20
3731 *
3732 * Pin assignment:
3733 * Speaker-out: 0x14
3734 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003735 * Built-in Mic-In: 0x19
3736 * Line-In: 0x1b
3737 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003738 * SPDIF-Out: 0x1e
3739 */
3740
Takashi Iwaid6815182006-03-23 16:06:23 +01003741static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003742 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003743 .items = {
3744 { "Mic", 0x0 },
3745 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003746 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003747 },
3748};
3749
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003750#define alc880_lg_lw_modes alc880_threestack_modes
3751
Takashi Iwaid6815182006-03-23 16:06:23 +01003752static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003753 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3754 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3755 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3756 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3757 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3758 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3759 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3760 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3761 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3762 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3765 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3766 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003767 {
3768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3769 .name = "Channel Mode",
3770 .info = alc_ch_mode_info,
3771 .get = alc_ch_mode_get,
3772 .put = alc_ch_mode_put,
3773 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003774 { } /* end */
3775};
3776
3777static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003778 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3779 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3780 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3781
Takashi Iwaid6815182006-03-23 16:06:23 +01003782 /* set capture source to mic-in */
3783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3785 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003786 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003787 /* speaker-out */
3788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3790 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003791 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3792 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3793 /* mic-in to input */
3794 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3796 /* built-in mic */
3797 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3798 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3799 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003800 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003801 { }
3802};
3803
3804/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003805static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003806{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003807 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003808
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003809 spec->autocfg.hp_pins[0] = 0x1b;
3810 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02003811 spec->automute = 1;
3812 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaid6815182006-03-23 16:06:23 +01003813}
3814
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003815static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3816 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3817 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3820 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3821 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3822 { } /* end */
3823};
3824
3825static struct hda_input_mux alc880_medion_rim_capture_source = {
3826 .num_items = 2,
3827 .items = {
3828 { "Mic", 0x0 },
3829 { "Internal Mic", 0x1 },
3830 },
3831};
3832
3833static struct hda_verb alc880_medion_rim_init_verbs[] = {
3834 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3835
3836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3837 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3838
3839 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3840 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3841 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3842 /* Mic2 (as headphone out) for HP output */
3843 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3844 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3845 /* Internal Speaker */
3846 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3847 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3848
3849 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3850 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3851
3852 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3853 { }
3854};
3855
3856/* toggle speaker-output according to the hp-jack state */
3857static void alc880_medion_rim_automute(struct hda_codec *codec)
3858{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003859 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02003860 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003861 /* toggle EAPD */
3862 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003863 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3864 else
3865 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3866}
3867
3868static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3869 unsigned int res)
3870{
3871 /* Looks like the unsol event is incompatible with the standard
3872 * definition. 4bit tag is placed at 28 bit!
3873 */
3874 if ((res >> 28) == ALC880_HP_EVENT)
3875 alc880_medion_rim_automute(codec);
3876}
3877
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003878static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003879{
3880 struct alc_spec *spec = codec->spec;
3881
3882 spec->autocfg.hp_pins[0] = 0x14;
3883 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02003884 spec->automute = 1;
3885 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003886}
3887
Takashi Iwaicb53c622007-08-10 17:21:45 +02003888#ifdef CONFIG_SND_HDA_POWER_SAVE
3889static struct hda_amp_list alc880_loopbacks[] = {
3890 { 0x0b, HDA_INPUT, 0 },
3891 { 0x0b, HDA_INPUT, 1 },
3892 { 0x0b, HDA_INPUT, 2 },
3893 { 0x0b, HDA_INPUT, 3 },
3894 { 0x0b, HDA_INPUT, 4 },
3895 { } /* end */
3896};
3897
3898static struct hda_amp_list alc880_lg_loopbacks[] = {
3899 { 0x0b, HDA_INPUT, 1 },
3900 { 0x0b, HDA_INPUT, 6 },
3901 { 0x0b, HDA_INPUT, 7 },
3902 { } /* end */
3903};
3904#endif
3905
Takashi Iwaid6815182006-03-23 16:06:23 +01003906/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003907 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003908 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003909
Takashi Iwai584c0c42011-03-10 12:51:11 +01003910static void alc_init_special_input_src(struct hda_codec *codec);
3911
Linus Torvalds1da177e2005-04-16 15:20:36 -07003912static int alc_init(struct hda_codec *codec)
3913{
3914 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003915 unsigned int i;
3916
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003917 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003918 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003919
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003920 for (i = 0; i < spec->num_init_verbs; i++)
3921 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwai584c0c42011-03-10 12:51:11 +01003922 alc_init_special_input_src(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003923
3924 if (spec->init_hook)
3925 spec->init_hook(codec);
3926
Takashi Iwai58701122011-01-13 15:41:45 +01003927 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
3928
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003929 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003930 return 0;
3931}
3932
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003933static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3934{
3935 struct alc_spec *spec = codec->spec;
3936
3937 if (spec->unsol_event)
3938 spec->unsol_event(codec, res);
3939}
3940
Takashi Iwaicb53c622007-08-10 17:21:45 +02003941#ifdef CONFIG_SND_HDA_POWER_SAVE
3942static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3943{
3944 struct alc_spec *spec = codec->spec;
3945 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3946}
3947#endif
3948
Linus Torvalds1da177e2005-04-16 15:20:36 -07003949/*
3950 * Analog playback callbacks
3951 */
3952static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3953 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003954 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003955{
3956 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003957 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3958 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003959}
3960
3961static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3962 struct hda_codec *codec,
3963 unsigned int stream_tag,
3964 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003965 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003966{
3967 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003968 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3969 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003970}
3971
3972static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3973 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003974 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003975{
3976 struct alc_spec *spec = codec->spec;
3977 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3978}
3979
3980/*
3981 * Digital out
3982 */
3983static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3984 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003985 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003986{
3987 struct alc_spec *spec = codec->spec;
3988 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3989}
3990
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003991static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3992 struct hda_codec *codec,
3993 unsigned int stream_tag,
3994 unsigned int format,
3995 struct snd_pcm_substream *substream)
3996{
3997 struct alc_spec *spec = codec->spec;
3998 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3999 stream_tag, format, substream);
4000}
4001
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004002static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4003 struct hda_codec *codec,
4004 struct snd_pcm_substream *substream)
4005{
4006 struct alc_spec *spec = codec->spec;
4007 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
4008}
4009
Linus Torvalds1da177e2005-04-16 15:20:36 -07004010static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
4011 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004012 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004013{
4014 struct alc_spec *spec = codec->spec;
4015 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
4016}
4017
4018/*
4019 * Analog capture
4020 */
Takashi Iwai63300792008-01-24 15:31:36 +01004021static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004022 struct hda_codec *codec,
4023 unsigned int stream_tag,
4024 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004025 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004026{
4027 struct alc_spec *spec = codec->spec;
4028
Takashi Iwai63300792008-01-24 15:31:36 +01004029 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07004030 stream_tag, 0, format);
4031 return 0;
4032}
4033
Takashi Iwai63300792008-01-24 15:31:36 +01004034static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004035 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004036 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004037{
4038 struct alc_spec *spec = codec->spec;
4039
Takashi Iwai888afa12008-03-18 09:57:50 +01004040 snd_hda_codec_cleanup_stream(codec,
4041 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004042 return 0;
4043}
4044
Takashi Iwai840b64c2010-07-13 22:49:01 +02004045/* analog capture with dynamic dual-adc changes */
4046static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
4047 struct hda_codec *codec,
4048 unsigned int stream_tag,
4049 unsigned int format,
4050 struct snd_pcm_substream *substream)
4051{
4052 struct alc_spec *spec = codec->spec;
4053 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
4054 spec->cur_adc_stream_tag = stream_tag;
4055 spec->cur_adc_format = format;
4056 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
4057 return 0;
4058}
4059
4060static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
4061 struct hda_codec *codec,
4062 struct snd_pcm_substream *substream)
4063{
4064 struct alc_spec *spec = codec->spec;
4065 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4066 spec->cur_adc = 0;
4067 return 0;
4068}
4069
4070static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4071 .substreams = 1,
4072 .channels_min = 2,
4073 .channels_max = 2,
4074 .nid = 0, /* fill later */
4075 .ops = {
4076 .prepare = dualmic_capture_pcm_prepare,
4077 .cleanup = dualmic_capture_pcm_cleanup
4078 },
4079};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004080
4081/*
4082 */
4083static struct hda_pcm_stream alc880_pcm_analog_playback = {
4084 .substreams = 1,
4085 .channels_min = 2,
4086 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004087 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004088 .ops = {
4089 .open = alc880_playback_pcm_open,
4090 .prepare = alc880_playback_pcm_prepare,
4091 .cleanup = alc880_playback_pcm_cleanup
4092 },
4093};
4094
4095static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004096 .substreams = 1,
4097 .channels_min = 2,
4098 .channels_max = 2,
4099 /* NID is set in alc_build_pcms */
4100};
4101
4102static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4103 .substreams = 1,
4104 .channels_min = 2,
4105 .channels_max = 2,
4106 /* NID is set in alc_build_pcms */
4107};
4108
4109static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4110 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004111 .channels_min = 2,
4112 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004113 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004114 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004115 .prepare = alc880_alt_capture_pcm_prepare,
4116 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004117 },
4118};
4119
4120static struct hda_pcm_stream alc880_pcm_digital_playback = {
4121 .substreams = 1,
4122 .channels_min = 2,
4123 .channels_max = 2,
4124 /* NID is set in alc_build_pcms */
4125 .ops = {
4126 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004127 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004128 .prepare = alc880_dig_playback_pcm_prepare,
4129 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004130 },
4131};
4132
4133static struct hda_pcm_stream alc880_pcm_digital_capture = {
4134 .substreams = 1,
4135 .channels_min = 2,
4136 .channels_max = 2,
4137 /* NID is set in alc_build_pcms */
4138};
4139
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004140/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004141static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004142 .substreams = 0,
4143 .channels_min = 0,
4144 .channels_max = 0,
4145};
4146
Linus Torvalds1da177e2005-04-16 15:20:36 -07004147static int alc_build_pcms(struct hda_codec *codec)
4148{
4149 struct alc_spec *spec = codec->spec;
4150 struct hda_pcm *info = spec->pcm_rec;
4151 int i;
4152
4153 codec->num_pcms = 1;
4154 codec->pcm_info = info;
4155
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004156 if (spec->no_analog)
4157 goto skip_analog;
4158
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004159 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4160 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004161 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004162
Takashi Iwai4a471b72005-12-07 13:56:29 +01004163 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004164 if (snd_BUG_ON(!spec->multiout.dac_nids))
4165 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004166 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4167 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4168 }
4169 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004170 if (snd_BUG_ON(!spec->adc_nids))
4171 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004172 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4173 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4174 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004175
Takashi Iwai4a471b72005-12-07 13:56:29 +01004176 if (spec->channel_mode) {
4177 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4178 for (i = 0; i < spec->num_channel_mode; i++) {
4179 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4180 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4181 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004182 }
4183 }
4184
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004185 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004186 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004187 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004188 snprintf(spec->stream_name_digital,
4189 sizeof(spec->stream_name_digital),
4190 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004191 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004192 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004193 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004194 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004195 if (spec->dig_out_type)
4196 info->pcm_type = spec->dig_out_type;
4197 else
4198 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004199 if (spec->multiout.dig_out_nid &&
4200 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004201 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4202 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4203 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004204 if (spec->dig_in_nid &&
4205 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004206 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4207 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4208 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004209 /* FIXME: do we need this for all Realtek codec models? */
4210 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004211 }
4212
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004213 if (spec->no_analog)
4214 return 0;
4215
Takashi Iwaie08a0072006-09-07 17:52:14 +02004216 /* If the use of more than one ADC is requested for the current
4217 * model, configure a second analog capture-only PCM.
4218 */
4219 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004220 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4221 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004222 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004223 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004224 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004225 if (spec->alt_dac_nid) {
4226 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4227 *spec->stream_analog_alt_playback;
4228 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4229 spec->alt_dac_nid;
4230 } else {
4231 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4232 alc_pcm_null_stream;
4233 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4234 }
4235 if (spec->num_adc_nids > 1) {
4236 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4237 *spec->stream_analog_alt_capture;
4238 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4239 spec->adc_nids[1];
4240 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4241 spec->num_adc_nids - 1;
4242 } else {
4243 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4244 alc_pcm_null_stream;
4245 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004246 }
4247 }
4248
Linus Torvalds1da177e2005-04-16 15:20:36 -07004249 return 0;
4250}
4251
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004252static inline void alc_shutup(struct hda_codec *codec)
4253{
Takashi Iwai1c7161532011-04-07 10:37:16 +02004254 struct alc_spec *spec = codec->spec;
4255
4256 if (spec && spec->shutup)
4257 spec->shutup(codec);
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004258 snd_hda_shutup_pins(codec);
4259}
4260
Takashi Iwai603c4012008-07-30 15:01:44 +02004261static void alc_free_kctls(struct hda_codec *codec)
4262{
4263 struct alc_spec *spec = codec->spec;
4264
4265 if (spec->kctls.list) {
4266 struct snd_kcontrol_new *kctl = spec->kctls.list;
4267 int i;
4268 for (i = 0; i < spec->kctls.used; i++)
4269 kfree(kctl[i].name);
4270 }
4271 snd_array_free(&spec->kctls);
4272}
4273
Linus Torvalds1da177e2005-04-16 15:20:36 -07004274static void alc_free(struct hda_codec *codec)
4275{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004276 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004277
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004278 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279 return;
4280
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004281 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004282 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004283 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004284 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004285 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004286}
4287
Hector Martinf5de24b2009-12-20 22:51:31 +01004288#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004289static void alc_power_eapd(struct hda_codec *codec)
4290{
Takashi Iwai691f1fc2011-04-07 10:31:43 +02004291 alc_auto_setup_eapd(codec, false);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004292}
4293
Hector Martinf5de24b2009-12-20 22:51:31 +01004294static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4295{
4296 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004297 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004298 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004299 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004300 return 0;
4301}
4302#endif
4303
Takashi Iwaie044c392008-10-27 16:56:24 +01004304#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004305static int alc_resume(struct hda_codec *codec)
4306{
Takashi Iwai1c7161532011-04-07 10:37:16 +02004307 msleep(150); /* to avoid pop noise */
Takashi Iwaie044c392008-10-27 16:56:24 +01004308 codec->patch_ops.init(codec);
4309 snd_hda_codec_resume_amp(codec);
4310 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004311 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004312 return 0;
4313}
Takashi Iwaie044c392008-10-27 16:56:24 +01004314#endif
4315
Linus Torvalds1da177e2005-04-16 15:20:36 -07004316/*
4317 */
4318static struct hda_codec_ops alc_patch_ops = {
4319 .build_controls = alc_build_controls,
4320 .build_pcms = alc_build_pcms,
4321 .init = alc_init,
4322 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004323 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004324#ifdef SND_HDA_NEEDS_RESUME
4325 .resume = alc_resume,
4326#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004327#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004328 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004329 .check_power_status = alc_check_power_status,
4330#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004331 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004332};
4333
Kailang Yangc027ddc2010-03-19 11:33:06 +01004334/* replace the codec chip_name with the given string */
4335static int alc_codec_rename(struct hda_codec *codec, const char *name)
4336{
4337 kfree(codec->chip_name);
4338 codec->chip_name = kstrdup(name, GFP_KERNEL);
4339 if (!codec->chip_name) {
4340 alc_free(codec);
4341 return -ENOMEM;
4342 }
4343 return 0;
4344}
4345
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004346/*
4347 * Test configuration for debugging
4348 *
4349 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4350 * enum controls.
4351 */
4352#ifdef CONFIG_SND_DEBUG
4353static hda_nid_t alc880_test_dac_nids[4] = {
4354 0x02, 0x03, 0x04, 0x05
4355};
4356
4357static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004358 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004359 .items = {
4360 { "In-1", 0x0 },
4361 { "In-2", 0x1 },
4362 { "In-3", 0x2 },
4363 { "In-4", 0x3 },
4364 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004365 { "Front", 0x5 },
4366 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004367 },
4368};
4369
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004370static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004371 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004372 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004373 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004374 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004375};
4376
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004377static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4378 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004379{
4380 static char *texts[] = {
4381 "N/A", "Line Out", "HP Out",
4382 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4383 };
4384 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4385 uinfo->count = 1;
4386 uinfo->value.enumerated.items = 8;
4387 if (uinfo->value.enumerated.item >= 8)
4388 uinfo->value.enumerated.item = 7;
4389 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4390 return 0;
4391}
4392
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004393static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4394 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004395{
4396 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4397 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4398 unsigned int pin_ctl, item = 0;
4399
4400 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4401 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4402 if (pin_ctl & AC_PINCTL_OUT_EN) {
4403 if (pin_ctl & AC_PINCTL_HP_EN)
4404 item = 2;
4405 else
4406 item = 1;
4407 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4408 switch (pin_ctl & AC_PINCTL_VREFEN) {
4409 case AC_PINCTL_VREF_HIZ: item = 3; break;
4410 case AC_PINCTL_VREF_50: item = 4; break;
4411 case AC_PINCTL_VREF_GRD: item = 5; break;
4412 case AC_PINCTL_VREF_80: item = 6; break;
4413 case AC_PINCTL_VREF_100: item = 7; break;
4414 }
4415 }
4416 ucontrol->value.enumerated.item[0] = item;
4417 return 0;
4418}
4419
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004420static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4421 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004422{
4423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4424 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4425 static unsigned int ctls[] = {
4426 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4427 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4428 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4429 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4430 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4431 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4432 };
4433 unsigned int old_ctl, new_ctl;
4434
4435 old_ctl = snd_hda_codec_read(codec, nid, 0,
4436 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4437 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4438 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004439 int val;
4440 snd_hda_codec_write_cache(codec, nid, 0,
4441 AC_VERB_SET_PIN_WIDGET_CONTROL,
4442 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004443 val = ucontrol->value.enumerated.item[0] >= 3 ?
4444 HDA_AMP_MUTE : 0;
4445 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4446 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004447 return 1;
4448 }
4449 return 0;
4450}
4451
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004452static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4453 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004454{
4455 static char *texts[] = {
4456 "Front", "Surround", "CLFE", "Side"
4457 };
4458 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4459 uinfo->count = 1;
4460 uinfo->value.enumerated.items = 4;
4461 if (uinfo->value.enumerated.item >= 4)
4462 uinfo->value.enumerated.item = 3;
4463 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4464 return 0;
4465}
4466
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004467static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4468 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004469{
4470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4471 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4472 unsigned int sel;
4473
4474 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4475 ucontrol->value.enumerated.item[0] = sel & 3;
4476 return 0;
4477}
4478
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004479static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4480 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004481{
4482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4483 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4484 unsigned int sel;
4485
4486 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4487 if (ucontrol->value.enumerated.item[0] != sel) {
4488 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004489 snd_hda_codec_write_cache(codec, nid, 0,
4490 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004491 return 1;
4492 }
4493 return 0;
4494}
4495
4496#define PIN_CTL_TEST(xname,nid) { \
4497 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4498 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004499 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004500 .info = alc_test_pin_ctl_info, \
4501 .get = alc_test_pin_ctl_get, \
4502 .put = alc_test_pin_ctl_put, \
4503 .private_value = nid \
4504 }
4505
4506#define PIN_SRC_TEST(xname,nid) { \
4507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4508 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004509 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004510 .info = alc_test_pin_src_info, \
4511 .get = alc_test_pin_src_get, \
4512 .put = alc_test_pin_src_put, \
4513 .private_value = nid \
4514 }
4515
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004516static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004517 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4518 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4519 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4520 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004521 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4522 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4523 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4524 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004525 PIN_CTL_TEST("Front Pin Mode", 0x14),
4526 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4527 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4528 PIN_CTL_TEST("Side Pin Mode", 0x17),
4529 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4530 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4531 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4532 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4533 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4534 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4535 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4536 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4537 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4538 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4539 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4540 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4541 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4542 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4543 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4544 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4545 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4546 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004547 {
4548 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4549 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004550 .info = alc_ch_mode_info,
4551 .get = alc_ch_mode_get,
4552 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004553 },
4554 { } /* end */
4555};
4556
4557static struct hda_verb alc880_test_init_verbs[] = {
4558 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4562 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4563 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4564 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4565 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4566 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004567 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004568 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4569 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4571 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004572 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4574 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4575 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4576 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004577 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004578 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4580 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4581 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004582 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004583 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4584 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004585 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4586 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4587 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004588 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004589 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4590 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4591 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4592 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004593 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004595 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004596 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004597 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004599 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004600 /* Analog input/passthru */
4601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4605 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004606 { }
4607};
4608#endif
4609
Linus Torvalds1da177e2005-04-16 15:20:36 -07004610/*
4611 */
4612
Takashi Iwaiea734962011-01-17 11:29:34 +01004613static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004614 [ALC880_3ST] = "3stack",
4615 [ALC880_TCL_S700] = "tcl",
4616 [ALC880_3ST_DIG] = "3stack-digout",
4617 [ALC880_CLEVO] = "clevo",
4618 [ALC880_5ST] = "5stack",
4619 [ALC880_5ST_DIG] = "5stack-digout",
4620 [ALC880_W810] = "w810",
4621 [ALC880_Z71V] = "z71v",
4622 [ALC880_6ST] = "6stack",
4623 [ALC880_6ST_DIG] = "6stack-digout",
4624 [ALC880_ASUS] = "asus",
4625 [ALC880_ASUS_W1V] = "asus-w1v",
4626 [ALC880_ASUS_DIG] = "asus-dig",
4627 [ALC880_ASUS_DIG2] = "asus-dig2",
4628 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004629 [ALC880_UNIWILL_P53] = "uniwill-p53",
4630 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004631 [ALC880_F1734] = "F1734",
4632 [ALC880_LG] = "lg",
4633 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004634 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004635#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004636 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004637#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004638 [ALC880_AUTO] = "auto",
4639};
4640
4641static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004642 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004643 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4644 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4645 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4646 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4647 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4648 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4649 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4650 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004651 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4652 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004653 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4654 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4655 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4656 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4657 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4658 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4659 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4660 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4661 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4662 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004663 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004664 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4665 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4666 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004667 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004668 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004669 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4670 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004671 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4672 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004673 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4674 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4675 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4676 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004677 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4678 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004679 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004680 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004681 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Justin P. Mattocka2e2bc22011-02-24 22:16:02 -08004682 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004683 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4684 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004685 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004686 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004687 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004688 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004689 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004690 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004691 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004692 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004693 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004694 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004695 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004696 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004697 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004698 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4699 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4700 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4701 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004702 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4703 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004704 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004705 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004706 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4707 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004708 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4709 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4710 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004711 /* default Intel */
4712 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004713 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4714 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004715 {}
4716};
4717
Takashi Iwai16ded522005-06-10 19:58:24 +02004718/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004719 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004720 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004721static struct alc_config_preset alc880_presets[] = {
4722 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004723 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004724 .init_verbs = { alc880_volume_init_verbs,
4725 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004726 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004727 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004728 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4729 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004730 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004731 .input_mux = &alc880_capture_source,
4732 },
4733 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004734 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004735 .init_verbs = { alc880_volume_init_verbs,
4736 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004737 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004738 .dac_nids = alc880_dac_nids,
4739 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004740 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4741 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004742 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004743 .input_mux = &alc880_capture_source,
4744 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004745 [ALC880_TCL_S700] = {
4746 .mixers = { alc880_tcl_s700_mixer },
4747 .init_verbs = { alc880_volume_init_verbs,
4748 alc880_pin_tcl_S700_init_verbs,
4749 alc880_gpio2_init_verbs },
4750 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4751 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004752 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4753 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004754 .hp_nid = 0x03,
4755 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4756 .channel_mode = alc880_2_jack_modes,
4757 .input_mux = &alc880_capture_source,
4758 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004759 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004760 .mixers = { alc880_three_stack_mixer,
4761 alc880_five_stack_mixer},
4762 .init_verbs = { alc880_volume_init_verbs,
4763 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004764 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4765 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004766 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4767 .channel_mode = alc880_fivestack_modes,
4768 .input_mux = &alc880_capture_source,
4769 },
4770 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004771 .mixers = { alc880_three_stack_mixer,
4772 alc880_five_stack_mixer },
4773 .init_verbs = { alc880_volume_init_verbs,
4774 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004775 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4776 .dac_nids = alc880_dac_nids,
4777 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004778 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4779 .channel_mode = alc880_fivestack_modes,
4780 .input_mux = &alc880_capture_source,
4781 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004782 [ALC880_6ST] = {
4783 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004784 .init_verbs = { alc880_volume_init_verbs,
4785 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004786 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4787 .dac_nids = alc880_6st_dac_nids,
4788 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4789 .channel_mode = alc880_sixstack_modes,
4790 .input_mux = &alc880_6stack_capture_source,
4791 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004792 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004793 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004794 .init_verbs = { alc880_volume_init_verbs,
4795 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004796 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4797 .dac_nids = alc880_6st_dac_nids,
4798 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004799 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4800 .channel_mode = alc880_sixstack_modes,
4801 .input_mux = &alc880_6stack_capture_source,
4802 },
4803 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004804 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004805 .init_verbs = { alc880_volume_init_verbs,
4806 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004807 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004808 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4809 .dac_nids = alc880_w810_dac_nids,
4810 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004811 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4812 .channel_mode = alc880_w810_modes,
4813 .input_mux = &alc880_capture_source,
4814 },
4815 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004817 .init_verbs = { alc880_volume_init_verbs,
4818 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004819 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4820 .dac_nids = alc880_z71v_dac_nids,
4821 .dig_out_nid = ALC880_DIGOUT_NID,
4822 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004823 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4824 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004825 .input_mux = &alc880_capture_source,
4826 },
4827 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004828 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004829 .init_verbs = { alc880_volume_init_verbs,
4830 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004831 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4832 .dac_nids = alc880_f1734_dac_nids,
4833 .hp_nid = 0x02,
4834 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4835 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004836 .input_mux = &alc880_f1734_capture_source,
4837 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004838 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02004839 .init_hook = alc_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02004840 },
4841 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004842 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004843 .init_verbs = { alc880_volume_init_verbs,
4844 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845 alc880_gpio1_init_verbs },
4846 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4847 .dac_nids = alc880_asus_dac_nids,
4848 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4849 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004850 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004851 .input_mux = &alc880_capture_source,
4852 },
4853 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004855 .init_verbs = { alc880_volume_init_verbs,
4856 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004857 alc880_gpio1_init_verbs },
4858 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4859 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004860 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004861 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4862 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004863 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004864 .input_mux = &alc880_capture_source,
4865 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004866 [ALC880_ASUS_DIG2] = {
4867 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004868 .init_verbs = { alc880_volume_init_verbs,
4869 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004870 alc880_gpio2_init_verbs }, /* use GPIO2 */
4871 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4872 .dac_nids = alc880_asus_dac_nids,
4873 .dig_out_nid = ALC880_DIGOUT_NID,
4874 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4875 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004876 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004877 .input_mux = &alc880_capture_source,
4878 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004879 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004880 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004881 .init_verbs = { alc880_volume_init_verbs,
4882 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004883 alc880_gpio1_init_verbs },
4884 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4885 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004886 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004887 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4888 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004889 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004890 .input_mux = &alc880_capture_source,
4891 },
4892 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004893 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004894 .init_verbs = { alc880_volume_init_verbs,
4895 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004896 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4897 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004898 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004899 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4900 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004901 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004902 .input_mux = &alc880_capture_source,
4903 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004904 [ALC880_UNIWILL] = {
4905 .mixers = { alc880_uniwill_mixer },
4906 .init_verbs = { alc880_volume_init_verbs,
4907 alc880_uniwill_init_verbs },
4908 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4909 .dac_nids = alc880_asus_dac_nids,
4910 .dig_out_nid = ALC880_DIGOUT_NID,
4911 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4912 .channel_mode = alc880_threestack_modes,
4913 .need_dac_fix = 1,
4914 .input_mux = &alc880_capture_source,
4915 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004916 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004917 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004918 },
4919 [ALC880_UNIWILL_P53] = {
4920 .mixers = { alc880_uniwill_p53_mixer },
4921 .init_verbs = { alc880_volume_init_verbs,
4922 alc880_uniwill_p53_init_verbs },
4923 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4924 .dac_nids = alc880_asus_dac_nids,
4925 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004926 .channel_mode = alc880_threestack_modes,
4927 .input_mux = &alc880_capture_source,
4928 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004929 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02004930 .init_hook = alc_hp_automute,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004931 },
4932 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004933 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004934 .init_verbs = { alc880_volume_init_verbs,
4935 alc880_uniwill_p53_init_verbs,
4936 alc880_beep_init_verbs },
4937 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4938 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004939 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004940 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4941 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004942 .input_mux = &alc880_capture_source,
4943 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004944 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02004945 .init_hook = alc_hp_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02004946 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004947 [ALC880_CLEVO] = {
4948 .mixers = { alc880_three_stack_mixer },
4949 .init_verbs = { alc880_volume_init_verbs,
4950 alc880_pin_clevo_init_verbs },
4951 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4952 .dac_nids = alc880_dac_nids,
4953 .hp_nid = 0x03,
4954 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4955 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004956 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004957 .input_mux = &alc880_capture_source,
4958 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004959 [ALC880_LG] = {
4960 .mixers = { alc880_lg_mixer },
4961 .init_verbs = { alc880_volume_init_verbs,
4962 alc880_lg_init_verbs },
4963 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4964 .dac_nids = alc880_lg_dac_nids,
4965 .dig_out_nid = ALC880_DIGOUT_NID,
4966 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4967 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004968 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004969 .input_mux = &alc880_lg_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02004970 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004971 .setup = alc880_lg_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02004972 .init_hook = alc_hp_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004973#ifdef CONFIG_SND_HDA_POWER_SAVE
4974 .loopbacks = alc880_lg_loopbacks,
4975#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004976 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004977 [ALC880_LG_LW] = {
4978 .mixers = { alc880_lg_lw_mixer },
4979 .init_verbs = { alc880_volume_init_verbs,
4980 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004981 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004982 .dac_nids = alc880_dac_nids,
4983 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004984 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4985 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004986 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02004987 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004988 .setup = alc880_lg_lw_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02004989 .init_hook = alc_hp_automute,
Takashi Iwaid6815182006-03-23 16:06:23 +01004990 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004991 [ALC880_MEDION_RIM] = {
4992 .mixers = { alc880_medion_rim_mixer },
4993 .init_verbs = { alc880_volume_init_verbs,
4994 alc880_medion_rim_init_verbs,
4995 alc_gpio2_init_verbs },
4996 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4997 .dac_nids = alc880_dac_nids,
4998 .dig_out_nid = ALC880_DIGOUT_NID,
4999 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5000 .channel_mode = alc880_2_jack_modes,
5001 .input_mux = &alc880_medion_rim_capture_source,
5002 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005003 .setup = alc880_medion_rim_setup,
5004 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005005 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005006#ifdef CONFIG_SND_DEBUG
5007 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005008 .mixers = { alc880_test_mixer },
5009 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005010 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
5011 .dac_nids = alc880_test_dac_nids,
5012 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005013 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
5014 .channel_mode = alc880_test_modes,
5015 .input_mux = &alc880_test_capture_source,
5016 },
5017#endif
5018};
5019
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005020/*
5021 * Automatic parse of I/O pins from the BIOS configuration
5022 */
5023
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005024enum {
5025 ALC_CTL_WIDGET_VOL,
5026 ALC_CTL_WIDGET_MUTE,
5027 ALC_CTL_BIND_MUTE,
5028};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005029static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005030 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
5031 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01005032 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005033};
5034
Takashi Iwaice764ab2011-04-27 16:35:23 +02005035static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
5036{
5037 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
5038 return snd_array_new(&spec->kctls);
5039}
5040
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005041/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005042static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005043 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005044{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005045 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005046
Takashi Iwaice764ab2011-04-27 16:35:23 +02005047 knew = alc_kcontrol_new(spec);
Takashi Iwai603c4012008-07-30 15:01:44 +02005048 if (!knew)
5049 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005050 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07005051 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005052 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005054 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005055 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005056 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005057 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005058 return 0;
5059}
5060
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005061static int add_control_with_pfx(struct alc_spec *spec, int type,
5062 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005063 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005064{
5065 char name[32];
5066 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005067 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005068}
5069
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005070#define add_pb_vol_ctrl(spec, type, pfx, val) \
5071 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5072#define add_pb_sw_ctrl(spec, type, pfx, val) \
5073 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5074#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5075 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5076#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5077 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005078
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005079#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5080#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5081#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5082#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005083#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5084#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5085#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5086#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5087#define ALC880_PIN_CD_NID 0x1c
5088
5089/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005090static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5091 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005092{
5093 hda_nid_t nid;
5094 int assigned[4];
5095 int i, j;
5096
5097 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005098 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005099
5100 /* check the pins hardwired to audio widget */
5101 for (i = 0; i < cfg->line_outs; i++) {
5102 nid = cfg->line_out_pins[i];
5103 if (alc880_is_fixed_pin(nid)) {
5104 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005105 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005106 assigned[idx] = 1;
5107 }
5108 }
5109 /* left pins can be connect to any audio widget */
5110 for (i = 0; i < cfg->line_outs; i++) {
5111 nid = cfg->line_out_pins[i];
5112 if (alc880_is_fixed_pin(nid))
5113 continue;
5114 /* search for an empty channel */
5115 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005116 if (!assigned[j]) {
5117 spec->multiout.dac_nids[i] =
5118 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005119 assigned[j] = 1;
5120 break;
5121 }
5122 }
5123 }
5124 spec->multiout.num_dacs = cfg->line_outs;
5125 return 0;
5126}
5127
Takashi Iwaice764ab2011-04-27 16:35:23 +02005128static const char *alc_get_line_out_pfx(struct alc_spec *spec,
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005129 bool can_be_master)
5130{
Takashi Iwaice764ab2011-04-27 16:35:23 +02005131 struct auto_pin_cfg *cfg = &spec->autocfg;
5132
5133 if (cfg->line_outs == 1 && !spec->multi_ios &&
5134 !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005135 return "Master";
5136
5137 switch (cfg->line_out_type) {
5138 case AUTO_PIN_SPEAKER_OUT:
David Henningssonebbeb3d2011-03-04 14:08:30 +01005139 if (cfg->line_outs == 1)
5140 return "Speaker";
5141 break;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005142 case AUTO_PIN_HP_OUT:
5143 return "Headphone";
5144 default:
Takashi Iwaice764ab2011-04-27 16:35:23 +02005145 if (cfg->line_outs == 1 && !spec->multi_ios)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005146 return "PCM";
5147 break;
5148 }
5149 return NULL;
5150}
5151
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005152/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005153static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5154 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005155{
Takashi Iwaiea734962011-01-17 11:29:34 +01005156 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005157 "Front", "Surround", NULL /*CLFE*/, "Side"
5158 };
Takashi Iwaice764ab2011-04-27 16:35:23 +02005159 const char *pfx = alc_get_line_out_pfx(spec, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005160 hda_nid_t nid;
Takashi Iwaice764ab2011-04-27 16:35:23 +02005161 int i, err, noutputs;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005162
Takashi Iwaice764ab2011-04-27 16:35:23 +02005163 noutputs = cfg->line_outs;
5164 if (spec->multi_ios > 0)
5165 noutputs += spec->multi_ios;
5166
5167 for (i = 0; i < noutputs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005168 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005169 continue;
5170 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005171 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005172 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005173 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5174 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005175 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5176 HDA_OUTPUT));
5177 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005178 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005179 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5180 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005181 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5182 HDA_OUTPUT));
5183 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005184 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005185 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5186 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005187 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5188 HDA_INPUT));
5189 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005190 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005191 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5192 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005193 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5194 HDA_INPUT));
5195 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005196 return err;
5197 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005198 const char *name = pfx;
David Henningsson7e59e092011-03-04 14:22:25 +01005199 int index = i;
5200 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005201 name = chname[i];
David Henningsson7e59e092011-03-04 14:22:25 +01005202 index = 0;
5203 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005204 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson7e59e092011-03-04 14:22:25 +01005205 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005206 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5207 HDA_OUTPUT));
5208 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005209 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005210 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson7e59e092011-03-04 14:22:25 +01005211 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005212 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5213 HDA_INPUT));
5214 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005215 return err;
5216 }
5217 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005218 return 0;
5219}
5220
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005221/* add playback controls for speaker and HP outputs */
5222static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5223 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005224{
5225 hda_nid_t nid;
5226 int err;
5227
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005228 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005229 return 0;
5230
5231 if (alc880_is_fixed_pin(pin)) {
5232 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005233 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005234 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005235 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005236 else
5237 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005238 /* control HP volume/switch on the output mixer amp */
5239 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005240 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005241 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5242 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005243 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005244 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005245 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5246 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005247 return err;
5248 } else if (alc880_is_multi_pin(pin)) {
5249 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005250 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005251 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005252 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5253 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005254 return err;
5255 }
5256 return 0;
5257}
5258
5259/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005260static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005261 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005262 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005263{
Kailang Yangdf694da2005-12-05 19:42:22 +01005264 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005265
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005266 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005267 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5268 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005269 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005270 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005271 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5272 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005273 return err;
5274 return 0;
5275}
5276
Takashi Iwai05f5f472009-08-25 13:10:18 +02005277static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005278{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005279 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5280 return (pincap & AC_PINCAP_IN) != 0;
5281}
5282
5283/* create playback/capture controls for input pins */
5284static int alc_auto_create_input_ctls(struct hda_codec *codec,
5285 const struct auto_pin_cfg *cfg,
5286 hda_nid_t mixer,
5287 hda_nid_t cap1, hda_nid_t cap2)
5288{
5289 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005290 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005291 int i, err, idx, type_idx = 0;
5292 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005293
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005294 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005295 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005296 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005297
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005298 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005299 if (!alc_is_input_pin(codec, pin))
5300 continue;
5301
David Henningsson5322bf22011-01-05 11:03:56 +01005302 label = hda_get_autocfg_input_label(codec, cfg, i);
5303 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005304 type_idx++;
5305 else
5306 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005307 prev_label = label;
5308
Takashi Iwai05f5f472009-08-25 13:10:18 +02005309 if (mixer) {
5310 idx = get_connection_index(codec, mixer, pin);
5311 if (idx >= 0) {
5312 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005313 label, type_idx,
5314 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005315 if (err < 0)
5316 return err;
5317 }
5318 }
5319
5320 if (!cap1)
5321 continue;
5322 idx = get_connection_index(codec, cap1, pin);
5323 if (idx < 0 && cap2)
5324 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005325 if (idx >= 0)
5326 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005327 }
5328 return 0;
5329}
5330
Takashi Iwai05f5f472009-08-25 13:10:18 +02005331static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5332 const struct auto_pin_cfg *cfg)
5333{
5334 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5335}
5336
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005337static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5338 unsigned int pin_type)
5339{
5340 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5341 pin_type);
5342 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005343 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5344 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005345}
5346
Kailang Yangdf694da2005-12-05 19:42:22 +01005347static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5348 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005349 int dac_idx)
5350{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005351 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005352 /* need the manual connection? */
5353 if (alc880_is_multi_pin(nid)) {
5354 struct alc_spec *spec = codec->spec;
5355 int idx = alc880_multi_pin_idx(nid);
5356 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5357 AC_VERB_SET_CONNECT_SEL,
5358 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5359 }
5360}
5361
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005362static int get_pin_type(int line_out_type)
5363{
5364 if (line_out_type == AUTO_PIN_HP_OUT)
5365 return PIN_HP;
5366 else
5367 return PIN_OUT;
5368}
5369
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005370static void alc880_auto_init_multi_out(struct hda_codec *codec)
5371{
5372 struct alc_spec *spec = codec->spec;
5373 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005374
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005375 for (i = 0; i < spec->autocfg.line_outs; i++) {
5376 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005377 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5378 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005379 }
5380}
5381
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005382static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005383{
5384 struct alc_spec *spec = codec->spec;
5385 hda_nid_t pin;
5386
Takashi Iwai82bc9552006-03-21 11:24:42 +01005387 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005388 if (pin) /* connect to front */
5389 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005390 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005391 if (pin) /* connect to front */
5392 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5393}
5394
5395static void alc880_auto_init_analog_input(struct hda_codec *codec)
5396{
5397 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005398 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005399 int i;
5400
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005401 for (i = 0; i < cfg->num_inputs; i++) {
5402 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005403 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005404 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005405 if (nid != ALC880_PIN_CD_NID &&
5406 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005407 snd_hda_codec_write(codec, nid, 0,
5408 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005409 AMP_OUT_MUTE);
5410 }
5411 }
5412}
5413
Takashi Iwai7f311a42010-04-09 17:32:23 +02005414static void alc880_auto_init_input_src(struct hda_codec *codec)
5415{
5416 struct alc_spec *spec = codec->spec;
5417 int c;
5418
5419 for (c = 0; c < spec->num_adc_nids; c++) {
5420 unsigned int mux_idx;
5421 const struct hda_input_mux *imux;
5422 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5423 imux = &spec->input_mux[mux_idx];
5424 if (!imux->num_items && mux_idx > 0)
5425 imux = &spec->input_mux[0];
5426 if (imux)
5427 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5428 AC_VERB_SET_CONNECT_SEL,
5429 imux->items[0].index);
5430 }
5431}
5432
Takashi Iwaice764ab2011-04-27 16:35:23 +02005433static int alc_auto_add_multi_channel_mode(struct hda_codec *codec);
5434
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005435/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005436/* return 1 if successful, 0 if the proper config is not found,
5437 * or a negative error code
5438 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005439static int alc880_parse_auto_config(struct hda_codec *codec)
5440{
5441 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005442 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005443 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005444
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005445 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5446 alc880_ignore);
5447 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005448 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005449 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005450 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005451
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005452 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5453 if (err < 0)
5454 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +02005455 err = alc_auto_add_multi_channel_mode(codec);
5456 if (err < 0)
5457 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005458 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5459 if (err < 0)
5460 return err;
5461 err = alc880_auto_create_extra_out(spec,
5462 spec->autocfg.speaker_pins[0],
5463 "Speaker");
5464 if (err < 0)
5465 return err;
5466 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5467 "Headphone");
5468 if (err < 0)
5469 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005470 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005471 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005472 return err;
5473
5474 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5475
Takashi Iwai757899a2010-07-30 10:48:14 +02005476 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005477
Takashi Iwai603c4012008-07-30 15:01:44 +02005478 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005479 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005480
Takashi Iwaid88897e2008-10-31 15:01:37 +01005481 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005482
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005483 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005484 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005485
Kailang Yang6227cdc2010-02-25 08:36:52 +01005486 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005487
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005488 return 1;
5489}
5490
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005491/* additional initialization for auto-configuration model */
5492static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005493{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005494 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005495 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005496 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005497 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005498 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005499 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005500 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005501 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005502}
5503
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005504/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5505 * one of two digital mic pins, e.g. on ALC272
5506 */
5507static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005508{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005509 struct alc_spec *spec = codec->spec;
5510 int i;
5511
5512 for (i = 0; i < spec->num_adc_nids; i++) {
5513 hda_nid_t cap = spec->capsrc_nids ?
5514 spec->capsrc_nids[i] : spec->adc_nids[i];
5515 int iidx, eidx;
5516
5517 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5518 if (iidx < 0)
5519 continue;
5520 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5521 if (eidx < 0)
5522 continue;
5523 spec->int_mic.mux_idx = iidx;
5524 spec->ext_mic.mux_idx = eidx;
5525 if (spec->capsrc_nids)
5526 spec->capsrc_nids += i;
5527 spec->adc_nids += i;
5528 spec->num_adc_nids = 1;
5529 return;
5530 }
5531 snd_printd(KERN_INFO "hda_codec: %s: "
5532 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5533 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5534 spec->auto_mic = 0; /* disable auto-mic to be sure */
5535}
5536
Takashi Iwai748cce42010-08-04 07:37:39 +02005537/* select or unmute the given capsrc route */
5538static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5539 int idx)
5540{
5541 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5542 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5543 HDA_AMP_MUTE, 0);
5544 } else {
5545 snd_hda_codec_write_cache(codec, cap, 0,
5546 AC_VERB_SET_CONNECT_SEL, idx);
5547 }
5548}
5549
Takashi Iwai840b64c2010-07-13 22:49:01 +02005550/* set the default connection to that pin */
5551static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5552{
5553 struct alc_spec *spec = codec->spec;
5554 int i;
5555
5556 for (i = 0; i < spec->num_adc_nids; i++) {
5557 hda_nid_t cap = spec->capsrc_nids ?
5558 spec->capsrc_nids[i] : spec->adc_nids[i];
5559 int idx;
5560
5561 idx = get_connection_index(codec, cap, pin);
5562 if (idx < 0)
5563 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005564 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005565 return i; /* return the found index */
5566 }
5567 return -1; /* not found */
5568}
5569
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005570/* choose the ADC/MUX containing the input pin and initialize the setup */
5571static void fixup_single_adc(struct hda_codec *codec)
5572{
5573 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005574 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005575 int i;
5576
5577 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005578 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005579 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005580 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005581 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005582 /* use only this ADC */
5583 if (spec->capsrc_nids)
5584 spec->capsrc_nids += i;
5585 spec->adc_nids += i;
5586 spec->num_adc_nids = 1;
Takashi Iwai584c0c42011-03-10 12:51:11 +01005587 spec->single_input_src = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005588 }
5589}
5590
Takashi Iwai840b64c2010-07-13 22:49:01 +02005591/* initialize dual adcs */
5592static void fixup_dual_adc_switch(struct hda_codec *codec)
5593{
5594 struct alc_spec *spec = codec->spec;
5595 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5596 init_capsrc_for_pin(codec, spec->int_mic.pin);
5597}
5598
Takashi Iwai584c0c42011-03-10 12:51:11 +01005599/* initialize some special cases for input sources */
5600static void alc_init_special_input_src(struct hda_codec *codec)
5601{
5602 struct alc_spec *spec = codec->spec;
5603 if (spec->dual_adc_switch)
5604 fixup_dual_adc_switch(codec);
5605 else if (spec->single_input_src)
5606 init_capsrc_for_pin(codec, spec->autocfg.inputs[0].pin);
5607}
5608
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005609static void set_capture_mixer(struct hda_codec *codec)
5610{
5611 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005612 static struct snd_kcontrol_new *caps[2][3] = {
5613 { alc_capture_mixer_nosrc1,
5614 alc_capture_mixer_nosrc2,
5615 alc_capture_mixer_nosrc3 },
5616 { alc_capture_mixer1,
5617 alc_capture_mixer2,
5618 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005619 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005620 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005621 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005622 int num_adcs = spec->num_adc_nids;
5623 if (spec->dual_adc_switch)
Takashi Iwai584c0c42011-03-10 12:51:11 +01005624 num_adcs = 1;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005625 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005626 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005627 else if (spec->input_mux) {
5628 if (spec->input_mux->num_items > 1)
5629 mux = 1;
5630 else if (spec->input_mux->num_items == 1)
5631 fixup_single_adc(codec);
5632 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005633 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005634 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005635}
5636
Takashi Iwai66946352010-03-29 17:21:45 +02005637/* fill adc_nids (and capsrc_nids) containing all active input pins */
5638static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5639 int num_nids)
5640{
5641 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005642 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005643 int n;
5644 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5645
5646 for (n = 0; n < num_nids; n++) {
5647 hda_nid_t adc, cap;
5648 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5649 int nconns, i, j;
5650
5651 adc = nids[n];
5652 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5653 continue;
5654 cap = adc;
5655 nconns = snd_hda_get_connections(codec, cap, conn,
5656 ARRAY_SIZE(conn));
5657 if (nconns == 1) {
5658 cap = conn[0];
5659 nconns = snd_hda_get_connections(codec, cap, conn,
5660 ARRAY_SIZE(conn));
5661 }
5662 if (nconns <= 0)
5663 continue;
5664 if (!fallback_adc) {
5665 fallback_adc = adc;
5666 fallback_cap = cap;
5667 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005668 for (i = 0; i < cfg->num_inputs; i++) {
5669 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005670 for (j = 0; j < nconns; j++) {
5671 if (conn[j] == nid)
5672 break;
5673 }
5674 if (j >= nconns)
5675 break;
5676 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005677 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005678 int num_adcs = spec->num_adc_nids;
5679 spec->private_adc_nids[num_adcs] = adc;
5680 spec->private_capsrc_nids[num_adcs] = cap;
5681 spec->num_adc_nids++;
5682 spec->adc_nids = spec->private_adc_nids;
5683 if (adc != cap)
5684 spec->capsrc_nids = spec->private_capsrc_nids;
5685 }
5686 }
5687 if (!spec->num_adc_nids) {
5688 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005689 " using fallback 0x%x\n",
5690 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005691 spec->private_adc_nids[0] = fallback_adc;
5692 spec->adc_nids = spec->private_adc_nids;
5693 if (fallback_adc != fallback_cap) {
5694 spec->private_capsrc_nids[0] = fallback_cap;
5695 spec->capsrc_nids = spec->private_adc_nids;
5696 }
5697 }
5698}
5699
Takashi Iwai67d634c2009-11-16 15:35:59 +01005700#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005701#define set_beep_amp(spec, nid, idx, dir) \
5702 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005703
5704static struct snd_pci_quirk beep_white_list[] = {
5705 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005706 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005707 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005708 {}
5709};
5710
5711static inline int has_cdefine_beep(struct hda_codec *codec)
5712{
5713 struct alc_spec *spec = codec->spec;
5714 const struct snd_pci_quirk *q;
5715 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5716 if (q)
5717 return q->value;
5718 return spec->cdefine.enable_pcbeep;
5719}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005720#else
5721#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005722#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005723#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005724
5725/*
5726 * OK, here we have finally the patch for ALC880
5727 */
5728
Linus Torvalds1da177e2005-04-16 15:20:36 -07005729static int patch_alc880(struct hda_codec *codec)
5730{
5731 struct alc_spec *spec;
5732 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005733 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005734
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005735 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005736 if (spec == NULL)
5737 return -ENOMEM;
5738
5739 codec->spec = spec;
5740
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005741 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5742 alc880_models,
5743 alc880_cfg_tbl);
5744 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005745 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5746 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005747 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005748 }
5749
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005750 if (board_config == ALC880_AUTO) {
5751 /* automatic parse from the BIOS config */
5752 err = alc880_parse_auto_config(codec);
5753 if (err < 0) {
5754 alc_free(codec);
5755 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005756 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005757 printk(KERN_INFO
5758 "hda_codec: Cannot set up configuration "
5759 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005760 board_config = ALC880_3ST;
5761 }
5762 }
5763
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005764 err = snd_hda_attach_beep_device(codec, 0x1);
5765 if (err < 0) {
5766 alc_free(codec);
5767 return err;
5768 }
5769
Kailang Yangdf694da2005-12-05 19:42:22 +01005770 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005771 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005772
Linus Torvalds1da177e2005-04-16 15:20:36 -07005773 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5774 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005775 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005776
Linus Torvalds1da177e2005-04-16 15:20:36 -07005777 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5778 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5779
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005780 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005781 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005782 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005783 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005784 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005785 if (wcap != AC_WID_AUD_IN) {
5786 spec->adc_nids = alc880_adc_nids_alt;
5787 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005788 } else {
5789 spec->adc_nids = alc880_adc_nids;
5790 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005791 }
5792 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005793 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005794 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005795
Takashi Iwai2134ea42008-01-10 16:53:55 +01005796 spec->vmaster_nid = 0x0c;
5797
Linus Torvalds1da177e2005-04-16 15:20:36 -07005798 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005799 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005800 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005801#ifdef CONFIG_SND_HDA_POWER_SAVE
5802 if (!spec->loopback.amplist)
5803 spec->loopback.amplist = alc880_loopbacks;
5804#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005805
5806 return 0;
5807}
5808
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005809
Linus Torvalds1da177e2005-04-16 15:20:36 -07005810/*
5811 * ALC260 support
5812 */
5813
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005814static hda_nid_t alc260_dac_nids[1] = {
5815 /* front */
5816 0x02,
5817};
5818
5819static hda_nid_t alc260_adc_nids[1] = {
5820 /* ADC0 */
5821 0x04,
5822};
5823
Kailang Yangdf694da2005-12-05 19:42:22 +01005824static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005825 /* ADC1 */
5826 0x05,
5827};
5828
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005829/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5830 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5831 */
5832static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005833 /* ADC0, ADC1 */
5834 0x04, 0x05
5835};
5836
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005837#define ALC260_DIGOUT_NID 0x03
5838#define ALC260_DIGIN_NID 0x06
5839
5840static struct hda_input_mux alc260_capture_source = {
5841 .num_items = 4,
5842 .items = {
5843 { "Mic", 0x0 },
5844 { "Front Mic", 0x1 },
5845 { "Line", 0x2 },
5846 { "CD", 0x4 },
5847 },
5848};
5849
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005850/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005851 * headphone jack and the internal CD lines since these are the only pins at
5852 * which audio can appear. For flexibility, also allow the option of
5853 * recording the mixer output on the second ADC (ADC0 doesn't have a
5854 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005855 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005856static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5857 {
5858 .num_items = 3,
5859 .items = {
5860 { "Mic/Line", 0x0 },
5861 { "CD", 0x4 },
5862 { "Headphone", 0x2 },
5863 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005864 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005865 {
5866 .num_items = 4,
5867 .items = {
5868 { "Mic/Line", 0x0 },
5869 { "CD", 0x4 },
5870 { "Headphone", 0x2 },
5871 { "Mixer", 0x5 },
5872 },
5873 },
5874
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005875};
5876
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005877/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5878 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005879 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005880static struct hda_input_mux alc260_acer_capture_sources[2] = {
5881 {
5882 .num_items = 4,
5883 .items = {
5884 { "Mic", 0x0 },
5885 { "Line", 0x2 },
5886 { "CD", 0x4 },
5887 { "Headphone", 0x5 },
5888 },
5889 },
5890 {
5891 .num_items = 5,
5892 .items = {
5893 { "Mic", 0x0 },
5894 { "Line", 0x2 },
5895 { "CD", 0x4 },
5896 { "Headphone", 0x6 },
5897 { "Mixer", 0x5 },
5898 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005899 },
5900};
Michael Schwingencc959482009-02-22 18:58:45 +01005901
5902/* Maxdata Favorit 100XS */
5903static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5904 {
5905 .num_items = 2,
5906 .items = {
5907 { "Line/Mic", 0x0 },
5908 { "CD", 0x4 },
5909 },
5910 },
5911 {
5912 .num_items = 3,
5913 .items = {
5914 { "Line/Mic", 0x0 },
5915 { "CD", 0x4 },
5916 { "Mixer", 0x5 },
5917 },
5918 },
5919};
5920
Linus Torvalds1da177e2005-04-16 15:20:36 -07005921/*
5922 * This is just place-holder, so there's something for alc_build_pcms to look
5923 * at when it calculates the maximum number of channels. ALC260 has no mixer
5924 * element which allows changing the channel mode, so the verb list is
5925 * never used.
5926 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005927static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005928 { 2, NULL },
5929};
5930
Kailang Yangdf694da2005-12-05 19:42:22 +01005931
5932/* Mixer combinations
5933 *
5934 * basic: base_output + input + pc_beep + capture
5935 * HP: base_output + input + capture_alt
5936 * HP_3013: hp_3013 + input + capture
5937 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005938 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005939 */
5940
5941static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005942 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005943 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005944 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5945 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5946 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5947 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5948 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005949};
Kailang Yangdf694da2005-12-05 19:42:22 +01005950
5951static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005952 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5953 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5954 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5955 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5957 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5958 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005960 { } /* end */
5961};
5962
Takashi Iwaibec15c32008-01-28 18:16:30 +01005963/* update HP, line and mono out pins according to the master switch */
5964static void alc260_hp_master_update(struct hda_codec *codec,
5965 hda_nid_t hp, hda_nid_t line,
5966 hda_nid_t mono)
5967{
5968 struct alc_spec *spec = codec->spec;
5969 unsigned int val = spec->master_sw ? PIN_HP : 0;
5970 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005971 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005972 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005973 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005974 val);
5975 /* mono (speaker) depending on the HP jack sense */
5976 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005977 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005978 val);
5979}
5980
5981static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5982 struct snd_ctl_elem_value *ucontrol)
5983{
5984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5985 struct alc_spec *spec = codec->spec;
5986 *ucontrol->value.integer.value = spec->master_sw;
5987 return 0;
5988}
5989
5990static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5991 struct snd_ctl_elem_value *ucontrol)
5992{
5993 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5994 struct alc_spec *spec = codec->spec;
5995 int val = !!*ucontrol->value.integer.value;
5996 hda_nid_t hp, line, mono;
5997
5998 if (val == spec->master_sw)
5999 return 0;
6000 spec->master_sw = val;
6001 hp = (kcontrol->private_value >> 16) & 0xff;
6002 line = (kcontrol->private_value >> 8) & 0xff;
6003 mono = kcontrol->private_value & 0xff;
6004 alc260_hp_master_update(codec, hp, line, mono);
6005 return 1;
6006}
6007
6008static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
6009 {
6010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6011 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006012 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006013 .info = snd_ctl_boolean_mono_info,
6014 .get = alc260_hp_master_sw_get,
6015 .put = alc260_hp_master_sw_put,
6016 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
6017 },
6018 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6019 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
6020 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6021 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
6022 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
6023 HDA_OUTPUT),
6024 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6025 { } /* end */
6026};
6027
6028static struct hda_verb alc260_hp_unsol_verbs[] = {
6029 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6030 {},
6031};
6032
6033static void alc260_hp_automute(struct hda_codec *codec)
6034{
6035 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006036
Wu Fengguang864f92b2009-11-18 12:38:02 +08006037 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006038 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
6039}
6040
6041static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
6042{
6043 if ((res >> 26) == ALC880_HP_EVENT)
6044 alc260_hp_automute(codec);
6045}
6046
Kailang Yangdf694da2005-12-05 19:42:22 +01006047static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006048 {
6049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6050 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006051 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006052 .info = snd_ctl_boolean_mono_info,
6053 .get = alc260_hp_master_sw_get,
6054 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006055 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01006056 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006057 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6058 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6059 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
6060 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
6061 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006063 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6064 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02006065 { } /* end */
6066};
6067
Kailang Yang3f878302008-08-26 13:02:23 +02006068static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
6069 .ops = &snd_hda_bind_vol,
6070 .values = {
6071 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6072 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
6073 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6074 0
6075 },
6076};
6077
6078static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6079 .ops = &snd_hda_bind_sw,
6080 .values = {
6081 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6082 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6083 0
6084 },
6085};
6086
6087static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6088 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6089 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6090 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6091 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6092 { } /* end */
6093};
6094
Takashi Iwaibec15c32008-01-28 18:16:30 +01006095static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6096 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6097 {},
6098};
6099
6100static void alc260_hp_3013_automute(struct hda_codec *codec)
6101{
6102 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006103
Wu Fengguang864f92b2009-11-18 12:38:02 +08006104 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006105 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006106}
6107
6108static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6109 unsigned int res)
6110{
6111 if ((res >> 26) == ALC880_HP_EVENT)
6112 alc260_hp_3013_automute(codec);
6113}
6114
Kailang Yang3f878302008-08-26 13:02:23 +02006115static void alc260_hp_3012_automute(struct hda_codec *codec)
6116{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006117 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006118
Kailang Yang3f878302008-08-26 13:02:23 +02006119 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6120 bits);
6121 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6122 bits);
6123 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6124 bits);
6125}
6126
6127static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6128 unsigned int res)
6129{
6130 if ((res >> 26) == ALC880_HP_EVENT)
6131 alc260_hp_3012_automute(codec);
6132}
6133
6134/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006135 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6136 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006137static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006138 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006139 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006140 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006141 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6142 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6143 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6144 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006145 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006146 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6147 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006148 { } /* end */
6149};
6150
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006151/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6152 * versions of the ALC260 don't act on requests to enable mic bias from NID
6153 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6154 * datasheet doesn't mention this restriction. At this stage it's not clear
6155 * whether this behaviour is intentional or is a hardware bug in chip
6156 * revisions available in early 2006. Therefore for now allow the
6157 * "Headphone Jack Mode" control to span all choices, but if it turns out
6158 * that the lack of mic bias for this NID is intentional we could change the
6159 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6160 *
6161 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6162 * don't appear to make the mic bias available from the "line" jack, even
6163 * though the NID used for this jack (0x14) can supply it. The theory is
6164 * that perhaps Acer have included blocking capacitors between the ALC260
6165 * and the output jack. If this turns out to be the case for all such
6166 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6167 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006168 *
6169 * The C20x Tablet series have a mono internal speaker which is controlled
6170 * via the chip's Mono sum widget and pin complex, so include the necessary
6171 * controls for such models. On models without a "mono speaker" the control
6172 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006173 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006174static struct snd_kcontrol_new alc260_acer_mixer[] = {
6175 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6176 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006177 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006178 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006179 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006180 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006181 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006182 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6183 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6184 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6185 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6186 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6187 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6188 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6189 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006190 { } /* end */
6191};
6192
Michael Schwingencc959482009-02-22 18:58:45 +01006193/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6194 */
6195static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6196 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6197 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6198 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6199 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6200 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6201 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6202 { } /* end */
6203};
6204
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006205/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6206 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6207 */
6208static struct snd_kcontrol_new alc260_will_mixer[] = {
6209 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6210 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6212 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6213 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6214 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6215 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6216 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6217 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6218 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006219 { } /* end */
6220};
6221
6222/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6223 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6224 */
6225static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6226 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6227 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6229 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6230 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6231 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6232 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6233 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6234 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6235 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6236 { } /* end */
6237};
6238
Kailang Yangdf694da2005-12-05 19:42:22 +01006239/*
6240 * initialization verbs
6241 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006242static struct hda_verb alc260_init_verbs[] = {
6243 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006245 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006246 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006247 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006248 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006249 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006250 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006251 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006253 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006254 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006255 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006256 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006257 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006258 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006259 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006260 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6261 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006262 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006263 /* set connection select to line in (default select for this ADC) */
6264 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006265 /* mute capture amp left and right */
6266 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6267 /* set connection select to line in (default select for this ADC) */
6268 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006269 /* set vol=0 Line-Out mixer amp left and right */
6270 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6271 /* unmute pin widget amp left and right (no gain on this amp) */
6272 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6273 /* set vol=0 HP mixer amp left and right */
6274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6275 /* unmute pin widget amp left and right (no gain on this amp) */
6276 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6277 /* set vol=0 Mono mixer amp left and right */
6278 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6279 /* unmute pin widget amp left and right (no gain on this amp) */
6280 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6281 /* unmute LINE-2 out pin */
6282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006283 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6284 * Line In 2 = 0x03
6285 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006286 /* mute analog inputs */
6287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006292 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006293 /* mute Front out path */
6294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6296 /* mute Headphone out path */
6297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6299 /* mute Mono out path */
6300 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006302 { }
6303};
6304
Takashi Iwai474167d2006-05-17 17:17:43 +02006305#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006306static struct hda_verb alc260_hp_init_verbs[] = {
6307 /* Headphone and output */
6308 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6309 /* mono output */
6310 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6311 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6312 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6313 /* Mic2 (front panel) pin widget for input and vref at 80% */
6314 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6315 /* Line In pin widget for input */
6316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6317 /* Line-2 pin widget for output */
6318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6319 /* CD pin widget for input */
6320 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6321 /* unmute amp left and right */
6322 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6323 /* set connection select to line in (default select for this ADC) */
6324 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6325 /* unmute Line-Out mixer amp left and right (volume = 0) */
6326 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6327 /* mute pin widget amp left and right (no gain on this amp) */
6328 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6329 /* unmute HP mixer amp left and right (volume = 0) */
6330 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6331 /* mute pin widget amp left and right (no gain on this amp) */
6332 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006333 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6334 * Line In 2 = 0x03
6335 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006336 /* mute analog inputs */
6337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006342 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6343 /* Unmute Front out path */
6344 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6345 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6346 /* Unmute Headphone out path */
6347 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6348 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6349 /* Unmute Mono out path */
6350 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6351 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6352 { }
6353};
Takashi Iwai474167d2006-05-17 17:17:43 +02006354#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006355
6356static struct hda_verb alc260_hp_3013_init_verbs[] = {
6357 /* Line out and output */
6358 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6359 /* mono output */
6360 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6361 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6362 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6363 /* Mic2 (front panel) pin widget for input and vref at 80% */
6364 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6365 /* Line In pin widget for input */
6366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6367 /* Headphone pin widget for output */
6368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6369 /* CD pin widget for input */
6370 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6371 /* unmute amp left and right */
6372 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6373 /* set connection select to line in (default select for this ADC) */
6374 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6375 /* unmute Line-Out mixer amp left and right (volume = 0) */
6376 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6377 /* mute pin widget amp left and right (no gain on this amp) */
6378 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6379 /* unmute HP mixer amp left and right (volume = 0) */
6380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6381 /* mute pin widget amp left and right (no gain on this amp) */
6382 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006383 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6384 * Line In 2 = 0x03
6385 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006386 /* mute analog inputs */
6387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6388 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6389 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006392 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6393 /* Unmute Front out path */
6394 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6395 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6396 /* Unmute Headphone out path */
6397 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6398 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6399 /* Unmute Mono out path */
6400 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6401 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6402 { }
6403};
6404
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006405/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006406 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6407 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006408 */
6409static struct hda_verb alc260_fujitsu_init_verbs[] = {
6410 /* Disable all GPIOs */
6411 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6412 /* Internal speaker is connected to headphone pin */
6413 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6414 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006416 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6417 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6418 /* Ensure all other unused pins are disabled and muted. */
6419 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6420 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006421 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006422 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006423 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006424 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006427
Jonathan Woithef7ace402006-02-28 11:46:14 +01006428 /* Disable digital (SPDIF) pins */
6429 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6430 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006431
Kailang Yangea1fb292008-08-26 12:58:38 +02006432 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006433 * when acting as an output.
6434 */
6435 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6436
6437 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6444 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6446 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006447
Jonathan Woithef7ace402006-02-28 11:46:14 +01006448 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6449 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6450 /* Unmute Line1 pin widget output buffer since it starts as an output.
6451 * If the pin mode is changed by the user the pin mode control will
6452 * take care of enabling the pin's input/output buffers as needed.
6453 * Therefore there's no need to enable the input buffer at this
6454 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006455 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006456 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006457 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006458 * mixer ctrl)
6459 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006460 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006461
Jonathan Woithef7ace402006-02-28 11:46:14 +01006462 /* Mute capture amp left and right */
6463 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006464 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006465 * in (on mic1 pin)
6466 */
6467 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006468
Jonathan Woithef7ace402006-02-28 11:46:14 +01006469 /* Do the same for the second ADC: mute capture input amp and
6470 * set ADC connection to line in (on mic1 pin)
6471 */
6472 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6473 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006474
Jonathan Woithef7ace402006-02-28 11:46:14 +01006475 /* Mute all inputs to mixer widget (even unconnected ones) */
6476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6482 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6483 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006484
6485 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006486};
6487
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006488/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6489 * similar laptops (adapted from Fujitsu init verbs).
6490 */
6491static struct hda_verb alc260_acer_init_verbs[] = {
6492 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6493 * the headphone jack. Turn this on and rely on the standard mute
6494 * methods whenever the user wants to turn these outputs off.
6495 */
6496 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6497 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6498 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6499 /* Internal speaker/Headphone jack is connected to Line-out pin */
6500 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6501 /* Internal microphone/Mic jack is connected to Mic1 pin */
6502 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6503 /* Line In jack is connected to Line1 pin */
6504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006505 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6506 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006507 /* Ensure all other unused pins are disabled and muted. */
6508 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6509 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006510 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6511 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6514 /* Disable digital (SPDIF) pins */
6515 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6516 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6517
Kailang Yangea1fb292008-08-26 12:58:38 +02006518 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006519 * bus when acting as outputs.
6520 */
6521 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6522 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6523
6524 /* Start with output sum widgets muted and their output gains at min */
6525 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6526 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6527 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6528 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6529 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6530 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6531 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6532 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6533 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6534
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006535 /* Unmute Line-out pin widget amp left and right
6536 * (no equiv mixer ctrl)
6537 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006538 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006539 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6540 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006541 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6542 * inputs. If the pin mode is changed by the user the pin mode control
6543 * will take care of enabling the pin's input/output buffers as needed.
6544 * Therefore there's no need to enable the input buffer at this
6545 * stage.
6546 */
6547 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6548 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6549
6550 /* Mute capture amp left and right */
6551 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6552 /* Set ADC connection select to match default mixer setting - mic
6553 * (on mic1 pin)
6554 */
6555 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6556
6557 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006558 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006559 */
6560 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006561 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006562
6563 /* Mute all inputs to mixer widget (even unconnected ones) */
6564 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6572
6573 { }
6574};
6575
Michael Schwingencc959482009-02-22 18:58:45 +01006576/* Initialisation sequence for Maxdata Favorit 100XS
6577 * (adapted from Acer init verbs).
6578 */
6579static struct hda_verb alc260_favorit100_init_verbs[] = {
6580 /* GPIO 0 enables the output jack.
6581 * Turn this on and rely on the standard mute
6582 * methods whenever the user wants to turn these outputs off.
6583 */
6584 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6585 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6586 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6587 /* Line/Mic input jack is connected to Mic1 pin */
6588 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6589 /* Ensure all other unused pins are disabled and muted. */
6590 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6591 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6592 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6593 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6594 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6595 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6599 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6600 /* Disable digital (SPDIF) pins */
6601 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6602 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6603
6604 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6605 * bus when acting as outputs.
6606 */
6607 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6608 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6609
6610 /* Start with output sum widgets muted and their output gains at min */
6611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6612 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6613 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6615 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6616 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6617 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6618 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6619 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6620
6621 /* Unmute Line-out pin widget amp left and right
6622 * (no equiv mixer ctrl)
6623 */
6624 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6625 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6626 * inputs. If the pin mode is changed by the user the pin mode control
6627 * will take care of enabling the pin's input/output buffers as needed.
6628 * Therefore there's no need to enable the input buffer at this
6629 * stage.
6630 */
6631 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6632
6633 /* Mute capture amp left and right */
6634 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6635 /* Set ADC connection select to match default mixer setting - mic
6636 * (on mic1 pin)
6637 */
6638 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6639
6640 /* Do similar with the second ADC: mute capture input amp and
6641 * set ADC connection to mic to match ALSA's default state.
6642 */
6643 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6644 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6645
6646 /* Mute all inputs to mixer widget (even unconnected ones) */
6647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6655
6656 { }
6657};
6658
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006659static struct hda_verb alc260_will_verbs[] = {
6660 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6661 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6662 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6663 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6664 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6665 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6666 {}
6667};
6668
6669static struct hda_verb alc260_replacer_672v_verbs[] = {
6670 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6671 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6672 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6673
6674 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6675 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6676 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6677
6678 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6679 {}
6680};
6681
6682/* toggle speaker-output according to the hp-jack state */
6683static void alc260_replacer_672v_automute(struct hda_codec *codec)
6684{
6685 unsigned int present;
6686
6687 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006688 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006689 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006690 snd_hda_codec_write_cache(codec, 0x01, 0,
6691 AC_VERB_SET_GPIO_DATA, 1);
6692 snd_hda_codec_write_cache(codec, 0x0f, 0,
6693 AC_VERB_SET_PIN_WIDGET_CONTROL,
6694 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006695 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006696 snd_hda_codec_write_cache(codec, 0x01, 0,
6697 AC_VERB_SET_GPIO_DATA, 0);
6698 snd_hda_codec_write_cache(codec, 0x0f, 0,
6699 AC_VERB_SET_PIN_WIDGET_CONTROL,
6700 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006701 }
6702}
6703
6704static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6705 unsigned int res)
6706{
6707 if ((res >> 26) == ALC880_HP_EVENT)
6708 alc260_replacer_672v_automute(codec);
6709}
6710
Kailang Yang3f878302008-08-26 13:02:23 +02006711static struct hda_verb alc260_hp_dc7600_verbs[] = {
6712 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6713 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6714 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6715 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6716 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6717 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6718 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6719 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6720 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6721 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6722 {}
6723};
6724
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006725/* Test configuration for debugging, modelled after the ALC880 test
6726 * configuration.
6727 */
6728#ifdef CONFIG_SND_DEBUG
6729static hda_nid_t alc260_test_dac_nids[1] = {
6730 0x02,
6731};
6732static hda_nid_t alc260_test_adc_nids[2] = {
6733 0x04, 0x05,
6734};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006735/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006736 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006737 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006738 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006739static struct hda_input_mux alc260_test_capture_sources[2] = {
6740 {
6741 .num_items = 7,
6742 .items = {
6743 { "MIC1 pin", 0x0 },
6744 { "MIC2 pin", 0x1 },
6745 { "LINE1 pin", 0x2 },
6746 { "LINE2 pin", 0x3 },
6747 { "CD pin", 0x4 },
6748 { "LINE-OUT pin", 0x5 },
6749 { "HP-OUT pin", 0x6 },
6750 },
6751 },
6752 {
6753 .num_items = 8,
6754 .items = {
6755 { "MIC1 pin", 0x0 },
6756 { "MIC2 pin", 0x1 },
6757 { "LINE1 pin", 0x2 },
6758 { "LINE2 pin", 0x3 },
6759 { "CD pin", 0x4 },
6760 { "Mixer", 0x5 },
6761 { "LINE-OUT pin", 0x6 },
6762 { "HP-OUT pin", 0x7 },
6763 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006764 },
6765};
6766static struct snd_kcontrol_new alc260_test_mixer[] = {
6767 /* Output driver widgets */
6768 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6769 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6770 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6771 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6772 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6773 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6774
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006775 /* Modes for retasking pin widgets
6776 * Note: the ALC260 doesn't seem to act on requests to enable mic
6777 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6778 * mention this restriction. At this stage it's not clear whether
6779 * this behaviour is intentional or is a hardware bug in chip
6780 * revisions available at least up until early 2006. Therefore for
6781 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6782 * choices, but if it turns out that the lack of mic bias for these
6783 * NIDs is intentional we could change their modes from
6784 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6785 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006786 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6787 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6788 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6789 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6790 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6791 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6792
6793 /* Loopback mixer controls */
6794 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6795 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6796 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6797 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6798 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6799 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6800 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6801 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6802 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6803 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006804 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6805 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6806 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6807 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006808
6809 /* Controls for GPIO pins, assuming they are configured as outputs */
6810 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6811 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6812 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6813 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6814
Jonathan Woithe92621f12006-02-28 11:47:47 +01006815 /* Switches to allow the digital IO pins to be enabled. The datasheet
6816 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006817 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006818 */
6819 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6820 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6821
Jonathan Woithef8225f62008-01-08 12:16:54 +01006822 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6823 * this output to turn on an external amplifier.
6824 */
6825 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6826 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6827
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006828 { } /* end */
6829};
6830static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006831 /* Enable all GPIOs as outputs with an initial value of 0 */
6832 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6833 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6834 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6835
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006836 /* Enable retasking pins as output, initially without power amp */
6837 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6838 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6839 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6841 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6842 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6843
Jonathan Woithe92621f12006-02-28 11:47:47 +01006844 /* Disable digital (SPDIF) pins initially, but users can enable
6845 * them via a mixer switch. In the case of SPDIF-out, this initverb
6846 * payload also sets the generation to 0, output to be in "consumer"
6847 * PCM format, copyright asserted, no pre-emphasis and no validity
6848 * control.
6849 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006850 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6851 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6852
Kailang Yangea1fb292008-08-26 12:58:38 +02006853 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006854 * OUT1 sum bus when acting as an output.
6855 */
6856 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6857 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6858 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6859 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6860
6861 /* Start with output sum widgets muted and their output gains at min */
6862 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6863 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6864 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6865 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6866 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6867 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6868 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6869 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6870 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6871
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006872 /* Unmute retasking pin widget output buffers since the default
6873 * state appears to be output. As the pin mode is changed by the
6874 * user the pin mode control will take care of enabling the pin's
6875 * input/output buffers as needed.
6876 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006877 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6878 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6881 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6882 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6883 /* Also unmute the mono-out pin widget */
6884 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6885
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006886 /* Mute capture amp left and right */
6887 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006888 /* Set ADC connection select to match default mixer setting (mic1
6889 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006890 */
6891 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6892
6893 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006894 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006895 */
6896 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6897 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6898
6899 /* Mute all inputs to mixer widget (even unconnected ones) */
6900 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6901 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6908
6909 { }
6910};
6911#endif
6912
Takashi Iwai63300792008-01-24 15:31:36 +01006913#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6914#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006915
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006916#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6917#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6918
Kailang Yangdf694da2005-12-05 19:42:22 +01006919/*
6920 * for BIOS auto-configuration
6921 */
6922
6923static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006924 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006925{
6926 hda_nid_t nid_vol;
6927 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006928 int err;
6929
6930 if (nid >= 0x0f && nid < 0x11) {
6931 nid_vol = nid - 0x7;
6932 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6933 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6934 } else if (nid == 0x11) {
6935 nid_vol = nid - 0x7;
6936 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6937 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6938 } else if (nid >= 0x12 && nid <= 0x15) {
6939 nid_vol = 0x08;
6940 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6941 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6942 } else
6943 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006944
Takashi Iwai863b4512008-10-21 17:01:47 +02006945 if (!(*vol_bits & (1 << nid_vol))) {
6946 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006947 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006948 if (err < 0)
6949 return err;
6950 *vol_bits |= (1 << nid_vol);
6951 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006952 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006953 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006954 return err;
6955 return 1;
6956}
6957
6958/* add playback controls from the parsed DAC table */
6959static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6960 const struct auto_pin_cfg *cfg)
6961{
6962 hda_nid_t nid;
6963 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006964 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006965
6966 spec->multiout.num_dacs = 1;
6967 spec->multiout.dac_nids = spec->private_dac_nids;
6968 spec->multiout.dac_nids[0] = 0x02;
6969
6970 nid = cfg->line_out_pins[0];
6971 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006972 const char *pfx;
6973 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6974 pfx = "Master";
6975 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6976 pfx = "Speaker";
6977 else
6978 pfx = "Front";
6979 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006980 if (err < 0)
6981 return err;
6982 }
6983
Takashi Iwai82bc9552006-03-21 11:24:42 +01006984 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006985 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006986 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006987 if (err < 0)
6988 return err;
6989 }
6990
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006991 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006992 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006993 err = alc260_add_playback_controls(spec, nid, "Headphone",
6994 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006995 if (err < 0)
6996 return err;
6997 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006998 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006999}
7000
7001/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007002static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01007003 const struct auto_pin_cfg *cfg)
7004{
Takashi Iwai05f5f472009-08-25 13:10:18 +02007005 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01007006}
7007
7008static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
7009 hda_nid_t nid, int pin_type,
7010 int sel_idx)
7011{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007012 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007013 /* need the manual connection? */
7014 if (nid >= 0x12) {
7015 int idx = nid - 0x12;
7016 snd_hda_codec_write(codec, idx + 0x0b, 0,
7017 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01007018 }
7019}
7020
7021static void alc260_auto_init_multi_out(struct hda_codec *codec)
7022{
7023 struct alc_spec *spec = codec->spec;
7024 hda_nid_t nid;
7025
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007026 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007027 if (nid) {
7028 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7029 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
7030 }
Kailang Yangea1fb292008-08-26 12:58:38 +02007031
Takashi Iwai82bc9552006-03-21 11:24:42 +01007032 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007033 if (nid)
7034 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
7035
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007036 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007037 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007038 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007039}
Kailang Yangdf694da2005-12-05 19:42:22 +01007040
7041#define ALC260_PIN_CD_NID 0x16
7042static void alc260_auto_init_analog_input(struct hda_codec *codec)
7043{
7044 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007045 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01007046 int i;
7047
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007048 for (i = 0; i < cfg->num_inputs; i++) {
7049 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01007050 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02007051 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01007052 if (nid != ALC260_PIN_CD_NID &&
7053 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007054 snd_hda_codec_write(codec, nid, 0,
7055 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01007056 AMP_OUT_MUTE);
7057 }
7058 }
7059}
7060
Takashi Iwai7f311a42010-04-09 17:32:23 +02007061#define alc260_auto_init_input_src alc880_auto_init_input_src
7062
Kailang Yangdf694da2005-12-05 19:42:22 +01007063/*
7064 * generic initialization of ADC, input mixers and output mixers
7065 */
7066static struct hda_verb alc260_volume_init_verbs[] = {
7067 /*
7068 * Unmute ADC0-1 and set the default input to mic-in
7069 */
7070 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7071 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7072 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7073 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007074
Kailang Yangdf694da2005-12-05 19:42:22 +01007075 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7076 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007077 * Note: PASD motherboards uses the Line In 2 as the input for
7078 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007079 */
7080 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007081 /* mute analog inputs */
7082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7086 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007087
7088 /*
7089 * Set up output mixers (0x08 - 0x0a)
7090 */
7091 /* set vol=0 to output mixers */
7092 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7093 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7094 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7095 /* set up input amps for analog loopback */
7096 /* Amp Indices: DAC = 0, mixer = 1 */
7097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7098 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7099 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7101 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7102 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007103
Kailang Yangdf694da2005-12-05 19:42:22 +01007104 { }
7105};
7106
7107static int alc260_parse_auto_config(struct hda_codec *codec)
7108{
7109 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007110 int err;
7111 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7112
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007113 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7114 alc260_ignore);
7115 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007116 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007117 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7118 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007119 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007120 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007121 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007122 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007123 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007124 return err;
7125
7126 spec->multiout.max_channels = 2;
7127
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007128 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007129 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007130 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007131 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007132
Takashi Iwaid88897e2008-10-31 15:01:37 +01007133 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007134
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007135 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007136 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007137
Kailang Yang6227cdc2010-02-25 08:36:52 +01007138 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007139
Kailang Yangdf694da2005-12-05 19:42:22 +01007140 return 1;
7141}
7142
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007143/* additional initialization for auto-configuration model */
7144static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007145{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007146 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007147 alc260_auto_init_multi_out(codec);
7148 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007149 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007150 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007151 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007152 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007153}
7154
Takashi Iwaicb53c622007-08-10 17:21:45 +02007155#ifdef CONFIG_SND_HDA_POWER_SAVE
7156static struct hda_amp_list alc260_loopbacks[] = {
7157 { 0x07, HDA_INPUT, 0 },
7158 { 0x07, HDA_INPUT, 1 },
7159 { 0x07, HDA_INPUT, 2 },
7160 { 0x07, HDA_INPUT, 3 },
7161 { 0x07, HDA_INPUT, 4 },
7162 { } /* end */
7163};
7164#endif
7165
Kailang Yangdf694da2005-12-05 19:42:22 +01007166/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007167 * Pin config fixes
7168 */
7169enum {
7170 PINFIX_HP_DC5750,
7171};
7172
Takashi Iwaifc091762010-08-04 23:53:36 +02007173static const struct alc_fixup alc260_fixups[] = {
7174 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007175 .type = ALC_FIXUP_PINS,
7176 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007177 { 0x11, 0x90130110 }, /* speaker */
7178 { }
7179 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007180 },
7181};
7182
7183static struct snd_pci_quirk alc260_fixup_tbl[] = {
7184 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7185 {}
7186};
7187
7188/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007189 * ALC260 configurations
7190 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007191static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007192 [ALC260_BASIC] = "basic",
7193 [ALC260_HP] = "hp",
7194 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007195 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007196 [ALC260_FUJITSU_S702X] = "fujitsu",
7197 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007198 [ALC260_WILL] = "will",
7199 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007200 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007201#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007202 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007203#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007204 [ALC260_AUTO] = "auto",
7205};
7206
7207static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007208 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007209 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007210 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007211 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007212 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007213 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007214 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007215 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007216 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007217 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7218 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7219 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7220 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7221 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7222 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7223 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7224 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7225 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007226 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007227 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007228 {}
7229};
7230
Kailang Yangdf694da2005-12-05 19:42:22 +01007231static struct alc_config_preset alc260_presets[] = {
7232 [ALC260_BASIC] = {
7233 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007234 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007235 .init_verbs = { alc260_init_verbs },
7236 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7237 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007238 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007239 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007240 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7241 .channel_mode = alc260_modes,
7242 .input_mux = &alc260_capture_source,
7243 },
7244 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007245 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007246 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007247 .init_verbs = { alc260_init_verbs,
7248 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007249 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7250 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007251 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7252 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007253 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7254 .channel_mode = alc260_modes,
7255 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007256 .unsol_event = alc260_hp_unsol_event,
7257 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007258 },
Kailang Yang3f878302008-08-26 13:02:23 +02007259 [ALC260_HP_DC7600] = {
7260 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007261 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007262 .init_verbs = { alc260_init_verbs,
7263 alc260_hp_dc7600_verbs },
7264 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7265 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007266 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7267 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007268 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7269 .channel_mode = alc260_modes,
7270 .input_mux = &alc260_capture_source,
7271 .unsol_event = alc260_hp_3012_unsol_event,
7272 .init_hook = alc260_hp_3012_automute,
7273 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007274 [ALC260_HP_3013] = {
7275 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007276 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007277 .init_verbs = { alc260_hp_3013_init_verbs,
7278 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007279 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7280 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007281 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7282 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007283 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7284 .channel_mode = alc260_modes,
7285 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007286 .unsol_event = alc260_hp_3013_unsol_event,
7287 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007288 },
7289 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007290 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007291 .init_verbs = { alc260_fujitsu_init_verbs },
7292 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7293 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007294 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7295 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007296 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7297 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007298 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7299 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007300 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007301 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007302 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007303 .init_verbs = { alc260_acer_init_verbs },
7304 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7305 .dac_nids = alc260_dac_nids,
7306 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7307 .adc_nids = alc260_dual_adc_nids,
7308 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7309 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007310 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7311 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007312 },
Michael Schwingencc959482009-02-22 18:58:45 +01007313 [ALC260_FAVORIT100] = {
7314 .mixers = { alc260_favorit100_mixer },
7315 .init_verbs = { alc260_favorit100_init_verbs },
7316 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7317 .dac_nids = alc260_dac_nids,
7318 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7319 .adc_nids = alc260_dual_adc_nids,
7320 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7321 .channel_mode = alc260_modes,
7322 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7323 .input_mux = alc260_favorit100_capture_sources,
7324 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007325 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007326 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007327 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7328 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7329 .dac_nids = alc260_dac_nids,
7330 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7331 .adc_nids = alc260_adc_nids,
7332 .dig_out_nid = ALC260_DIGOUT_NID,
7333 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7334 .channel_mode = alc260_modes,
7335 .input_mux = &alc260_capture_source,
7336 },
7337 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007338 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007339 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7340 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7341 .dac_nids = alc260_dac_nids,
7342 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7343 .adc_nids = alc260_adc_nids,
7344 .dig_out_nid = ALC260_DIGOUT_NID,
7345 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7346 .channel_mode = alc260_modes,
7347 .input_mux = &alc260_capture_source,
7348 .unsol_event = alc260_replacer_672v_unsol_event,
7349 .init_hook = alc260_replacer_672v_automute,
7350 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007351#ifdef CONFIG_SND_DEBUG
7352 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007353 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007354 .init_verbs = { alc260_test_init_verbs },
7355 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7356 .dac_nids = alc260_test_dac_nids,
7357 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7358 .adc_nids = alc260_test_adc_nids,
7359 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7360 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007361 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7362 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007363 },
7364#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007365};
7366
Linus Torvalds1da177e2005-04-16 15:20:36 -07007367static int patch_alc260(struct hda_codec *codec)
7368{
7369 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007370 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007371
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007372 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007373 if (spec == NULL)
7374 return -ENOMEM;
7375
7376 codec->spec = spec;
7377
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007378 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7379 alc260_models,
7380 alc260_cfg_tbl);
7381 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007382 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007383 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007384 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007385 }
7386
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007387 if (board_config == ALC260_AUTO) {
7388 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7389 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7390 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007391
Kailang Yangdf694da2005-12-05 19:42:22 +01007392 if (board_config == ALC260_AUTO) {
7393 /* automatic parse from the BIOS config */
7394 err = alc260_parse_auto_config(codec);
7395 if (err < 0) {
7396 alc_free(codec);
7397 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007398 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007399 printk(KERN_INFO
7400 "hda_codec: Cannot set up configuration "
7401 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007402 board_config = ALC260_BASIC;
7403 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007404 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007405
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007406 err = snd_hda_attach_beep_device(codec, 0x1);
7407 if (err < 0) {
7408 alc_free(codec);
7409 return err;
7410 }
7411
Kailang Yangdf694da2005-12-05 19:42:22 +01007412 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007413 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007414
Linus Torvalds1da177e2005-04-16 15:20:36 -07007415 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7416 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307417 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007418
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007419 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7420 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7421
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007422 if (!spec->adc_nids && spec->input_mux) {
7423 /* check whether NID 0x04 is valid */
7424 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007425 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007426 /* get type */
7427 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7428 spec->adc_nids = alc260_adc_nids_alt;
7429 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7430 } else {
7431 spec->adc_nids = alc260_adc_nids;
7432 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7433 }
7434 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007435 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007436 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007437
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007438 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007439
Takashi Iwai2134ea42008-01-10 16:53:55 +01007440 spec->vmaster_nid = 0x08;
7441
Linus Torvalds1da177e2005-04-16 15:20:36 -07007442 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007443 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007444 spec->init_hook = alc260_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +02007445 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007446#ifdef CONFIG_SND_HDA_POWER_SAVE
7447 if (!spec->loopback.amplist)
7448 spec->loopback.amplist = alc260_loopbacks;
7449#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007450
7451 return 0;
7452}
7453
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007454
Linus Torvalds1da177e2005-04-16 15:20:36 -07007455/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007456 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007457 *
7458 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7459 * configuration. Each pin widget can choose any input DACs and a mixer.
7460 * Each ADC is connected from a mixer of all inputs. This makes possible
7461 * 6-channel independent captures.
7462 *
7463 * In addition, an independent DAC for the multi-playback (not used in this
7464 * driver yet).
7465 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007466#define ALC882_DIGOUT_NID 0x06
7467#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007468#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7469#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7470#define ALC1200_DIGOUT_NID 0x10
7471
Linus Torvalds1da177e2005-04-16 15:20:36 -07007472
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007473static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007474 { 8, NULL }
7475};
7476
Takashi Iwai4953550a2009-06-30 15:28:30 +02007477/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007478static hda_nid_t alc882_dac_nids[4] = {
7479 /* front, rear, clfe, rear_surr */
7480 0x02, 0x03, 0x04, 0x05
7481};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007482#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007483
Takashi Iwai4953550a2009-06-30 15:28:30 +02007484/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007485#define alc882_adc_nids alc880_adc_nids
7486#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007487#define alc883_adc_nids alc882_adc_nids_alt
7488static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7489static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7490#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007491
Takashi Iwaie1406342008-02-11 18:32:32 +01007492static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7493static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007494#define alc883_capsrc_nids alc882_capsrc_nids_alt
7495static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7496#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007497
Linus Torvalds1da177e2005-04-16 15:20:36 -07007498/* input MUX */
7499/* FIXME: should be a matrix-type input source selection */
7500
7501static struct hda_input_mux alc882_capture_source = {
7502 .num_items = 4,
7503 .items = {
7504 { "Mic", 0x0 },
7505 { "Front Mic", 0x1 },
7506 { "Line", 0x2 },
7507 { "CD", 0x4 },
7508 },
7509};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007510
Takashi Iwai4953550a2009-06-30 15:28:30 +02007511#define alc883_capture_source alc882_capture_source
7512
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007513static struct hda_input_mux alc889_capture_source = {
7514 .num_items = 3,
7515 .items = {
7516 { "Front Mic", 0x0 },
7517 { "Mic", 0x3 },
7518 { "Line", 0x2 },
7519 },
7520};
7521
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007522static struct hda_input_mux mb5_capture_source = {
7523 .num_items = 3,
7524 .items = {
7525 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307526 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007527 { "CD", 0x4 },
7528 },
7529};
7530
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007531static struct hda_input_mux macmini3_capture_source = {
7532 .num_items = 2,
7533 .items = {
7534 { "Line", 0x2 },
7535 { "CD", 0x4 },
7536 },
7537};
7538
Takashi Iwai4953550a2009-06-30 15:28:30 +02007539static struct hda_input_mux alc883_3stack_6ch_intel = {
7540 .num_items = 4,
7541 .items = {
7542 { "Mic", 0x1 },
7543 { "Front Mic", 0x0 },
7544 { "Line", 0x2 },
7545 { "CD", 0x4 },
7546 },
7547};
7548
7549static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7550 .num_items = 2,
7551 .items = {
7552 { "Mic", 0x1 },
7553 { "Line", 0x2 },
7554 },
7555};
7556
7557static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7558 .num_items = 4,
7559 .items = {
7560 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007561 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007562 { "Line", 0x2 },
7563 { "CD", 0x4 },
7564 },
7565};
7566
7567static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7568 .num_items = 2,
7569 .items = {
7570 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007571 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007572 },
7573};
7574
7575static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7576 .num_items = 3,
7577 .items = {
7578 { "Mic", 0x0 },
7579 { "Front Mic", 0x1 },
7580 { "Line", 0x4 },
7581 },
7582};
7583
7584static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7585 .num_items = 2,
7586 .items = {
7587 { "Mic", 0x0 },
7588 { "Line", 0x2 },
7589 },
7590};
7591
7592static struct hda_input_mux alc889A_mb31_capture_source = {
7593 .num_items = 2,
7594 .items = {
7595 { "Mic", 0x0 },
7596 /* Front Mic (0x01) unused */
7597 { "Line", 0x2 },
7598 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007599 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007600 },
7601};
7602
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007603static struct hda_input_mux alc889A_imac91_capture_source = {
7604 .num_items = 2,
7605 .items = {
7606 { "Mic", 0x01 },
7607 { "Line", 0x2 }, /* Not sure! */
7608 },
7609};
7610
Takashi Iwai4953550a2009-06-30 15:28:30 +02007611/*
7612 * 2ch mode
7613 */
7614static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7615 { 2, NULL }
7616};
7617
Kailang Yangdf694da2005-12-05 19:42:22 +01007618/*
Kailang Yang272a5272007-05-14 11:00:38 +02007619 * 2ch mode
7620 */
7621static struct hda_verb alc882_3ST_ch2_init[] = {
7622 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7623 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7624 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7625 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7626 { } /* end */
7627};
7628
7629/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007630 * 4ch mode
7631 */
7632static struct hda_verb alc882_3ST_ch4_init[] = {
7633 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7634 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7635 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7636 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7637 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7638 { } /* end */
7639};
7640
7641/*
Kailang Yang272a5272007-05-14 11:00:38 +02007642 * 6ch mode
7643 */
7644static struct hda_verb alc882_3ST_ch6_init[] = {
7645 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7646 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7647 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7648 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7649 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7650 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7651 { } /* end */
7652};
7653
Takashi Iwai4953550a2009-06-30 15:28:30 +02007654static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007655 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007656 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007657 { 6, alc882_3ST_ch6_init },
7658};
7659
Takashi Iwai4953550a2009-06-30 15:28:30 +02007660#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7661
Kailang Yang272a5272007-05-14 11:00:38 +02007662/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307663 * 2ch mode
7664 */
7665static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7666 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7667 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7668 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7669 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7670 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7671 { } /* end */
7672};
7673
7674/*
7675 * 4ch mode
7676 */
7677static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7678 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7679 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7680 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7681 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7682 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7683 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7684 { } /* end */
7685};
7686
7687/*
7688 * 6ch mode
7689 */
7690static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7691 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7692 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7693 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7694 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7695 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7696 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7697 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7698 { } /* end */
7699};
7700
7701static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7702 { 2, alc883_3ST_ch2_clevo_init },
7703 { 4, alc883_3ST_ch4_clevo_init },
7704 { 6, alc883_3ST_ch6_clevo_init },
7705};
7706
7707
7708/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007709 * 6ch mode
7710 */
7711static struct hda_verb alc882_sixstack_ch6_init[] = {
7712 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7713 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7714 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7715 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7716 { } /* end */
7717};
7718
7719/*
7720 * 8ch mode
7721 */
7722static struct hda_verb alc882_sixstack_ch8_init[] = {
7723 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7724 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7725 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7726 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7727 { } /* end */
7728};
7729
7730static struct hda_channel_mode alc882_sixstack_modes[2] = {
7731 { 6, alc882_sixstack_ch6_init },
7732 { 8, alc882_sixstack_ch8_init },
7733};
7734
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007735
7736/* Macbook Air 2,1 */
7737
7738static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7739 { 2, NULL },
7740};
7741
Takashi Iwai87350ad2007-08-16 18:19:38 +02007742/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007743 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007744 */
7745
7746/*
7747 * 2ch mode
7748 */
7749static struct hda_verb alc885_mbp_ch2_init[] = {
7750 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7751 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7752 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7753 { } /* end */
7754};
7755
7756/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007757 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007758 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007759static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007760 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7761 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7762 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7763 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7764 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7765 { } /* end */
7766};
7767
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007768static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007769 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007770 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007771};
7772
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007773/*
7774 * 2ch
7775 * Speakers/Woofer/HP = Front
7776 * LineIn = Input
7777 */
7778static struct hda_verb alc885_mb5_ch2_init[] = {
7779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7780 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7781 { } /* end */
7782};
7783
7784/*
7785 * 6ch mode
7786 * Speakers/HP = Front
7787 * Woofer = LFE
7788 * LineIn = Surround
7789 */
7790static struct hda_verb alc885_mb5_ch6_init[] = {
7791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7793 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7794 { } /* end */
7795};
7796
7797static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7798 { 2, alc885_mb5_ch2_init },
7799 { 6, alc885_mb5_ch6_init },
7800};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007801
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007802#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007803
7804/*
7805 * 2ch mode
7806 */
7807static struct hda_verb alc883_4ST_ch2_init[] = {
7808 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7809 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7810 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7811 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7812 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7813 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7814 { } /* end */
7815};
7816
7817/*
7818 * 4ch mode
7819 */
7820static struct hda_verb alc883_4ST_ch4_init[] = {
7821 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7822 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7823 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7824 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7825 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7826 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7827 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7828 { } /* end */
7829};
7830
7831/*
7832 * 6ch mode
7833 */
7834static struct hda_verb alc883_4ST_ch6_init[] = {
7835 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7836 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7837 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7838 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7839 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7842 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7843 { } /* end */
7844};
7845
7846/*
7847 * 8ch mode
7848 */
7849static struct hda_verb alc883_4ST_ch8_init[] = {
7850 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7851 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7852 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7853 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7854 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7855 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7856 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7857 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7858 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7859 { } /* end */
7860};
7861
7862static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7863 { 2, alc883_4ST_ch2_init },
7864 { 4, alc883_4ST_ch4_init },
7865 { 6, alc883_4ST_ch6_init },
7866 { 8, alc883_4ST_ch8_init },
7867};
7868
7869
7870/*
7871 * 2ch mode
7872 */
7873static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7874 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7875 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7876 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7877 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7878 { } /* end */
7879};
7880
7881/*
7882 * 4ch mode
7883 */
7884static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7885 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7886 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7887 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7888 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7889 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7890 { } /* end */
7891};
7892
7893/*
7894 * 6ch mode
7895 */
7896static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7897 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7898 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7899 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7900 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7901 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7902 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7903 { } /* end */
7904};
7905
7906static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7907 { 2, alc883_3ST_ch2_intel_init },
7908 { 4, alc883_3ST_ch4_intel_init },
7909 { 6, alc883_3ST_ch6_intel_init },
7910};
7911
7912/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007913 * 2ch mode
7914 */
7915static struct hda_verb alc889_ch2_intel_init[] = {
7916 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7917 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7918 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7919 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7920 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7921 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7922 { } /* end */
7923};
7924
7925/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007926 * 6ch mode
7927 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007928static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007929 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7930 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7931 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7932 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7933 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007934 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7935 { } /* end */
7936};
7937
7938/*
7939 * 8ch mode
7940 */
7941static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007942 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7943 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7944 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7945 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7946 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007947 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7948 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007949 { } /* end */
7950};
7951
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007952static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7953 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007954 { 6, alc889_ch6_intel_init },
7955 { 8, alc889_ch8_intel_init },
7956};
7957
7958/*
7959 * 6ch mode
7960 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007961static struct hda_verb alc883_sixstack_ch6_init[] = {
7962 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7963 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7964 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7965 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7966 { } /* end */
7967};
7968
7969/*
7970 * 8ch mode
7971 */
7972static struct hda_verb alc883_sixstack_ch8_init[] = {
7973 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7974 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7975 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7976 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7977 { } /* end */
7978};
7979
7980static struct hda_channel_mode alc883_sixstack_modes[2] = {
7981 { 6, alc883_sixstack_ch6_init },
7982 { 8, alc883_sixstack_ch8_init },
7983};
7984
7985
Linus Torvalds1da177e2005-04-16 15:20:36 -07007986/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7987 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7988 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007989static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007990 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007991 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007992 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007993 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007994 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7995 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007996 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7997 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007998 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007999 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8001 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8002 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008006 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8008 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008009 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008010 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008011 { } /* end */
8012};
8013
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008014/* Macbook Air 2,1 same control for HP and internal Speaker */
8015
8016static struct snd_kcontrol_new alc885_mba21_mixer[] = {
8017 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8018 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
8019 { }
8020};
8021
8022
Takashi Iwai87350ad2007-08-16 18:19:38 +02008023static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008024 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8025 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
8026 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8027 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
8028 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01008029 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8030 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8032 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008033 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
8034 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008035 { } /* end */
8036};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008037
8038static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008039 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8040 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8041 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8042 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8043 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8044 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10308045 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8046 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09308047 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8048 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8050 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008051 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
8052 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008053 { } /* end */
8054};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008055
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008056static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
8057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8058 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8059 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8060 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8061 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8062 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
8063 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8064 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
8065 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8066 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008067 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008068 { } /* end */
8069};
8070
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008071static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008072 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8073 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008074 { } /* end */
8075};
8076
8077
Kailang Yangbdd148a2007-05-08 15:19:08 +02008078static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8079 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8080 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8081 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8082 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8083 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8084 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8085 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008086 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008087 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008088 { } /* end */
8089};
8090
Kailang Yang272a5272007-05-14 11:00:38 +02008091static struct snd_kcontrol_new alc882_targa_mixer[] = {
8092 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8093 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008101 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008102 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008104 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008105 { } /* end */
8106};
8107
8108/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8109 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8110 */
8111static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8112 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8113 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8114 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8115 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8116 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8117 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8118 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8119 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8120 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8121 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008124 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008125 { } /* end */
8126};
8127
Takashi Iwai914759b2007-09-06 14:52:04 +02008128static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8129 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8130 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008137 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008139 { } /* end */
8140};
8141
Kailang Yangdf694da2005-12-05 19:42:22 +01008142static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8143 {
8144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8145 .name = "Channel Mode",
8146 .info = alc_ch_mode_info,
8147 .get = alc_ch_mode_get,
8148 .put = alc_ch_mode_put,
8149 },
8150 { } /* end */
8151};
8152
Takashi Iwai4953550a2009-06-30 15:28:30 +02008153static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008154 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008155 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8156 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008157 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008158 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8159 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008160 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008161 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8162 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008163 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008164 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8165 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008166
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008167 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008168 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008169 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008170 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008171 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008173 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008174 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008175 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008176 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008177 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008178 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008179 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008180 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008181 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008182 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008183 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008184 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008185 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8186 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008187 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008188 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8189 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008190 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008191 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8192 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8195 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008196 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008197 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008198
8199 /* FIXME: use matrix-type input source selection */
8200 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008201 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008202 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008203 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008205 /* ADC2: mute amp left and right */
8206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008207 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008208 /* ADC3: mute amp left and right */
8209 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008210 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008211
8212 { }
8213};
8214
Takashi Iwai4953550a2009-06-30 15:28:30 +02008215static struct hda_verb alc882_adc1_init_verbs[] = {
8216 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8218 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8219 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8220 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8221 /* ADC1: mute amp left and right */
8222 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8223 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8224 { }
8225};
8226
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008227static struct hda_verb alc882_eapd_verbs[] = {
8228 /* change to EAPD mode */
8229 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008230 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008231 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008232};
8233
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008234static struct hda_verb alc889_eapd_verbs[] = {
8235 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8236 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8237 { }
8238};
8239
Wu Fengguang6732bd02009-07-30 09:19:14 +02008240static struct hda_verb alc_hp15_unsol_verbs[] = {
8241 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8243 {}
8244};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008245
8246static struct hda_verb alc885_init_verbs[] = {
8247 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008250 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008253 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008254 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008256 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008257 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8258 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008259
8260 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008261 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8263 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8264 /* Front Pin: output 0 (0x0c) */
8265 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8266 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8267 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8268 /* Rear Pin: output 1 (0x0d) */
8269 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8271 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8272 /* CLFE Pin: output 2 (0x0e) */
8273 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8274 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8275 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8276 /* Side Pin: output 3 (0x0f) */
8277 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8278 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8279 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8280 /* Mic (rear) pin: input vref at 80% */
8281 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8282 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8283 /* Front Mic pin: input vref at 80% */
8284 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8285 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8286 /* Line In pin: input */
8287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8289
8290 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8291 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008292 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008293 /* Input mixer2 */
8294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008295 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008297 /* ADC2: mute amp left and right */
8298 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8299 /* ADC3: mute amp left and right */
8300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8301
8302 { }
8303};
8304
8305static struct hda_verb alc885_init_input_verbs[] = {
8306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8308 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8309 { }
8310};
8311
8312
8313/* Unmute Selector 24h and set the default input to front mic */
8314static struct hda_verb alc889_init_input_verbs[] = {
8315 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8317 { }
8318};
8319
8320
Takashi Iwai4953550a2009-06-30 15:28:30 +02008321#define alc883_init_verbs alc882_base_init_verbs
8322
Tobin Davis9102cd12006-12-15 10:02:12 +01008323/* Mac Pro test */
8324static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8325 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8326 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8327 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8328 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8329 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008330 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008331 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8332 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008333 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008334 { } /* end */
8335};
8336
8337static struct hda_verb alc882_macpro_init_verbs[] = {
8338 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8342 /* Front Pin: output 0 (0x0c) */
8343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8345 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8346 /* Front Mic pin: input vref at 80% */
8347 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8348 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8349 /* Speaker: output */
8350 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8351 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8352 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8353 /* Headphone output (output 0 - 0x0c) */
8354 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8356 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8357
8358 /* FIXME: use matrix-type input source selection */
8359 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8360 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8365 /* Input mixer2 */
8366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8370 /* Input mixer3 */
8371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8373 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8375 /* ADC1: mute amp left and right */
8376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8377 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8378 /* ADC2: mute amp left and right */
8379 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8380 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8381 /* ADC3: mute amp left and right */
8382 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8383 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8384
8385 { }
8386};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008387
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008388/* Macbook 5,1 */
8389static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008390 /* DACs */
8391 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8392 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8393 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8394 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008395 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008399 /* Surround mixer */
8400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8402 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8403 /* LFE mixer */
8404 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8407 /* HP mixer */
8408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8409 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8410 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8411 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008412 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8413 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008414 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8415 /* LFE Pin (0x0e) */
8416 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8417 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8418 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8419 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8421 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008422 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308423 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008424 /* Front Mic pin: input vref at 80% */
8425 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8427 /* Line In pin */
8428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8429 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8430
Alex Murrayb8f171e2010-06-14 12:08:43 +09308431 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8432 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8433 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008434 { }
8435};
8436
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008437/* Macmini 3,1 */
8438static struct hda_verb alc885_macmini3_init_verbs[] = {
8439 /* DACs */
8440 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8441 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8442 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8443 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8444 /* Front mixer */
8445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8448 /* Surround mixer */
8449 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8450 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8451 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8452 /* LFE mixer */
8453 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8454 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8455 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8456 /* HP mixer */
8457 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8458 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8459 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8460 /* Front Pin (0x0c) */
8461 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8462 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8463 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8464 /* LFE Pin (0x0e) */
8465 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8466 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8467 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8468 /* HP Pin (0x0f) */
8469 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8470 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8471 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8472 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8473 /* Line In pin */
8474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8476
8477 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8478 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8479 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8480 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8481 { }
8482};
8483
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008484
8485static struct hda_verb alc885_mba21_init_verbs[] = {
8486 /*Internal and HP Speaker Mixer*/
8487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8490 /*Internal Speaker Pin (0x0c)*/
8491 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8492 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8493 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8494 /* HP Pin: output 0 (0x0e) */
8495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8497 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8498 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8499 /* Line in (is hp when jack connected)*/
8500 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8501 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8502
8503 { }
8504 };
8505
8506
Takashi Iwai87350ad2007-08-16 18:19:38 +02008507/* Macbook Pro rev3 */
8508static struct hda_verb alc885_mbp3_init_verbs[] = {
8509 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8513 /* Rear mixer */
8514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8515 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8516 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008517 /* HP mixer */
8518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8519 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008521 /* Front Pin: output 0 (0x0c) */
8522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8524 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008525 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8528 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008529 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8530 /* Mic (rear) pin: input vref at 80% */
8531 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8532 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8533 /* Front Mic pin: input vref at 80% */
8534 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8535 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8536 /* Line In pin: use output 1 when in LineOut mode */
8537 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8538 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8539 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8540
8541 /* FIXME: use matrix-type input source selection */
8542 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8543 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8544 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8545 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8546 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8548 /* Input mixer2 */
8549 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8550 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8551 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8552 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8553 /* Input mixer3 */
8554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8556 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8557 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8558 /* ADC1: mute amp left and right */
8559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8560 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8561 /* ADC2: mute amp left and right */
8562 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8563 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8564 /* ADC3: mute amp left and right */
8565 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8566 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8567
8568 { }
8569};
8570
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008571/* iMac 9,1 */
8572static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008573 /* Internal Speaker Pin (0x0c) */
8574 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8576 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8577 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8578 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8579 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8580 /* HP Pin: Rear */
8581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8582 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8583 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8584 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8585 /* Line in Rear */
8586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8587 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8588 /* Front Mic pin: input vref at 80% */
8589 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8590 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008591 /* Rear mixer */
8592 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8593 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8594 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008595 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8599 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008600 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8601 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8602 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008604 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8606 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8607 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8608 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008609 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008614 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8616 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008617 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008618 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8619 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008620 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008621 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8622 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008623 { }
8624};
8625
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008626/* iMac 24 mixer. */
8627static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8628 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8629 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8630 { } /* end */
8631};
8632
8633/* iMac 24 init verbs. */
8634static struct hda_verb alc885_imac24_init_verbs[] = {
8635 /* Internal speakers: output 0 (0x0c) */
8636 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8637 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8638 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8639 /* Internal speakers: output 0 (0x0c) */
8640 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8642 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8643 /* Headphone: output 0 (0x0c) */
8644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8647 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8648 /* Front Mic: input vref at 80% */
8649 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8650 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8651 { }
8652};
8653
8654/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008655static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008656{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008657 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008658
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008659 spec->autocfg.hp_pins[0] = 0x14;
8660 spec->autocfg.speaker_pins[0] = 0x18;
8661 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008662 spec->automute = 1;
8663 spec->automute_mode = ALC_AUTOMUTE_AMP;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008664}
8665
Takashi Iwai9d54f082010-02-22 08:34:40 +01008666#define alc885_mb5_setup alc885_imac24_setup
8667#define alc885_macmini3_setup alc885_imac24_setup
8668
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008669/* Macbook Air 2,1 */
8670static void alc885_mba21_setup(struct hda_codec *codec)
8671{
8672 struct alc_spec *spec = codec->spec;
8673
8674 spec->autocfg.hp_pins[0] = 0x14;
8675 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02008676 spec->automute = 1;
8677 spec->automute_mode = ALC_AUTOMUTE_AMP;
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008678}
8679
8680
8681
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008682static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008683{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008684 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008685
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008686 spec->autocfg.hp_pins[0] = 0x15;
8687 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02008688 spec->automute = 1;
8689 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008690}
8691
Takashi Iwai9d54f082010-02-22 08:34:40 +01008692static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308693{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008694 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308695
Takashi Iwai9d54f082010-02-22 08:34:40 +01008696 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008697 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008698 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008699 spec->automute = 1;
8700 spec->automute_mode = ALC_AUTOMUTE_AMP;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008701}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008702
Kailang Yang272a5272007-05-14 11:00:38 +02008703static struct hda_verb alc882_targa_verbs[] = {
8704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8706
8707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8708 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008709
Kailang Yang272a5272007-05-14 11:00:38 +02008710 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8711 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8712 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8713
8714 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008715 { } /* end */
8716};
8717
8718/* toggle speaker-output according to the hp-jack state */
8719static void alc882_targa_automute(struct hda_codec *codec)
8720{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008721 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02008722 alc_hp_automute(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008723 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008724 spec->jack_present ? 1 : 3);
8725}
8726
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008727static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008728{
8729 struct alc_spec *spec = codec->spec;
8730
8731 spec->autocfg.hp_pins[0] = 0x14;
8732 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02008733 spec->automute = 1;
8734 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02008735}
8736
8737static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8738{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008739 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008740 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008741}
8742
8743static struct hda_verb alc882_asus_a7j_verbs[] = {
8744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8746
8747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008750
Kailang Yang272a5272007-05-14 11:00:38 +02008751 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8753 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8754
8755 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8756 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8757 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8758 { } /* end */
8759};
8760
Takashi Iwai914759b2007-09-06 14:52:04 +02008761static struct hda_verb alc882_asus_a7m_verbs[] = {
8762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8764
8765 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8766 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8767 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008768
Takashi Iwai914759b2007-09-06 14:52:04 +02008769 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8770 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8771 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8772
8773 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8774 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8775 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8776 { } /* end */
8777};
8778
Tobin Davis9102cd12006-12-15 10:02:12 +01008779static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8780{
8781 unsigned int gpiostate, gpiomask, gpiodir;
8782
8783 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8784 AC_VERB_GET_GPIO_DATA, 0);
8785
8786 if (!muted)
8787 gpiostate |= (1 << pin);
8788 else
8789 gpiostate &= ~(1 << pin);
8790
8791 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8792 AC_VERB_GET_GPIO_MASK, 0);
8793 gpiomask |= (1 << pin);
8794
8795 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8796 AC_VERB_GET_GPIO_DIRECTION, 0);
8797 gpiodir |= (1 << pin);
8798
8799
8800 snd_hda_codec_write(codec, codec->afg, 0,
8801 AC_VERB_SET_GPIO_MASK, gpiomask);
8802 snd_hda_codec_write(codec, codec->afg, 0,
8803 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8804
8805 msleep(1);
8806
8807 snd_hda_codec_write(codec, codec->afg, 0,
8808 AC_VERB_SET_GPIO_DATA, gpiostate);
8809}
8810
Takashi Iwai7debbe52007-08-16 15:01:03 +02008811/* set up GPIO at initialization */
8812static void alc885_macpro_init_hook(struct hda_codec *codec)
8813{
8814 alc882_gpio_mute(codec, 0, 0);
8815 alc882_gpio_mute(codec, 1, 0);
8816}
8817
8818/* set up GPIO and update auto-muting at initialization */
8819static void alc885_imac24_init_hook(struct hda_codec *codec)
8820{
8821 alc885_macpro_init_hook(codec);
Takashi Iwaid922b512011-04-28 12:18:53 +02008822 alc_hp_automute(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008823}
8824
Kailang Yangdf694da2005-12-05 19:42:22 +01008825/*
8826 * generic initialization of ADC, input mixers and output mixers
8827 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008828static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008829 /*
8830 * Unmute ADC0-2 and set the default input to mic-in
8831 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008832 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8833 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8834 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8836
Kailang Yangdf694da2005-12-05 19:42:22 +01008837 /*
8838 * Set up output mixers (0x0c - 0x0f)
8839 */
8840 /* set vol=0 to output mixers */
8841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8845 /* set up input amps for analog loopback */
8846 /* Amp Indices: DAC = 0, mixer = 1 */
8847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8849 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8854 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8855 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8856 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8857
8858 /* FIXME: use matrix-type input source selection */
8859 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008860 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008862 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008864 { }
8865};
8866
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008867/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8868static struct hda_verb alc889A_mb31_ch2_init[] = {
8869 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8870 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8871 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8872 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8873 { } /* end */
8874};
8875
8876/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8877static struct hda_verb alc889A_mb31_ch4_init[] = {
8878 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8879 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8880 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8881 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8882 { } /* end */
8883};
8884
8885/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8886static struct hda_verb alc889A_mb31_ch5_init[] = {
8887 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8889 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8890 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8891 { } /* end */
8892};
8893
8894/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8895static struct hda_verb alc889A_mb31_ch6_init[] = {
8896 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8897 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8898 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8899 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8900 { } /* end */
8901};
8902
8903static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8904 { 2, alc889A_mb31_ch2_init },
8905 { 4, alc889A_mb31_ch4_init },
8906 { 5, alc889A_mb31_ch5_init },
8907 { 6, alc889A_mb31_ch6_init },
8908};
8909
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008910static struct hda_verb alc883_medion_eapd_verbs[] = {
8911 /* eanable EAPD on medion laptop */
8912 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8913 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8914 { }
8915};
8916
Takashi Iwai4953550a2009-06-30 15:28:30 +02008917#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008918
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008919static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8921 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8922 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8923 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8924 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8925 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8926 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008928 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8930 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008931 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008932 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008933 { } /* end */
8934};
8935
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008936static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008937 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8938 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8939 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8940 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008942 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008944 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008945 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008946 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008947 { } /* end */
8948};
8949
Jiang zhefb97dc62008-03-06 11:07:11 +01008950static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8951 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8952 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8953 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8954 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8955 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008956 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008958 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008959 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008960 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008961 { } /* end */
8962};
8963
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008964static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8965 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8966 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8967 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8968 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8969 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8970 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8971 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008973 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8975 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008976 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008977 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008978 { } /* end */
8979};
8980
8981static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8982 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8983 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8984 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8985 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8986 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8987 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8988 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8989 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8993 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8994 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008996 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008999 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009001 { } /* end */
9002};
9003
Jiang zhe17bba1b2008-06-04 12:11:07 +02009004static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
9005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9006 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9007 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9008 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9009 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9010 HDA_OUTPUT),
9011 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9012 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9013 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9015 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9016 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9017 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9018 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9019 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009020 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9022 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009023 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009024 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009025 { } /* end */
9026};
9027
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009028static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
9029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9030 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9032 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9033 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9034 HDA_OUTPUT),
9035 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9036 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9037 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9038 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9039 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
9040 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9041 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9042 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009044 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
9046 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009047 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009048 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9049 { } /* end */
9050};
9051
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009052static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02009053 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009054 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009055 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009056 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009057 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9058 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009059 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9060 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009061 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9062 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9063 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9064 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9065 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009067 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9069 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009070 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009071 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009072 { } /* end */
9073};
9074
Sasha Alexandrc2592492009-06-16 14:52:54 -04009075static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009076 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009077 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009079 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009080 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9081 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9082 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9083 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9084 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9085 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9086 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9087 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9088 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9089 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9090 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009091 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009093 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009094};
Kailang Yangccc656c2006-10-17 12:32:26 +02009095
Sasha Alexandrc2592492009-06-16 14:52:54 -04009096static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009097 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009098 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009099 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009100 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9102 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009104 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009106 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009107 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009108 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009109 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009110};
Kailang Yangccc656c2006-10-17 12:32:26 +02009111
Takashi Iwaib99dba32009-09-17 18:23:00 +02009112static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9113 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9114 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009115 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009116 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009117 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009118 { } /* end */
9119};
9120
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009121static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9122 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9123 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009124 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9125 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009128 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009130 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009131};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009132
Kailang Yang272a5272007-05-14 11:00:38 +02009133static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9134 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9135 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9137 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9138 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9140 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009141 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9142 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009143 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009144};
Kailang Yang272a5272007-05-14 11:00:38 +02009145
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009146static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9148 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9149 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9150 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9151 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9152 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9153 { } /* end */
9154};
9155
9156static struct hda_verb alc883_medion_wim2160_verbs[] = {
9157 /* Unmute front mixer */
9158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9160
9161 /* Set speaker pin to front mixer */
9162 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9163
9164 /* Init headphone pin */
9165 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9166 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9167 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9168 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9169
9170 { } /* end */
9171};
9172
9173/* toggle speaker-output according to the hp-jack state */
9174static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9175{
9176 struct alc_spec *spec = codec->spec;
9177
9178 spec->autocfg.hp_pins[0] = 0x1a;
9179 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009180 spec->automute = 1;
9181 spec->automute_mode = ALC_AUTOMUTE_AMP;
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009182}
9183
Tobin Davis2880a862007-08-07 11:50:26 +02009184static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009185 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9186 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009188 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9189 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009191 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009193 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009194};
Tobin Davis2880a862007-08-07 11:50:26 +02009195
Tony Vroond2fd4b02009-06-21 00:40:10 +01009196static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9197 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009198 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009199 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9200 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009204 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9206 { } /* end */
9207};
9208
Kailang Yange2757d52008-08-26 13:17:46 +02009209static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9210 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9211 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9212 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9213 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9214 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9215 0x0d, 1, 0x0, HDA_OUTPUT),
9216 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9217 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9218 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9219 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9220 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009221 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9222 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9223 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9224 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009226 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009227 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9228 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009229 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009230 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009231 { } /* end */
9232};
9233
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009234static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9235 /* Output mixers */
9236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9237 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9238 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9239 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9240 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9241 HDA_OUTPUT),
9242 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9243 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9244 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9245 /* Output switches */
9246 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9247 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9248 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9249 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009250 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9251 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009252 /* Input mixers */
9253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9255 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9256 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9257 { } /* end */
9258};
9259
Guido Günther3e1647c2009-06-05 00:47:26 +02009260static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9261 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9262 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9263 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009265 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9267 { } /* end */
9268};
9269
Kailang Yange2757d52008-08-26 13:17:46 +02009270static struct hda_bind_ctls alc883_bind_cap_vol = {
9271 .ops = &snd_hda_bind_vol,
9272 .values = {
9273 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9274 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9275 0
9276 },
9277};
9278
9279static struct hda_bind_ctls alc883_bind_cap_switch = {
9280 .ops = &snd_hda_bind_sw,
9281 .values = {
9282 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9283 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9284 0
9285 },
9286};
9287
9288static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9289 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9290 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009295 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009297 { } /* end */
9298};
9299
9300static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009301 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9302 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9303 {
9304 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9305 /* .name = "Capture Source", */
9306 .name = "Input Source",
9307 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009308 .info = alc_mux_enum_info,
9309 .get = alc_mux_enum_get,
9310 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009311 },
9312 { } /* end */
9313};
9314
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009315static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9316 {
9317 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9318 .name = "Channel Mode",
9319 .info = alc_ch_mode_info,
9320 .get = alc_ch_mode_get,
9321 .put = alc_ch_mode_put,
9322 },
9323 { } /* end */
9324};
9325
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009326/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009327static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009328{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009329 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009330
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009331 spec->autocfg.hp_pins[0] = 0x15;
9332 spec->autocfg.speaker_pins[0] = 0x14;
9333 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009334 spec->automute = 1;
9335 spec->automute_mode = ALC_AUTOMUTE_AMP;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009336}
9337
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009338static struct hda_verb alc883_mitac_verbs[] = {
9339 /* HP */
9340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9342 /* Subwoofer */
9343 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9344 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9345
9346 /* enable unsolicited event */
9347 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9348 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9349
9350 { } /* end */
9351};
9352
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309353static struct hda_verb alc883_clevo_m540r_verbs[] = {
9354 /* HP */
9355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9356 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9357 /* Int speaker */
9358 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9359
9360 /* enable unsolicited event */
9361 /*
9362 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9363 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9364 */
9365
9366 { } /* end */
9367};
9368
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009369static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009370 /* HP */
9371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9372 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9373 /* Int speaker */
9374 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9376
9377 /* enable unsolicited event */
9378 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009379 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009380
9381 { } /* end */
9382};
9383
Jiang zhefb97dc62008-03-06 11:07:11 +01009384static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9385 /* HP */
9386 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9388 /* Subwoofer */
9389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9391
9392 /* enable unsolicited event */
9393 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9394
9395 { } /* end */
9396};
9397
Sasha Alexandrc2592492009-06-16 14:52:54 -04009398static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9400 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9401
9402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9403 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009404
David Heidelberger64a8be72009-06-08 16:15:18 +02009405/* Connect Line-Out side jack (SPDIF) to Side */
9406 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9407 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9408 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9409/* Connect Mic jack to CLFE */
9410 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9412 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9413/* Connect Line-in jack to Surround */
9414 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9415 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9416 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9417/* Connect HP out jack to Front */
9418 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9419 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9420 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009421
9422 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009423
9424 { } /* end */
9425};
9426
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009427static struct hda_verb alc883_lenovo_101e_verbs[] = {
9428 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9429 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9430 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9431 { } /* end */
9432};
9433
Kailang Yang272a5272007-05-14 11:00:38 +02009434static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9435 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9436 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9437 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9439 { } /* end */
9440};
9441
9442static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9443 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9444 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9445 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9446 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9447 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9448 { } /* end */
9449};
9450
Kailang Yang189609a2007-08-20 11:31:23 +02009451static struct hda_verb alc883_haier_w66_verbs[] = {
9452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9454
9455 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9456
9457 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9458 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9459 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9460 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9461 { } /* end */
9462};
9463
Kailang Yange2757d52008-08-26 13:17:46 +02009464static struct hda_verb alc888_lenovo_sky_verbs[] = {
9465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9469 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9470 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9471 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9472 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9473 { } /* end */
9474};
9475
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009476static struct hda_verb alc888_6st_dell_verbs[] = {
9477 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9478 { }
9479};
9480
Guido Günther3e1647c2009-06-05 00:47:26 +02009481static struct hda_verb alc883_vaiott_verbs[] = {
9482 /* HP */
9483 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9484 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9485
9486 /* enable unsolicited event */
9487 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9488
9489 { } /* end */
9490};
9491
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009492static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009493{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009494 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009495
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009496 spec->autocfg.hp_pins[0] = 0x1b;
9497 spec->autocfg.speaker_pins[0] = 0x14;
9498 spec->autocfg.speaker_pins[1] = 0x16;
9499 spec->autocfg.speaker_pins[2] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02009500 spec->automute = 1;
9501 spec->automute_mode = ALC_AUTOMUTE_AMP;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009502}
9503
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009504static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009505 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009506 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9507 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009508 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009509 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009510};
9511
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009512/*
9513 * 2ch mode
9514 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009515static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009516 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9517 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9518 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9519 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009520 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009521};
9522
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009523/*
9524 * 4ch mode
9525 */
9526static struct hda_verb alc888_3st_hp_4ch_init[] = {
9527 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9528 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9529 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9530 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9531 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9532 { } /* end */
9533};
9534
9535/*
9536 * 6ch mode
9537 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009538static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009539 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9540 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009541 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009542 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9543 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009544 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9545 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009546};
9547
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009548static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009549 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009550 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009551 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009552};
9553
Kailang Yang272a5272007-05-14 11:00:38 +02009554/* toggle front-jack and RCA according to the hp-jack state */
9555static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9556{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009557 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009558
Takashi Iwai47fd8302007-08-10 17:11:07 +02009559 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9560 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9561 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9562 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009563}
9564
9565/* toggle RCA according to the front-jack state */
9566static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9567{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009568 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009569
Takashi Iwai47fd8302007-08-10 17:11:07 +02009570 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9571 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009572}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009573
Kailang Yang272a5272007-05-14 11:00:38 +02009574static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9575 unsigned int res)
9576{
9577 if ((res >> 26) == ALC880_HP_EVENT)
9578 alc888_lenovo_ms7195_front_automute(codec);
9579 if ((res >> 26) == ALC880_FRONT_EVENT)
9580 alc888_lenovo_ms7195_rca_automute(codec);
9581}
9582
Kailang Yang272a5272007-05-14 11:00:38 +02009583/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009584static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009585{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009586 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009587
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009588 spec->autocfg.hp_pins[0] = 0x14;
9589 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009590 spec->automute = 1;
9591 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02009592}
9593
Kailang Yangccc656c2006-10-17 12:32:26 +02009594/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009595#define alc883_targa_init_hook alc882_targa_init_hook
9596#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009597
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009598static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009599{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009600 struct alc_spec *spec = codec->spec;
9601
9602 spec->autocfg.hp_pins[0] = 0x15;
9603 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02009604 spec->automute = 1;
9605 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009606}
9607
9608static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9609{
Takashi Iwaid922b512011-04-28 12:18:53 +02009610 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009611 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009612}
9613
9614static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009615 unsigned int res)
9616{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009617 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009618 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009619 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009620 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009621 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02009622 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009623 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009624 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009625}
9626
Jiang zhefb97dc62008-03-06 11:07:11 +01009627/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009628static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009629{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009630 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009631
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009632 spec->autocfg.hp_pins[0] = 0x14;
9633 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009634 spec->automute = 1;
9635 spec->automute_mode = ALC_AUTOMUTE_AMP;
Jiang zhefb97dc62008-03-06 11:07:11 +01009636}
9637
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009638static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009639{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009640 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009641
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009642 spec->autocfg.hp_pins[0] = 0x1b;
9643 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02009644 spec->automute = 1;
9645 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang189609a2007-08-20 11:31:23 +02009646}
9647
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009648static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9649{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009650 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009651
Takashi Iwai47fd8302007-08-10 17:11:07 +02009652 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9653 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009654}
9655
9656static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9657{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009658 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009659
Takashi Iwai47fd8302007-08-10 17:11:07 +02009660 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9661 HDA_AMP_MUTE, bits);
9662 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9663 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009664}
9665
9666static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9667 unsigned int res)
9668{
9669 if ((res >> 26) == ALC880_HP_EVENT)
9670 alc883_lenovo_101e_all_automute(codec);
9671 if ((res >> 26) == ALC880_FRONT_EVENT)
9672 alc883_lenovo_101e_ispeaker_automute(codec);
9673}
9674
Takashi Iwai676a9b52007-08-16 15:23:35 +02009675/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009676static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009677{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009678 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009679
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009680 spec->autocfg.hp_pins[0] = 0x14;
9681 spec->autocfg.speaker_pins[0] = 0x15;
9682 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02009683 spec->automute = 1;
9684 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009685}
9686
Kailang Yangd1a991a2007-08-15 16:21:59 +02009687static struct hda_verb alc883_acer_eapd_verbs[] = {
9688 /* HP Pin: output 0 (0x0c) */
9689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9691 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9692 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009693 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9694 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009695 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009696 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9697 /* eanable EAPD on medion laptop */
9698 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9699 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009700 /* enable unsolicited event */
9701 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009702 { }
9703};
9704
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009705static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009706{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009707 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009708
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009709 spec->autocfg.hp_pins[0] = 0x1b;
9710 spec->autocfg.speaker_pins[0] = 0x14;
9711 spec->autocfg.speaker_pins[1] = 0x15;
9712 spec->autocfg.speaker_pins[2] = 0x16;
9713 spec->autocfg.speaker_pins[3] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009714 spec->automute = 1;
9715 spec->automute_mode = ALC_AUTOMUTE_AMP;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009716}
9717
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009718static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009719{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009720 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009721
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009722 spec->autocfg.hp_pins[0] = 0x1b;
9723 spec->autocfg.speaker_pins[0] = 0x14;
9724 spec->autocfg.speaker_pins[1] = 0x15;
9725 spec->autocfg.speaker_pins[2] = 0x16;
9726 spec->autocfg.speaker_pins[3] = 0x17;
9727 spec->autocfg.speaker_pins[4] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02009728 spec->automute = 1;
9729 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009730}
9731
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009732static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009733{
9734 struct alc_spec *spec = codec->spec;
9735
9736 spec->autocfg.hp_pins[0] = 0x15;
9737 spec->autocfg.speaker_pins[0] = 0x14;
9738 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009739 spec->automute = 1;
9740 spec->automute_mode = ALC_AUTOMUTE_AMP;
Guido Günther3e1647c2009-06-05 00:47:26 +02009741}
9742
Kailang Yange2757d52008-08-26 13:17:46 +02009743static struct hda_verb alc888_asus_m90v_verbs[] = {
9744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9745 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9746 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9747 /* enable unsolicited event */
9748 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9749 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9750 { } /* end */
9751};
9752
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009753static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009754{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009755 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009756
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009757 spec->autocfg.hp_pins[0] = 0x1b;
9758 spec->autocfg.speaker_pins[0] = 0x14;
9759 spec->autocfg.speaker_pins[1] = 0x15;
9760 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009761 spec->ext_mic.pin = 0x18;
9762 spec->int_mic.pin = 0x19;
9763 spec->ext_mic.mux_idx = 0;
9764 spec->int_mic.mux_idx = 1;
9765 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +02009766 spec->automute = 1;
9767 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009768}
9769
9770static struct hda_verb alc888_asus_eee1601_verbs[] = {
9771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9772 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9774 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9775 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9776 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9777 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9778 /* enable unsolicited event */
9779 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9780 { } /* end */
9781};
9782
Kailang Yange2757d52008-08-26 13:17:46 +02009783static void alc883_eee1601_inithook(struct hda_codec *codec)
9784{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009785 struct alc_spec *spec = codec->spec;
9786
9787 spec->autocfg.hp_pins[0] = 0x14;
9788 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02009789 alc_hp_automute(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009790}
9791
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009792static struct hda_verb alc889A_mb31_verbs[] = {
9793 /* Init rear pin (used as headphone output) */
9794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9795 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9796 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9797 /* Init line pin (used as output in 4ch and 6ch mode) */
9798 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9799 /* Init line 2 pin (used as headphone out by default) */
9800 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9801 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9802 { } /* end */
9803};
9804
9805/* Mute speakers according to the headphone jack state */
9806static void alc889A_mb31_automute(struct hda_codec *codec)
9807{
9808 unsigned int present;
9809
9810 /* Mute only in 2ch or 4ch mode */
9811 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9812 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009813 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009814 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9815 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9816 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9817 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9818 }
9819}
9820
9821static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9822{
9823 if ((res >> 26) == ALC880_HP_EVENT)
9824 alc889A_mb31_automute(codec);
9825}
9826
Takashi Iwai4953550a2009-06-30 15:28:30 +02009827
Takashi Iwaicb53c622007-08-10 17:21:45 +02009828#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009829#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009830#endif
9831
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009832/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009833#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9834#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9835#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9836#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9837
9838static hda_nid_t alc883_slave_dig_outs[] = {
9839 ALC1200_DIGOUT_NID, 0,
9840};
9841
9842static hda_nid_t alc1200_slave_dig_outs[] = {
9843 ALC883_DIGOUT_NID, 0,
9844};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009845
9846/*
9847 * configuration and preset
9848 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009849static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009850 [ALC882_3ST_DIG] = "3stack-dig",
9851 [ALC882_6ST_DIG] = "6stack-dig",
9852 [ALC882_ARIMA] = "arima",
9853 [ALC882_W2JC] = "w2jc",
9854 [ALC882_TARGA] = "targa",
9855 [ALC882_ASUS_A7J] = "asus-a7j",
9856 [ALC882_ASUS_A7M] = "asus-a7m",
9857 [ALC885_MACPRO] = "macpro",
9858 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009859 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009860 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009861 [ALC885_MBP3] = "mbp3",
9862 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009863 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009864 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009865 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9866 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009867 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009868 [ALC883_TARGA_DIG] = "targa-dig",
9869 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009870 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009871 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009872 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009873 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009874 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009875 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009876 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009877 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009878 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009879 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009880 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009881 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9882 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009883 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009884 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009885 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009886 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009887 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309888 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009889 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009890 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009891 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009892 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009893 [ALC889A_INTEL] = "intel-alc889a",
9894 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009895 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009896 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009897 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009898 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009899};
9900
Takashi Iwai4953550a2009-06-30 15:28:30 +02009901static struct snd_pci_quirk alc882_cfg_tbl[] = {
9902 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9903
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009904 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009905 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009906 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009907 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9908 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009909 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009910 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9911 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009912 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009913 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009914 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9915 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009916 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9917 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009918 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9919 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009920 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009921 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009922 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009923 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009924 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9925 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009926 /* default Acer -- disabled as it causes more problems.
9927 * model=auto should work fine now
9928 */
9929 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009930
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009931 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009932
Tobin Davisfebe3372007-06-12 11:27:46 +02009933 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009934 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9935 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009936 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009937 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009938 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009939
9940 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9941 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9942 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009943 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009944 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9945 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9946 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009947 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009948 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009949 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009950 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009951
9952 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009953 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009954 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009955 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009956 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9957 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009958 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009959 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009960
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009961 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9962 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9963 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009964 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009965 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009966 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009967 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009968 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009969 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9970 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9971 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9972 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9973 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9974 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009975 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009976 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9977 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9978 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009979 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009980 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009981 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9982 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009983 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009984 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009985 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009986 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009987 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009988 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009989 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009990 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009991 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009992
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009993 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009994 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009995 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9996 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309997 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009998 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009999 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010000 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010001 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +020010002 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +010010003 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +020010004 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010005 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +020010006 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +020010007 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010008 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
10009 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +020010010 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +010010011 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +010010012 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +020010013 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010014
Jiang zhe17bba1b2008-06-04 12:11:07 +020010015 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
10016 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +110010017 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010018 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
10019 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
10020 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -040010021 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010022
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010023 {}
10024};
10025
Takashi Iwai4953550a2009-06-30 15:28:30 +020010026/* codec SSID table for Intel Mac */
10027static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
10028 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
10029 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
10030 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
10031 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
10032 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
10033 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
10034 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -040010035 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -070010036 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -070010037 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -070010038 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010039 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
10040 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
10041 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010042 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010043 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +100010044 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010045 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
10046 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +020010047 */
10048 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010049 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010050 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010051 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010052};
10053
Takashi Iwai4953550a2009-06-30 15:28:30 +020010054static struct alc_config_preset alc882_presets[] = {
10055 [ALC882_3ST_DIG] = {
10056 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010057 .init_verbs = { alc882_base_init_verbs,
10058 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010059 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10060 .dac_nids = alc882_dac_nids,
10061 .dig_out_nid = ALC882_DIGOUT_NID,
10062 .dig_in_nid = ALC882_DIGIN_NID,
10063 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10064 .channel_mode = alc882_ch_modes,
10065 .need_dac_fix = 1,
10066 .input_mux = &alc882_capture_source,
10067 },
10068 [ALC882_6ST_DIG] = {
10069 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010070 .init_verbs = { alc882_base_init_verbs,
10071 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010072 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10073 .dac_nids = alc882_dac_nids,
10074 .dig_out_nid = ALC882_DIGOUT_NID,
10075 .dig_in_nid = ALC882_DIGIN_NID,
10076 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10077 .channel_mode = alc882_sixstack_modes,
10078 .input_mux = &alc882_capture_source,
10079 },
10080 [ALC882_ARIMA] = {
10081 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010082 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10083 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010084 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10085 .dac_nids = alc882_dac_nids,
10086 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10087 .channel_mode = alc882_sixstack_modes,
10088 .input_mux = &alc882_capture_source,
10089 },
10090 [ALC882_W2JC] = {
10091 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010092 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10093 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010094 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10095 .dac_nids = alc882_dac_nids,
10096 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10097 .channel_mode = alc880_threestack_modes,
10098 .need_dac_fix = 1,
10099 .input_mux = &alc882_capture_source,
10100 .dig_out_nid = ALC882_DIGOUT_NID,
10101 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010102 [ALC885_MBA21] = {
10103 .mixers = { alc885_mba21_mixer },
10104 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
10105 .num_dacs = 2,
10106 .dac_nids = alc882_dac_nids,
10107 .channel_mode = alc885_mba21_ch_modes,
10108 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10109 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010110 .unsol_event = alc_sku_unsol_event,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010111 .setup = alc885_mba21_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010112 .init_hook = alc_hp_automute,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010113 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010114 [ALC885_MBP3] = {
10115 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10116 .init_verbs = { alc885_mbp3_init_verbs,
10117 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010118 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010119 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010120 .hp_nid = 0x04,
10121 .channel_mode = alc885_mbp_4ch_modes,
10122 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010123 .input_mux = &alc882_capture_source,
10124 .dig_out_nid = ALC882_DIGOUT_NID,
10125 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010126 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010127 .setup = alc885_mbp3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010128 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010129 },
10130 [ALC885_MB5] = {
10131 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10132 .init_verbs = { alc885_mb5_init_verbs,
10133 alc880_gpio1_init_verbs },
10134 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10135 .dac_nids = alc882_dac_nids,
10136 .channel_mode = alc885_mb5_6ch_modes,
10137 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10138 .input_mux = &mb5_capture_source,
10139 .dig_out_nid = ALC882_DIGOUT_NID,
10140 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010141 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010142 .setup = alc885_mb5_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010143 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010144 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010145 [ALC885_MACMINI3] = {
10146 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10147 .init_verbs = { alc885_macmini3_init_verbs,
10148 alc880_gpio1_init_verbs },
10149 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10150 .dac_nids = alc882_dac_nids,
10151 .channel_mode = alc885_macmini3_6ch_modes,
10152 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10153 .input_mux = &macmini3_capture_source,
10154 .dig_out_nid = ALC882_DIGOUT_NID,
10155 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010156 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010157 .setup = alc885_macmini3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010158 .init_hook = alc_hp_automute,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010159 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010160 [ALC885_MACPRO] = {
10161 .mixers = { alc882_macpro_mixer },
10162 .init_verbs = { alc882_macpro_init_verbs },
10163 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10164 .dac_nids = alc882_dac_nids,
10165 .dig_out_nid = ALC882_DIGOUT_NID,
10166 .dig_in_nid = ALC882_DIGIN_NID,
10167 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10168 .channel_mode = alc882_ch_modes,
10169 .input_mux = &alc882_capture_source,
10170 .init_hook = alc885_macpro_init_hook,
10171 },
10172 [ALC885_IMAC24] = {
10173 .mixers = { alc885_imac24_mixer },
10174 .init_verbs = { alc885_imac24_init_verbs },
10175 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10176 .dac_nids = alc882_dac_nids,
10177 .dig_out_nid = ALC882_DIGOUT_NID,
10178 .dig_in_nid = ALC882_DIGIN_NID,
10179 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10180 .channel_mode = alc882_ch_modes,
10181 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010182 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010183 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010184 .init_hook = alc885_imac24_init_hook,
10185 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010186 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010187 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010188 .init_verbs = { alc885_imac91_init_verbs,
10189 alc880_gpio1_init_verbs },
10190 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10191 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010192 .channel_mode = alc885_mba21_ch_modes,
10193 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10194 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010195 .dig_out_nid = ALC882_DIGOUT_NID,
10196 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010197 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010198 .setup = alc885_imac91_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010199 .init_hook = alc_hp_automute,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010200 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010201 [ALC882_TARGA] = {
10202 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010203 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010204 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010205 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10206 .dac_nids = alc882_dac_nids,
10207 .dig_out_nid = ALC882_DIGOUT_NID,
10208 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10209 .adc_nids = alc882_adc_nids,
10210 .capsrc_nids = alc882_capsrc_nids,
10211 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10212 .channel_mode = alc882_3ST_6ch_modes,
10213 .need_dac_fix = 1,
10214 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010215 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010216 .setup = alc882_targa_setup,
10217 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010218 },
10219 [ALC882_ASUS_A7J] = {
10220 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010221 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10222 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010223 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10224 .dac_nids = alc882_dac_nids,
10225 .dig_out_nid = ALC882_DIGOUT_NID,
10226 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10227 .adc_nids = alc882_adc_nids,
10228 .capsrc_nids = alc882_capsrc_nids,
10229 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10230 .channel_mode = alc882_3ST_6ch_modes,
10231 .need_dac_fix = 1,
10232 .input_mux = &alc882_capture_source,
10233 },
10234 [ALC882_ASUS_A7M] = {
10235 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010236 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10237 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010238 alc882_asus_a7m_verbs },
10239 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10240 .dac_nids = alc882_dac_nids,
10241 .dig_out_nid = ALC882_DIGOUT_NID,
10242 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10243 .channel_mode = alc880_threestack_modes,
10244 .need_dac_fix = 1,
10245 .input_mux = &alc882_capture_source,
10246 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010247 [ALC883_3ST_2ch_DIG] = {
10248 .mixers = { alc883_3ST_2ch_mixer },
10249 .init_verbs = { alc883_init_verbs },
10250 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10251 .dac_nids = alc883_dac_nids,
10252 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010253 .dig_in_nid = ALC883_DIGIN_NID,
10254 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10255 .channel_mode = alc883_3ST_2ch_modes,
10256 .input_mux = &alc883_capture_source,
10257 },
10258 [ALC883_3ST_6ch_DIG] = {
10259 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10260 .init_verbs = { alc883_init_verbs },
10261 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10262 .dac_nids = alc883_dac_nids,
10263 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010264 .dig_in_nid = ALC883_DIGIN_NID,
10265 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10266 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010267 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010268 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010269 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010270 [ALC883_3ST_6ch] = {
10271 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10272 .init_verbs = { alc883_init_verbs },
10273 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10274 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010275 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10276 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010277 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010278 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010279 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010280 [ALC883_3ST_6ch_INTEL] = {
10281 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10282 .init_verbs = { alc883_init_verbs },
10283 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10284 .dac_nids = alc883_dac_nids,
10285 .dig_out_nid = ALC883_DIGOUT_NID,
10286 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010287 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010288 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10289 .channel_mode = alc883_3ST_6ch_intel_modes,
10290 .need_dac_fix = 1,
10291 .input_mux = &alc883_3stack_6ch_intel,
10292 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010293 [ALC889A_INTEL] = {
10294 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010295 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10296 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010297 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10298 .dac_nids = alc883_dac_nids,
10299 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10300 .adc_nids = alc889_adc_nids,
10301 .dig_out_nid = ALC883_DIGOUT_NID,
10302 .dig_in_nid = ALC883_DIGIN_NID,
10303 .slave_dig_outs = alc883_slave_dig_outs,
10304 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10305 .channel_mode = alc889_8ch_intel_modes,
10306 .capsrc_nids = alc889_capsrc_nids,
10307 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010308 .setup = alc889_automute_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010309 .init_hook = alc_hp_automute,
10310 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010311 .need_dac_fix = 1,
10312 },
10313 [ALC889_INTEL] = {
10314 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10315 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010316 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010317 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10318 .dac_nids = alc883_dac_nids,
10319 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10320 .adc_nids = alc889_adc_nids,
10321 .dig_out_nid = ALC883_DIGOUT_NID,
10322 .dig_in_nid = ALC883_DIGIN_NID,
10323 .slave_dig_outs = alc883_slave_dig_outs,
10324 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10325 .channel_mode = alc889_8ch_intel_modes,
10326 .capsrc_nids = alc889_capsrc_nids,
10327 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010328 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010329 .init_hook = alc889_intel_init_hook,
Takashi Iwaid922b512011-04-28 12:18:53 +020010330 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010331 .need_dac_fix = 1,
10332 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010333 [ALC883_6ST_DIG] = {
10334 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10335 .init_verbs = { alc883_init_verbs },
10336 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10337 .dac_nids = alc883_dac_nids,
10338 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010339 .dig_in_nid = ALC883_DIGIN_NID,
10340 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10341 .channel_mode = alc883_sixstack_modes,
10342 .input_mux = &alc883_capture_source,
10343 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010344 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010345 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010346 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10347 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010348 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10349 .dac_nids = alc883_dac_nids,
10350 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010351 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10352 .channel_mode = alc883_3ST_6ch_modes,
10353 .need_dac_fix = 1,
10354 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010355 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010356 .setup = alc882_targa_setup,
10357 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010358 },
10359 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010360 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010361 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10362 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010363 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10364 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010365 .adc_nids = alc883_adc_nids_alt,
10366 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010367 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010368 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010369 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10370 .channel_mode = alc883_3ST_2ch_modes,
10371 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010372 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010373 .setup = alc882_targa_setup,
10374 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010375 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010376 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010377 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10378 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010379 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010380 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010381 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10382 .dac_nids = alc883_dac_nids,
10383 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10384 .adc_nids = alc883_adc_nids_rev,
10385 .capsrc_nids = alc883_capsrc_nids_rev,
10386 .dig_out_nid = ALC883_DIGOUT_NID,
10387 .dig_in_nid = ALC883_DIGIN_NID,
10388 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10389 .channel_mode = alc883_4ST_8ch_modes,
10390 .need_dac_fix = 1,
10391 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010392 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010393 .setup = alc882_targa_setup,
10394 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010395 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010396 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010397 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010398 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10399 * and the headphone jack. Turn this on and rely on the
10400 * standard mute methods whenever the user wants to turn
10401 * these outputs off.
10402 */
10403 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10404 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10405 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010406 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10407 .channel_mode = alc883_3ST_2ch_modes,
10408 .input_mux = &alc883_capture_source,
10409 },
Tobin Davis2880a862007-08-07 11:50:26 +020010410 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010411 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010412 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010413 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10414 .dac_nids = alc883_dac_nids,
10415 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010416 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10417 .channel_mode = alc883_3ST_2ch_modes,
10418 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010419 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010420 .setup = alc883_acer_aspire_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010421 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010422 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010423 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010424 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010425 alc883_chmode_mixer },
10426 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10427 alc888_acer_aspire_4930g_verbs },
10428 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10429 .dac_nids = alc883_dac_nids,
10430 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10431 .adc_nids = alc883_adc_nids_rev,
10432 .capsrc_nids = alc883_capsrc_nids_rev,
10433 .dig_out_nid = ALC883_DIGOUT_NID,
10434 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10435 .channel_mode = alc883_3ST_6ch_modes,
10436 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010437 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010438 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010439 ARRAY_SIZE(alc888_2_capture_sources),
10440 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010441 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010442 .setup = alc888_acer_aspire_4930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010443 .init_hook = alc_hp_automute,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010444 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010445 [ALC888_ACER_ASPIRE_6530G] = {
10446 .mixers = { alc888_acer_aspire_6530_mixer },
10447 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10448 alc888_acer_aspire_6530g_verbs },
10449 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10450 .dac_nids = alc883_dac_nids,
10451 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10452 .adc_nids = alc883_adc_nids_rev,
10453 .capsrc_nids = alc883_capsrc_nids_rev,
10454 .dig_out_nid = ALC883_DIGOUT_NID,
10455 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10456 .channel_mode = alc883_3ST_2ch_modes,
10457 .num_mux_defs =
10458 ARRAY_SIZE(alc888_2_capture_sources),
10459 .input_mux = alc888_acer_aspire_6530_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010460 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010461 .setup = alc888_acer_aspire_6530g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010462 .init_hook = alc_hp_automute,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010463 },
Hector Martin3b315d72009-06-02 10:54:19 +020010464 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010465 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010466 alc883_chmode_mixer },
10467 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010468 alc889_acer_aspire_8930g_verbs,
10469 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010470 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10471 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010472 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10473 .adc_nids = alc889_adc_nids,
10474 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010475 .dig_out_nid = ALC883_DIGOUT_NID,
10476 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10477 .channel_mode = alc883_3ST_6ch_modes,
10478 .need_dac_fix = 1,
10479 .const_channel_count = 6,
10480 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010481 ARRAY_SIZE(alc889_capture_sources),
10482 .input_mux = alc889_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010483 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010484 .setup = alc889_acer_aspire_8930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010485 .init_hook = alc_hp_automute,
Hector Martinf5de24b2009-12-20 22:51:31 +010010486#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010487 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010488#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010489 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010490 [ALC888_ACER_ASPIRE_7730G] = {
10491 .mixers = { alc883_3ST_6ch_mixer,
10492 alc883_chmode_mixer },
10493 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10494 alc888_acer_aspire_7730G_verbs },
10495 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10496 .dac_nids = alc883_dac_nids,
10497 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10498 .adc_nids = alc883_adc_nids_rev,
10499 .capsrc_nids = alc883_capsrc_nids_rev,
10500 .dig_out_nid = ALC883_DIGOUT_NID,
10501 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10502 .channel_mode = alc883_3ST_6ch_modes,
10503 .need_dac_fix = 1,
10504 .const_channel_count = 6,
10505 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010506 .unsol_event = alc_sku_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010507 .setup = alc888_acer_aspire_7730g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010508 .init_hook = alc_hp_automute,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010509 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010510 [ALC883_MEDION] = {
10511 .mixers = { alc883_fivestack_mixer,
10512 alc883_chmode_mixer },
10513 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010514 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010515 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10516 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010517 .adc_nids = alc883_adc_nids_alt,
10518 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010519 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010520 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10521 .channel_mode = alc883_sixstack_modes,
10522 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010523 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010524 [ALC883_MEDION_WIM2160] = {
10525 .mixers = { alc883_medion_wim2160_mixer },
10526 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10527 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10528 .dac_nids = alc883_dac_nids,
10529 .dig_out_nid = ALC883_DIGOUT_NID,
10530 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10531 .adc_nids = alc883_adc_nids,
10532 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10533 .channel_mode = alc883_3ST_2ch_modes,
10534 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010535 .unsol_event = alc_sku_unsol_event,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010536 .setup = alc883_medion_wim2160_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010537 .init_hook = alc_hp_automute,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010538 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010539 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010540 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010541 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10542 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10543 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010544 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10545 .channel_mode = alc883_3ST_2ch_modes,
10546 .input_mux = &alc883_capture_source,
10547 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010548 [ALC883_CLEVO_M540R] = {
10549 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10550 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10552 .dac_nids = alc883_dac_nids,
10553 .dig_out_nid = ALC883_DIGOUT_NID,
10554 .dig_in_nid = ALC883_DIGIN_NID,
10555 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10556 .channel_mode = alc883_3ST_6ch_clevo_modes,
10557 .need_dac_fix = 1,
10558 .input_mux = &alc883_capture_source,
10559 /* This machine has the hardware HP auto-muting, thus
10560 * we need no software mute via unsol event
10561 */
10562 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010563 [ALC883_CLEVO_M720] = {
10564 .mixers = { alc883_clevo_m720_mixer },
10565 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010566 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10567 .dac_nids = alc883_dac_nids,
10568 .dig_out_nid = ALC883_DIGOUT_NID,
10569 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10570 .channel_mode = alc883_3ST_2ch_modes,
10571 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010572 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010573 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010574 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010575 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010576 [ALC883_LENOVO_101E_2ch] = {
10577 .mixers = { alc883_lenovo_101e_2ch_mixer},
10578 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10579 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10580 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010581 .adc_nids = alc883_adc_nids_alt,
10582 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010583 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010584 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10585 .channel_mode = alc883_3ST_2ch_modes,
10586 .input_mux = &alc883_lenovo_101e_capture_source,
10587 .unsol_event = alc883_lenovo_101e_unsol_event,
10588 .init_hook = alc883_lenovo_101e_all_automute,
10589 },
Kailang Yang272a5272007-05-14 11:00:38 +020010590 [ALC883_LENOVO_NB0763] = {
10591 .mixers = { alc883_lenovo_nb0763_mixer },
10592 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10593 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10594 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010595 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10596 .channel_mode = alc883_3ST_2ch_modes,
10597 .need_dac_fix = 1,
10598 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010599 .unsol_event = alc_sku_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010600 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010601 .init_hook = alc_hp_automute,
Kailang Yang272a5272007-05-14 11:00:38 +020010602 },
10603 [ALC888_LENOVO_MS7195_DIG] = {
10604 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10605 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10606 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10607 .dac_nids = alc883_dac_nids,
10608 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010609 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10610 .channel_mode = alc883_3ST_6ch_modes,
10611 .need_dac_fix = 1,
10612 .input_mux = &alc883_capture_source,
10613 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10614 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010615 },
10616 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010617 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010618 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10619 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10620 .dac_nids = alc883_dac_nids,
10621 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010622 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10623 .channel_mode = alc883_3ST_2ch_modes,
10624 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010625 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010626 .setup = alc883_haier_w66_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010627 .init_hook = alc_hp_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010628 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010629 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010630 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010631 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010632 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10633 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010634 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10635 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010636 .need_dac_fix = 1,
10637 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010638 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010639 .setup = alc888_3st_hp_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010640 .init_hook = alc_hp_automute,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010641 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010642 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010643 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010644 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10645 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10646 .dac_nids = alc883_dac_nids,
10647 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010648 .dig_in_nid = ALC883_DIGIN_NID,
10649 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10650 .channel_mode = alc883_sixstack_modes,
10651 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010652 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010653 .setup = alc888_6st_dell_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010654 .init_hook = alc_hp_automute,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010655 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010656 [ALC883_MITAC] = {
10657 .mixers = { alc883_mitac_mixer },
10658 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10659 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10660 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010661 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10662 .channel_mode = alc883_3ST_2ch_modes,
10663 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010664 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010665 .setup = alc883_mitac_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010666 .init_hook = alc_hp_automute,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010667 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010668 [ALC883_FUJITSU_PI2515] = {
10669 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10670 .init_verbs = { alc883_init_verbs,
10671 alc883_2ch_fujitsu_pi2515_verbs},
10672 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10673 .dac_nids = alc883_dac_nids,
10674 .dig_out_nid = ALC883_DIGOUT_NID,
10675 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10676 .channel_mode = alc883_3ST_2ch_modes,
10677 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010678 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010679 .setup = alc883_2ch_fujitsu_pi2515_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010680 .init_hook = alc_hp_automute,
Jiang zhefb97dc62008-03-06 11:07:11 +010010681 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010682 [ALC888_FUJITSU_XA3530] = {
10683 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10684 .init_verbs = { alc883_init_verbs,
10685 alc888_fujitsu_xa3530_verbs },
10686 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10687 .dac_nids = alc883_dac_nids,
10688 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10689 .adc_nids = alc883_adc_nids_rev,
10690 .capsrc_nids = alc883_capsrc_nids_rev,
10691 .dig_out_nid = ALC883_DIGOUT_NID,
10692 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10693 .channel_mode = alc888_4ST_8ch_intel_modes,
10694 .num_mux_defs =
10695 ARRAY_SIZE(alc888_2_capture_sources),
10696 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010697 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010698 .setup = alc888_fujitsu_xa3530_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010699 .init_hook = alc_hp_automute,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010700 },
Kailang Yange2757d52008-08-26 13:17:46 +020010701 [ALC888_LENOVO_SKY] = {
10702 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10703 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10704 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10705 .dac_nids = alc883_dac_nids,
10706 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010707 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10708 .channel_mode = alc883_sixstack_modes,
10709 .need_dac_fix = 1,
10710 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010711 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010712 .setup = alc888_lenovo_sky_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010713 .init_hook = alc_hp_automute,
Kailang Yange2757d52008-08-26 13:17:46 +020010714 },
10715 [ALC888_ASUS_M90V] = {
10716 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10717 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10718 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10719 .dac_nids = alc883_dac_nids,
10720 .dig_out_nid = ALC883_DIGOUT_NID,
10721 .dig_in_nid = ALC883_DIGIN_NID,
10722 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10723 .channel_mode = alc883_3ST_6ch_modes,
10724 .need_dac_fix = 1,
10725 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010726 .unsol_event = alc_sku_unsol_event,
10727 .setup = alc883_mode2_setup,
10728 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010729 },
10730 [ALC888_ASUS_EEE1601] = {
10731 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010732 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010733 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_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_2ch_modes),
10739 .channel_mode = alc883_3ST_2ch_modes,
10740 .need_dac_fix = 1,
10741 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010742 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010743 .init_hook = alc883_eee1601_inithook,
10744 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010745 [ALC1200_ASUS_P5Q] = {
10746 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10747 .init_verbs = { alc883_init_verbs },
10748 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10749 .dac_nids = alc883_dac_nids,
10750 .dig_out_nid = ALC1200_DIGOUT_NID,
10751 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010752 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010753 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10754 .channel_mode = alc883_sixstack_modes,
10755 .input_mux = &alc883_capture_source,
10756 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010757 [ALC889A_MB31] = {
10758 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10759 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10760 alc880_gpio1_init_verbs },
10761 .adc_nids = alc883_adc_nids,
10762 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010763 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010764 .dac_nids = alc883_dac_nids,
10765 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10766 .channel_mode = alc889A_mb31_6ch_modes,
10767 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10768 .input_mux = &alc889A_mb31_capture_source,
10769 .dig_out_nid = ALC883_DIGOUT_NID,
10770 .unsol_event = alc889A_mb31_unsol_event,
10771 .init_hook = alc889A_mb31_automute,
10772 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010773 [ALC883_SONY_VAIO_TT] = {
10774 .mixers = { alc883_vaiott_mixer },
10775 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10776 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10777 .dac_nids = alc883_dac_nids,
10778 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10779 .channel_mode = alc883_3ST_2ch_modes,
10780 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010781 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010782 .setup = alc883_vaiott_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010783 .init_hook = alc_hp_automute,
Guido Günther3e1647c2009-06-05 00:47:26 +020010784 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010785};
10786
10787
10788/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010789 * Pin config fixes
10790 */
10791enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010792 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010793 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010794 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010795 PINFIX_ACER_ASPIRE_7736,
Takashi Iwaic6b35872011-03-28 12:05:31 +020010796 PINFIX_GIGABYTE_880GM,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010797};
10798
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010799static const struct alc_fixup alc882_fixups[] = {
10800 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010801 .type = ALC_FIXUP_PINS,
10802 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010803 { 0x15, 0x01080104 }, /* side */
10804 { 0x16, 0x01011012 }, /* rear */
10805 { 0x17, 0x01016011 }, /* clfe */
10806 { }
10807 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010808 },
David Henningsson32eea382011-03-04 13:37:50 +010010809 [PINFIX_LENOVO_Y530] = {
10810 .type = ALC_FIXUP_PINS,
10811 .v.pins = (const struct alc_pincfg[]) {
10812 { 0x15, 0x99130112 }, /* rear int speakers */
10813 { 0x16, 0x99130111 }, /* subwoofer */
10814 { }
10815 }
10816 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010817 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010818 .type = ALC_FIXUP_VERBS,
10819 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010820 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10821 {}
10822 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010823 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010824 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010825 .type = ALC_FIXUP_SKU,
10826 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010827 },
Takashi Iwaic6b35872011-03-28 12:05:31 +020010828 [PINFIX_GIGABYTE_880GM] = {
10829 .type = ALC_FIXUP_PINS,
10830 .v.pins = (const struct alc_pincfg[]) {
10831 { 0x14, 0x1114410 }, /* set as speaker */
10832 { }
10833 }
10834 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010835};
10836
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010837static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010838 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010010839 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010840 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010841 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwaic6b35872011-03-28 12:05:31 +020010842 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", PINFIX_GIGABYTE_880GM),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010843 {}
10844};
10845
10846/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010847 * BIOS auto configuration
10848 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010849static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10850 const struct auto_pin_cfg *cfg)
10851{
10852 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10853}
10854
Takashi Iwai4953550a2009-06-30 15:28:30 +020010855static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010856 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010857 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010858{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010859 int idx;
10860
Takashi Iwai489008c2010-04-07 09:06:00 +020010861 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010862 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010863
Takashi Iwai489008c2010-04-07 09:06:00 +020010864 if (dac == 0x25)
10865 idx = 4;
10866 else if (dac >= 0x02 && dac <= 0x05)
10867 idx = dac - 2;
10868 else
10869 return;
10870 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010871}
10872
Takashi Iwai4953550a2009-06-30 15:28:30 +020010873static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010874{
10875 struct alc_spec *spec = codec->spec;
10876 int i;
10877
10878 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010879 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010880 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010881 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010882 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010883 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010884 }
10885}
10886
Takashi Iwai4953550a2009-06-30 15:28:30 +020010887static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010888{
10889 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010890 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010891 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010892
David Henningsson0a3fabe2011-03-04 16:54:52 +010010893 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) {
10894 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10895 pin = spec->autocfg.hp_pins[i];
10896 if (!pin)
10897 break;
10898 dac = spec->multiout.hp_nid;
10899 if (!dac)
10900 dac = spec->multiout.dac_nids[0]; /* to front */
10901 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10902 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010903 }
David Henningsson0a3fabe2011-03-04 16:54:52 +010010904
10905 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) {
10906 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10907 pin = spec->autocfg.speaker_pins[i];
10908 if (!pin)
10909 break;
10910 dac = spec->multiout.extra_out_nid[0];
10911 if (!dac)
10912 dac = spec->multiout.dac_nids[0]; /* to front */
10913 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10914 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010915 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010916}
10917
Takashi Iwai4953550a2009-06-30 15:28:30 +020010918static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010919{
10920 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010921 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010922 int i;
10923
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010924 for (i = 0; i < cfg->num_inputs; i++) {
10925 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010926 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010927 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10928 snd_hda_codec_write(codec, nid, 0,
10929 AC_VERB_SET_AMP_GAIN_MUTE,
10930 AMP_OUT_MUTE);
10931 }
10932}
10933
10934static void alc882_auto_init_input_src(struct hda_codec *codec)
10935{
10936 struct alc_spec *spec = codec->spec;
10937 int c;
10938
10939 for (c = 0; c < spec->num_adc_nids; c++) {
10940 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10941 hda_nid_t nid = spec->capsrc_nids[c];
10942 unsigned int mux_idx;
10943 const struct hda_input_mux *imux;
10944 int conns, mute, idx, item;
10945
Takashi Iwai10696aa2011-04-07 12:46:45 +020010946 /* mute ADC */
10947 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
10948 AC_VERB_SET_AMP_GAIN_MUTE,
10949 AMP_IN_MUTE(0));
10950
Takashi Iwai4953550a2009-06-30 15:28:30 +020010951 conns = snd_hda_get_connections(codec, nid, conn_list,
10952 ARRAY_SIZE(conn_list));
10953 if (conns < 0)
10954 continue;
10955 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10956 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010957 if (!imux->num_items && mux_idx > 0)
10958 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010959 for (idx = 0; idx < conns; idx++) {
10960 /* if the current connection is the selected one,
10961 * unmute it as default - otherwise mute it
10962 */
10963 mute = AMP_IN_MUTE(idx);
10964 for (item = 0; item < imux->num_items; item++) {
10965 if (imux->items[item].index == idx) {
10966 if (spec->cur_mux[c] == item)
10967 mute = AMP_IN_UNMUTE(idx);
10968 break;
10969 }
10970 }
10971 /* check if we have a selector or mixer
10972 * we could check for the widget type instead, but
10973 * just check for Amp-In presence (in case of mixer
10974 * without amp-in there is something wrong, this
10975 * function shouldn't be used or capsrc nid is wrong)
10976 */
10977 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010978 snd_hda_codec_write(codec, nid, 0,
10979 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010980 mute);
10981 else if (mute != AMP_IN_MUTE(idx))
10982 snd_hda_codec_write(codec, nid, 0,
10983 AC_VERB_SET_CONNECT_SEL,
10984 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010985 }
10986 }
10987}
10988
Takashi Iwai4953550a2009-06-30 15:28:30 +020010989/* add mic boosts if needed */
10990static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010991{
10992 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010993 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010994 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010995 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010996 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010997 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010998
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010999 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020011000 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011001 break;
11002 nid = cfg->inputs[i].pin;
11003 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010011004 const char *label;
11005 char boost_label[32];
11006
11007 label = hda_get_autocfg_input_label(codec, cfg, i);
11008 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010011009 type_idx++;
11010 else
11011 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010011012 prev_label = label;
11013
11014 snprintf(boost_label, sizeof(boost_label),
11015 "%s Boost Volume", label);
11016 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11017 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020011018 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011019 if (err < 0)
11020 return err;
11021 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011022 }
11023 return 0;
11024}
11025
11026/* almost identical with ALC880 parser... */
11027static int alc882_parse_auto_config(struct hda_codec *codec)
11028{
11029 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011030 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020011031 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011032
Takashi Iwai05f5f472009-08-25 13:10:18 +020011033 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11034 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011035 if (err < 0)
11036 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011037 if (!spec->autocfg.line_outs)
11038 return 0; /* can't find valid BIOS pin config */
11039
11040 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11041 if (err < 0)
11042 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020011043 err = alc_auto_add_multi_channel_mode(codec);
11044 if (err < 0)
11045 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010011046 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020011047 if (err < 0)
11048 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020011049 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11050 "Headphone");
11051 if (err < 0)
11052 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011053 err = alc880_auto_create_extra_out(spec,
11054 spec->autocfg.speaker_pins[0],
11055 "Speaker");
11056 if (err < 0)
11057 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011058 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
11059 if (err < 0)
11060 return err;
11061
11062 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11063
Takashi Iwai757899a2010-07-30 10:48:14 +020011064 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020011065
11066 if (spec->kctls.list)
11067 add_mixer(spec, spec->kctls.list);
11068
11069 add_verb(spec, alc883_auto_init_verbs);
11070 /* if ADC 0x07 is available, initialize it, too */
11071 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
11072 add_verb(spec, alc882_adc1_init_verbs);
11073
11074 spec->num_mux_defs = 1;
11075 spec->input_mux = &spec->private_imux[0];
11076
Kailang Yang6227cdc2010-02-25 08:36:52 +010011077 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020011078
11079 err = alc_auto_add_mic_boost(codec);
11080 if (err < 0)
11081 return err;
11082
Takashi Iwai776e1842007-08-29 15:07:11 +020011083 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011084}
11085
11086/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011087static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011088{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011089 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011090 alc882_auto_init_multi_out(codec);
11091 alc882_auto_init_hp_out(codec);
11092 alc882_auto_init_analog_input(codec);
11093 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020011094 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011095 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011096 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011097}
11098
Takashi Iwai4953550a2009-06-30 15:28:30 +020011099static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011100{
11101 struct alc_spec *spec;
11102 int err, board_config;
11103
11104 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11105 if (spec == NULL)
11106 return -ENOMEM;
11107
11108 codec->spec = spec;
11109
Takashi Iwai4953550a2009-06-30 15:28:30 +020011110 switch (codec->vendor_id) {
11111 case 0x10ec0882:
11112 case 0x10ec0885:
11113 break;
11114 default:
11115 /* ALC883 and variants */
11116 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11117 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011118 }
11119
Takashi Iwai4953550a2009-06-30 15:28:30 +020011120 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
11121 alc882_models,
11122 alc882_cfg_tbl);
11123
11124 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
11125 board_config = snd_hda_check_board_codec_sid_config(codec,
11126 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
11127
11128 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011129 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011130 codec->chip_name);
11131 board_config = ALC882_AUTO;
11132 }
11133
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011134 if (board_config == ALC882_AUTO) {
11135 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11136 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11137 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011138
David Henningsson90622912010-10-14 14:50:18 +020011139 alc_auto_parse_customize_define(codec);
11140
Takashi Iwai4953550a2009-06-30 15:28:30 +020011141 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011142 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011143 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011144 if (err < 0) {
11145 alc_free(codec);
11146 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011147 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011148 printk(KERN_INFO
11149 "hda_codec: Cannot set up configuration "
11150 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011151 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011152 }
11153 }
11154
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011155 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011156 err = snd_hda_attach_beep_device(codec, 0x1);
11157 if (err < 0) {
11158 alc_free(codec);
11159 return err;
11160 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011161 }
11162
Takashi Iwai4953550a2009-06-30 15:28:30 +020011163 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011164 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011165
Takashi Iwai4953550a2009-06-30 15:28:30 +020011166 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11167 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11168 /* FIXME: setup DAC5 */
11169 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11170 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11171
11172 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11173 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11174
Takashi Iwai4953550a2009-06-30 15:28:30 +020011175 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011176 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011177 spec->num_adc_nids = 0;
11178 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011179 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011180 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011181 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011182 hda_nid_t nid = alc882_adc_nids[i];
11183 unsigned int wcap = get_wcaps(codec, nid);
11184 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011185 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011186 if (wcap != AC_WID_AUD_IN)
11187 continue;
11188 spec->private_adc_nids[spec->num_adc_nids] = nid;
11189 err = snd_hda_get_connections(codec, nid, &cap, 1);
11190 if (err < 0)
11191 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011192 err = snd_hda_get_connections(codec, cap, items,
11193 ARRAY_SIZE(items));
11194 if (err < 0)
11195 continue;
11196 for (j = 0; j < imux->num_items; j++)
11197 if (imux->items[j].index >= err)
11198 break;
11199 if (j < imux->num_items)
11200 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011201 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11202 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011203 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011204 spec->adc_nids = spec->private_adc_nids;
11205 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011206 }
11207
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011208 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011209
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011210 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011211 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011212
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011213 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011214
Takashi Iwai2134ea42008-01-10 16:53:55 +010011215 spec->vmaster_nid = 0x0c;
11216
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011217 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011218 if (board_config == ALC882_AUTO)
11219 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011220
11221 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011222#ifdef CONFIG_SND_HDA_POWER_SAVE
11223 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011224 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011225#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011226
11227 return 0;
11228}
11229
Takashi Iwai4953550a2009-06-30 15:28:30 +020011230
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011231/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011232 * ALC262 support
11233 */
11234
11235#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11236#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11237
11238#define alc262_dac_nids alc260_dac_nids
11239#define alc262_adc_nids alc882_adc_nids
11240#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011241#define alc262_capsrc_nids alc882_capsrc_nids
11242#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011243
11244#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011245#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011246
Kailang Yang4e555fe2008-08-26 13:05:55 +020011247static hda_nid_t alc262_dmic_adc_nids[1] = {
11248 /* ADC0 */
11249 0x09
11250};
11251
11252static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11253
Kailang Yangdf694da2005-12-05 19:42:22 +010011254static struct snd_kcontrol_new alc262_base_mixer[] = {
11255 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11256 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11257 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11258 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11259 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11260 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11262 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011263 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011264 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11265 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011266 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011267 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11268 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11269 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11270 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011271 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011272};
11273
Takashi Iwaice875f02008-01-28 18:17:43 +010011274/* update HP, line and mono-out pins according to the master switch */
11275static void alc262_hp_master_update(struct hda_codec *codec)
11276{
11277 struct alc_spec *spec = codec->spec;
11278 int val = spec->master_sw;
11279
11280 /* HP & line-out */
11281 snd_hda_codec_write_cache(codec, 0x1b, 0,
11282 AC_VERB_SET_PIN_WIDGET_CONTROL,
11283 val ? PIN_HP : 0);
11284 snd_hda_codec_write_cache(codec, 0x15, 0,
11285 AC_VERB_SET_PIN_WIDGET_CONTROL,
11286 val ? PIN_HP : 0);
11287 /* mono (speaker) depending on the HP jack sense */
11288 val = val && !spec->jack_present;
11289 snd_hda_codec_write_cache(codec, 0x16, 0,
11290 AC_VERB_SET_PIN_WIDGET_CONTROL,
11291 val ? PIN_OUT : 0);
11292}
11293
11294static void alc262_hp_bpc_automute(struct hda_codec *codec)
11295{
11296 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011297
11298 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011299 alc262_hp_master_update(codec);
11300}
11301
11302static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11303{
11304 if ((res >> 26) != ALC880_HP_EVENT)
11305 return;
11306 alc262_hp_bpc_automute(codec);
11307}
11308
11309static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11310{
11311 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011312
11313 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011314 alc262_hp_master_update(codec);
11315}
11316
11317static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11318 unsigned int res)
11319{
11320 if ((res >> 26) != ALC880_HP_EVENT)
11321 return;
11322 alc262_hp_wildwest_automute(codec);
11323}
11324
Takashi Iwaib72519b2009-05-08 14:31:55 +020011325#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011326
11327static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11328 struct snd_ctl_elem_value *ucontrol)
11329{
11330 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11331 struct alc_spec *spec = codec->spec;
11332 int val = !!*ucontrol->value.integer.value;
11333
11334 if (val == spec->master_sw)
11335 return 0;
11336 spec->master_sw = val;
11337 alc262_hp_master_update(codec);
11338 return 1;
11339}
11340
Takashi Iwaib72519b2009-05-08 14:31:55 +020011341#define ALC262_HP_MASTER_SWITCH \
11342 { \
11343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11344 .name = "Master Playback Switch", \
11345 .info = snd_ctl_boolean_mono_info, \
11346 .get = alc262_hp_master_sw_get, \
11347 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011348 }, \
11349 { \
11350 .iface = NID_MAPPING, \
11351 .name = "Master Playback Switch", \
11352 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011353 }
11354
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011355
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011356static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011357 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011358 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11359 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11360 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011361 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11362 HDA_OUTPUT),
11363 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11364 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011365 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11366 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011367 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011368 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11369 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011370 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011371 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11372 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11373 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11374 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011375 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11376 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11377 { } /* end */
11378};
11379
Kailang Yangcd7509a2007-01-26 18:33:17 +010011380static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011381 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011382 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11383 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11384 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011386 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11387 HDA_OUTPUT),
11388 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11389 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011390 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11391 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011392 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011393 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11394 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11395 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11396 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011397 { } /* end */
11398};
11399
11400static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11401 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11402 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011403 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011404 { } /* end */
11405};
11406
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011407/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011408static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011409{
11410 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011411
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011412 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011413 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020011414 spec->automute = 1;
11415 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011416}
11417
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011418static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011419 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11420 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011421 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11422 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011425 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011426 { } /* end */
11427};
11428
11429static struct hda_verb alc262_hp_t5735_verbs[] = {
11430 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11431 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11432
11433 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11434 { }
11435};
11436
Kailang Yang8c427222008-01-10 13:03:59 +010011437static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011438 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011440 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11441 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11444 { } /* end */
11445};
11446
11447static struct hda_verb alc262_hp_rp5700_verbs[] = {
11448 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11449 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11450 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11451 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11452 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11453 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11458 {}
11459};
11460
11461static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11462 .num_items = 1,
11463 .items = {
11464 { "Line", 0x1 },
11465 },
11466};
11467
Takashi Iwai42171c12009-05-08 14:11:43 +020011468/* bind hp and internal speaker mute (with plug check) as master switch */
11469static void alc262_hippo_master_update(struct hda_codec *codec)
11470{
11471 struct alc_spec *spec = codec->spec;
11472 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11473 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11474 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11475 unsigned int mute;
11476
11477 /* HP */
11478 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11479 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11480 HDA_AMP_MUTE, mute);
11481 /* mute internal speaker per jack sense */
11482 if (spec->jack_present)
11483 mute = HDA_AMP_MUTE;
11484 if (line_nid)
11485 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11486 HDA_AMP_MUTE, mute);
11487 if (speaker_nid && speaker_nid != line_nid)
11488 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11489 HDA_AMP_MUTE, mute);
11490}
11491
11492#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11493
11494static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11495 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011496{
11497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011498 struct alc_spec *spec = codec->spec;
11499 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011500
Takashi Iwai42171c12009-05-08 14:11:43 +020011501 if (val == spec->master_sw)
11502 return 0;
11503 spec->master_sw = val;
11504 alc262_hippo_master_update(codec);
11505 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011506}
Takashi Iwai5b319542007-07-26 11:49:22 +020011507
Takashi Iwai42171c12009-05-08 14:11:43 +020011508#define ALC262_HIPPO_MASTER_SWITCH \
11509 { \
11510 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11511 .name = "Master Playback Switch", \
11512 .info = snd_ctl_boolean_mono_info, \
11513 .get = alc262_hippo_master_sw_get, \
11514 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011515 }, \
11516 { \
11517 .iface = NID_MAPPING, \
11518 .name = "Master Playback Switch", \
11519 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11520 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011521 }
11522
11523static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11524 ALC262_HIPPO_MASTER_SWITCH,
11525 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11526 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11527 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11528 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11529 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011532 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011533 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11534 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011535 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011536 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11537 { } /* end */
11538};
11539
11540static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11541 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11542 ALC262_HIPPO_MASTER_SWITCH,
11543 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11544 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11545 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11546 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11547 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11548 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011549 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011550 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11551 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011552 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011553 { } /* end */
11554};
11555
11556/* mute/unmute internal speaker according to the hp jack and mute state */
11557static void alc262_hippo_automute(struct hda_codec *codec)
11558{
11559 struct alc_spec *spec = codec->spec;
11560 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011561
Wu Fengguang864f92b2009-11-18 12:38:02 +080011562 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011563 alc262_hippo_master_update(codec);
11564}
11565
11566static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11567{
11568 if ((res >> 26) != ALC880_HP_EVENT)
11569 return;
11570 alc262_hippo_automute(codec);
11571}
11572
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011573static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011574{
11575 struct alc_spec *spec = codec->spec;
11576
11577 spec->autocfg.hp_pins[0] = 0x15;
11578 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011579}
11580
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011581static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011582{
11583 struct alc_spec *spec = codec->spec;
11584
11585 spec->autocfg.hp_pins[0] = 0x1b;
11586 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011587}
11588
11589
Kailang Yang272a5272007-05-14 11:00:38 +020011590static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011591 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011592 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11595 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11596 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11597 { } /* end */
11598};
11599
Kailang Yang83c34212007-07-05 11:43:05 +020011600static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011601 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11602 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11605 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11606 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11607 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11608 { } /* end */
11609};
Kailang Yang272a5272007-05-14 11:00:38 +020011610
Tony Vroonba340e82009-02-02 19:01:30 +000011611static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11612 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11613 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11614 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11615 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11616 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11617 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011620 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011621 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11622 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011623 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011624 { } /* end */
11625};
11626
11627static struct hda_verb alc262_tyan_verbs[] = {
11628 /* Headphone automute */
11629 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11630 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11631 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11632
11633 /* P11 AUX_IN, white 4-pin connector */
11634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11635 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11636 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11637 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11638
11639 {}
11640};
11641
11642/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011643static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011644{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011645 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011646
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011647 spec->autocfg.hp_pins[0] = 0x1b;
11648 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +020011649 spec->automute = 1;
11650 spec->automute_mode = ALC_AUTOMUTE_AMP;
Tony Vroonba340e82009-02-02 19:01:30 +000011651}
11652
Tony Vroonba340e82009-02-02 19:01:30 +000011653
Kailang Yangdf694da2005-12-05 19:42:22 +010011654#define alc262_capture_mixer alc882_capture_mixer
11655#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11656
11657/*
11658 * generic initialization of ADC, input mixers and output mixers
11659 */
11660static struct hda_verb alc262_init_verbs[] = {
11661 /*
11662 * Unmute ADC0-2 and set the default input to mic-in
11663 */
11664 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11666 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11668 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11669 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11670
Takashi Iwaicb53c622007-08-10 17:21:45 +020011671 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011672 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011673 * Note: PASD motherboards uses the Line In 2 as the input for
11674 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011675 */
11676 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011682
11683 /*
11684 * Set up output mixers (0x0c - 0x0e)
11685 */
11686 /* set vol=0 to output mixers */
11687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11690 /* set up input amps for analog loopback */
11691 /* Amp Indices: DAC = 0, mixer = 1 */
11692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11694 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11695 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11696 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11697 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11698
11699 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11701 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11702 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11703 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11704 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11705
11706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11708 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11709 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011711
Kailang Yangdf694da2005-12-05 19:42:22 +010011712 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11713 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011714
Kailang Yangdf694da2005-12-05 19:42:22 +010011715 /* FIXME: use matrix-type input source selection */
11716 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11717 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11720 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11721 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11722 /* Input mixer2 */
11723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11727 /* Input mixer3 */
11728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011732
11733 { }
11734};
11735
Kailang Yang4e555fe2008-08-26 13:05:55 +020011736static struct hda_verb alc262_eapd_verbs[] = {
11737 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11738 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11739 { }
11740};
11741
Kailang Yangccc656c2006-10-17 12:32:26 +020011742static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11743 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11744 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11745 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11746
11747 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11748 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11749 {}
11750};
11751
Kailang Yang272a5272007-05-14 11:00:38 +020011752static struct hda_verb alc262_sony_unsol_verbs[] = {
11753 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11754 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11755 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11756
11757 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11758 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011759 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011760};
11761
Kailang Yang4e555fe2008-08-26 13:05:55 +020011762static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11763 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11764 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11765 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11767 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011768 { } /* end */
11769};
11770
11771static struct hda_verb alc262_toshiba_s06_verbs[] = {
11772 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11773 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11775 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11776 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11777 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11778 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11779 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11780 {}
11781};
11782
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011783static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011784{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011785 struct alc_spec *spec = codec->spec;
11786
11787 spec->autocfg.hp_pins[0] = 0x15;
11788 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011789 spec->ext_mic.pin = 0x18;
11790 spec->ext_mic.mux_idx = 0;
11791 spec->int_mic.pin = 0x12;
11792 spec->int_mic.mux_idx = 9;
11793 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020011794 spec->automute = 1;
11795 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011796}
11797
Takashi Iwai834be882006-03-01 14:16:17 +010011798/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011799 * nec model
11800 * 0x15 = headphone
11801 * 0x16 = internal speaker
11802 * 0x18 = external mic
11803 */
11804
11805static struct snd_kcontrol_new alc262_nec_mixer[] = {
11806 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11807 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11808
11809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011811 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011812
11813 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11814 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11815 { } /* end */
11816};
11817
11818static struct hda_verb alc262_nec_verbs[] = {
11819 /* Unmute Speaker */
11820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11821
11822 /* Headphone */
11823 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11825
11826 /* External mic to headphone */
11827 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11828 /* External mic to speaker */
11829 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11830 {}
11831};
11832
11833/*
Takashi Iwai834be882006-03-01 14:16:17 +010011834 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011835 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11836 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011837 */
11838
11839#define ALC_HP_EVENT 0x37
11840
11841static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11842 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11843 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011844 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11845 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011846 {}
11847};
11848
Jiang zhe0e31daf2008-03-20 12:12:39 +010011849static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11850 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11851 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11852 {}
11853};
11854
Daniel T Chene2595322009-12-19 18:19:02 -050011855static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11856 /* Front Mic pin: input vref at 50% */
11857 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11859 {}
11860};
11861
Takashi Iwai834be882006-03-01 14:16:17 +010011862static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011863 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011864 .items = {
11865 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011866 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011867 { "CD", 0x4 },
11868 },
11869};
11870
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011871static struct hda_input_mux alc262_HP_capture_source = {
11872 .num_items = 5,
11873 .items = {
11874 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011875 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011876 { "Line", 0x2 },
11877 { "CD", 0x4 },
11878 { "AUX IN", 0x6 },
11879 },
11880};
11881
zhejiangaccbe492007-08-31 12:36:05 +020011882static struct hda_input_mux alc262_HP_D7000_capture_source = {
11883 .num_items = 4,
11884 .items = {
11885 { "Mic", 0x0 },
11886 { "Front Mic", 0x2 },
11887 { "Line", 0x1 },
11888 { "CD", 0x4 },
11889 },
11890};
11891
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011892/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011893static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11894{
11895 struct alc_spec *spec = codec->spec;
11896 unsigned int mute;
11897
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011898 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011899 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11900 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011901 spec->sense_updated = 1;
11902 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011903 /* unmute internal speaker only if both HPs are unplugged and
11904 * master switch is on
11905 */
11906 if (spec->jack_present)
11907 mute = HDA_AMP_MUTE;
11908 else
Takashi Iwai834be882006-03-01 14:16:17 +010011909 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011910 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11911 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011912}
11913
11914/* unsolicited event for HP jack sensing */
11915static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11916 unsigned int res)
11917{
11918 if ((res >> 26) != ALC_HP_EVENT)
11919 return;
11920 alc262_fujitsu_automute(codec, 1);
11921}
11922
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011923static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11924{
11925 alc262_fujitsu_automute(codec, 1);
11926}
11927
Takashi Iwai834be882006-03-01 14:16:17 +010011928/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011929static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11930 .ops = &snd_hda_bind_vol,
11931 .values = {
11932 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11933 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11934 0
11935 },
11936};
Takashi Iwai834be882006-03-01 14:16:17 +010011937
Jiang zhe0e31daf2008-03-20 12:12:39 +010011938/* mute/unmute internal speaker according to the hp jack and mute state */
11939static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11940{
11941 struct alc_spec *spec = codec->spec;
11942 unsigned int mute;
11943
11944 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011945 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011946 spec->sense_updated = 1;
11947 }
11948 if (spec->jack_present) {
11949 /* mute internal speaker */
11950 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11951 HDA_AMP_MUTE, HDA_AMP_MUTE);
11952 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11953 HDA_AMP_MUTE, HDA_AMP_MUTE);
11954 } else {
11955 /* unmute internal speaker if necessary */
11956 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11957 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11958 HDA_AMP_MUTE, mute);
11959 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11960 HDA_AMP_MUTE, mute);
11961 }
11962}
11963
11964/* unsolicited event for HP jack sensing */
11965static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11966 unsigned int res)
11967{
11968 if ((res >> 26) != ALC_HP_EVENT)
11969 return;
11970 alc262_lenovo_3000_automute(codec, 1);
11971}
11972
Takashi Iwai8de56b72009-07-24 16:51:47 +020011973static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11974 int dir, int idx, long *valp)
11975{
11976 int i, change = 0;
11977
11978 for (i = 0; i < 2; i++, valp++)
11979 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11980 HDA_AMP_MUTE,
11981 *valp ? 0 : HDA_AMP_MUTE);
11982 return change;
11983}
11984
Takashi Iwai834be882006-03-01 14:16:17 +010011985/* bind hp and internal speaker mute (with plug check) */
11986static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11987 struct snd_ctl_elem_value *ucontrol)
11988{
11989 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11990 long *valp = ucontrol->value.integer.value;
11991 int change;
11992
Takashi Iwai8de56b72009-07-24 16:51:47 +020011993 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11994 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011995 if (change)
11996 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011997 return change;
11998}
11999
12000static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020012001 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010012002 {
12003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12004 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012005 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010012006 .info = snd_hda_mixer_amp_switch_info,
12007 .get = snd_hda_mixer_amp_switch_get,
12008 .put = alc262_fujitsu_master_sw_put,
12009 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12010 },
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
Jiang zhe0e31daf2008-03-20 12:12:39 +010012027/* bind hp and internal speaker mute (with plug check) */
12028static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
12029 struct snd_ctl_elem_value *ucontrol)
12030{
12031 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12032 long *valp = ucontrol->value.integer.value;
12033 int change;
12034
Takashi Iwai8de56b72009-07-24 16:51:47 +020012035 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010012036 if (change)
12037 alc262_lenovo_3000_automute(codec, 0);
12038 return change;
12039}
12040
12041static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
12042 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
12043 {
12044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12045 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012046 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010012047 .info = snd_hda_mixer_amp_switch_info,
12048 .get = snd_hda_mixer_amp_switch_get,
12049 .put = alc262_lenovo_3000_master_sw_put,
12050 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
12051 },
12052 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12053 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012054 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012055 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12056 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012057 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010012058 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12059 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012060 { } /* end */
12061};
12062
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012063static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
12064 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020012065 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12067 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012068 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012069 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12070 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012071 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012072 { } /* end */
12073};
12074
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012075/* additional init verbs for Benq laptops */
12076static struct hda_verb alc262_EAPD_verbs[] = {
12077 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
12078 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
12079 {}
12080};
12081
Kailang Yang83c34212007-07-05 11:43:05 +020012082static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
12083 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12084 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12085
12086 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
12087 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
12088 {}
12089};
12090
Tobin Davisf651b502007-10-26 12:40:47 +020012091/* Samsung Q1 Ultra Vista model setup */
12092static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012093 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
12094 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012097 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
12098 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012099 { } /* end */
12100};
12101
12102static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012103 /* output mixer */
12104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12107 /* speaker */
12108 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12109 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12110 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12111 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12112 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020012113 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12115 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12116 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12117 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12118 /* internal mic */
12119 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12121 /* ADC, choose mic */
12122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12123 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12124 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12125 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12126 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12127 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12128 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12129 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12130 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
12131 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020012132 {}
12133};
12134
Tobin Davisf651b502007-10-26 12:40:47 +020012135/* mute/unmute internal speaker according to the hp jack and mute state */
12136static void alc262_ultra_automute(struct hda_codec *codec)
12137{
12138 struct alc_spec *spec = codec->spec;
12139 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012140
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012141 mute = 0;
12142 /* auto-mute only when HP is used as HP */
12143 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012144 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012145 if (spec->jack_present)
12146 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012147 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012148 /* mute/unmute internal speaker */
12149 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12150 HDA_AMP_MUTE, mute);
12151 /* mute/unmute HP */
12152 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12153 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012154}
12155
12156/* unsolicited event for HP jack sensing */
12157static void alc262_ultra_unsol_event(struct hda_codec *codec,
12158 unsigned int res)
12159{
12160 if ((res >> 26) != ALC880_HP_EVENT)
12161 return;
12162 alc262_ultra_automute(codec);
12163}
12164
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012165static struct hda_input_mux alc262_ultra_capture_source = {
12166 .num_items = 2,
12167 .items = {
12168 { "Mic", 0x1 },
12169 { "Headphone", 0x7 },
12170 },
12171};
12172
12173static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12174 struct snd_ctl_elem_value *ucontrol)
12175{
12176 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12177 struct alc_spec *spec = codec->spec;
12178 int ret;
12179
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012180 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012181 if (!ret)
12182 return 0;
12183 /* reprogram the HP pin as mic or HP according to the input source */
12184 snd_hda_codec_write_cache(codec, 0x15, 0,
12185 AC_VERB_SET_PIN_WIDGET_CONTROL,
12186 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12187 alc262_ultra_automute(codec); /* mute/unmute HP */
12188 return ret;
12189}
12190
12191static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12192 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12193 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12194 {
12195 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12196 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012197 .info = alc_mux_enum_info,
12198 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012199 .put = alc262_ultra_mux_enum_put,
12200 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012201 {
12202 .iface = NID_MAPPING,
12203 .name = "Capture Source",
12204 .private_value = 0x15,
12205 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012206 { } /* end */
12207};
12208
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012209/* We use two mixers depending on the output pin; 0x16 is a mono output
12210 * and thus it's bound with a different mixer.
12211 * This function returns which mixer amp should be used.
12212 */
12213static int alc262_check_volbit(hda_nid_t nid)
12214{
12215 if (!nid)
12216 return 0;
12217 else if (nid == 0x16)
12218 return 2;
12219 else
12220 return 1;
12221}
12222
12223static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012224 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012225{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012226 unsigned long val;
12227 int vbit;
12228
12229 vbit = alc262_check_volbit(nid);
12230 if (!vbit)
12231 return 0;
12232 if (*vbits & vbit) /* a volume control for this mixer already there */
12233 return 0;
12234 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012235 if (vbit == 2)
12236 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12237 else
12238 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012239 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012240}
12241
12242static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012243 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012244{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012245 unsigned long val;
12246
12247 if (!nid)
12248 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012249 if (nid == 0x16)
12250 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12251 else
12252 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012253 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012254}
12255
Kailang Yangdf694da2005-12-05 19:42:22 +010012256/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012257static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12258 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012259{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012260 const char *pfx;
12261 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012262 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012263
12264 spec->multiout.num_dacs = 1; /* only use one dac */
12265 spec->multiout.dac_nids = spec->private_dac_nids;
12266 spec->multiout.dac_nids[0] = 2;
12267
Takashi Iwaice764ab2011-04-27 16:35:23 +020012268 pfx = alc_get_line_out_pfx(spec, true);
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012269 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012270 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012271 for (i = 0; i < 2; i++) {
12272 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12273 if (err < 0)
12274 return err;
12275 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12276 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12277 "Speaker", i);
12278 if (err < 0)
12279 return err;
12280 }
12281 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12282 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12283 "Headphone", i);
12284 if (err < 0)
12285 return err;
12286 }
12287 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012288
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012289 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12290 alc262_check_volbit(cfg->speaker_pins[0]) |
12291 alc262_check_volbit(cfg->hp_pins[0]);
12292 if (vbits == 1 || vbits == 2)
12293 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012294 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012295 for (i = 0; i < 2; i++) {
12296 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12297 &vbits, i);
12298 if (err < 0)
12299 return err;
12300 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12301 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12302 "Speaker", &vbits, i);
12303 if (err < 0)
12304 return err;
12305 }
12306 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12307 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12308 "Headphone", &vbits, i);
12309 if (err < 0)
12310 return err;
12311 }
12312 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012313 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012314}
12315
Takashi Iwai05f5f472009-08-25 13:10:18 +020012316#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012317 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012318
12319/*
12320 * generic initialization of ADC, input mixers and output mixers
12321 */
12322static struct hda_verb alc262_volume_init_verbs[] = {
12323 /*
12324 * Unmute ADC0-2 and set the default input to mic-in
12325 */
12326 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12328 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12329 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12330 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12331 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12332
Takashi Iwaicb53c622007-08-10 17:21:45 +020012333 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012334 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012335 * Note: PASD motherboards uses the Line In 2 as the input for
12336 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012337 */
12338 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012344
12345 /*
12346 * Set up output mixers (0x0c - 0x0f)
12347 */
12348 /* set vol=0 to output mixers */
12349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12350 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012352
Kailang Yangdf694da2005-12-05 19:42:22 +010012353 /* set up input amps for analog loopback */
12354 /* Amp Indices: DAC = 0, mixer = 1 */
12355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12357 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12358 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12359 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12360 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12361
12362 /* FIXME: use matrix-type input source selection */
12363 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12364 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12369 /* Input mixer2 */
12370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12374 /* Input mixer3 */
12375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12379
12380 { }
12381};
12382
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012383static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12384 /*
12385 * Unmute ADC0-2 and set the default input to mic-in
12386 */
12387 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12388 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12389 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12391 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12393
Takashi Iwaicb53c622007-08-10 17:21:45 +020012394 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012395 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012396 * Note: PASD motherboards uses the Line In 2 as the input for
12397 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012398 */
12399 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012400 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12401 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12403 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12404 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12405 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12406 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012407
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012408 /*
12409 * Set up output mixers (0x0c - 0x0e)
12410 */
12411 /* set vol=0 to output mixers */
12412 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12413 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12415
12416 /* set up input amps for analog loopback */
12417 /* Amp Indices: DAC = 0, mixer = 1 */
12418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12419 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12420 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12421 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12422 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12423 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12424
Takashi Iwaice875f02008-01-28 18:17:43 +010012425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012426 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12427 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12428
12429 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12430 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12431
12432 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12433 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12434
12435 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12436 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12437 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12438 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12439 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12440
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012441 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012442 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12443 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012444 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012445 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12446 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12447
12448
12449 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012450 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12451 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012461 /* Input mixer2 */
12462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12466 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12467 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12468 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12469 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12470 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012471 /* Input mixer3 */
12472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012473 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12477 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012481
Takashi Iwaice875f02008-01-28 18:17:43 +010012482 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12483
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012484 { }
12485};
12486
Kailang Yangcd7509a2007-01-26 18:33:17 +010012487static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12488 /*
12489 * Unmute ADC0-2 and set the default input to mic-in
12490 */
12491 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12495 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12496 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12497
Takashi Iwaicb53c622007-08-10 17:21:45 +020012498 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012499 * mixer widget
12500 * Note: PASD motherboards uses the Line In 2 as the input for front
12501 * panel mic (mic 2)
12502 */
12503 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12510 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012512 /*
12513 * Set up output mixers (0x0c - 0x0e)
12514 */
12515 /* set vol=0 to output mixers */
12516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12519
12520 /* set up input amps for analog loopback */
12521 /* Amp Indices: DAC = 0, mixer = 1 */
12522 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12524 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12525 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12528
12529
12530 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12531 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12532 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12533 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12534 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12535 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12536 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12537
12538 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12540
12541 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12542 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12543
12544 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12545 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12548 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12549 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12550
12551 /* FIXME: use matrix-type input source selection */
12552 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12553 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12558 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12559 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12561 /* Input mixer2 */
12562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12567 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12569 /* Input mixer3 */
12570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12575 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12577
Takashi Iwaice875f02008-01-28 18:17:43 +010012578 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12579
Kailang Yangcd7509a2007-01-26 18:33:17 +010012580 { }
12581};
12582
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012583static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12584
12585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12586 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12587 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12588
12589 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12590 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12591 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12592 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12593
12594 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12595 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12596 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12597 {}
12598};
12599
Takashi Iwai18675e42010-09-08 15:55:44 +020012600/*
12601 * Pin config fixes
12602 */
12603enum {
12604 PINFIX_FSC_H270,
12605};
12606
12607static const struct alc_fixup alc262_fixups[] = {
12608 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012609 .type = ALC_FIXUP_PINS,
12610 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012611 { 0x14, 0x99130110 }, /* speaker */
12612 { 0x15, 0x0221142f }, /* front HP */
12613 { 0x1b, 0x0121141f }, /* rear HP */
12614 { }
12615 }
12616 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012617};
12618
12619static struct snd_pci_quirk alc262_fixup_tbl[] = {
12620 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12621 {}
12622};
12623
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012624
Takashi Iwaicb53c622007-08-10 17:21:45 +020012625#ifdef CONFIG_SND_HDA_POWER_SAVE
12626#define alc262_loopbacks alc880_loopbacks
12627#endif
12628
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012629/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012630#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12631#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12632#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12633#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12634
12635/*
12636 * BIOS auto configuration
12637 */
12638static int alc262_parse_auto_config(struct hda_codec *codec)
12639{
12640 struct alc_spec *spec = codec->spec;
12641 int err;
12642 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12643
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012644 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12645 alc262_ignore);
12646 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012647 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012648 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012649 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012650 spec->multiout.max_channels = 2;
12651 spec->no_analog = 1;
12652 goto dig_only;
12653 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012654 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012655 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012656 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12657 if (err < 0)
12658 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012659 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012660 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012661 return err;
12662
12663 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12664
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012665 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012666 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012667
Takashi Iwai603c4012008-07-30 15:01:44 +020012668 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012669 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012670
Takashi Iwaid88897e2008-10-31 15:01:37 +010012671 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012672 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012673 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012674
Takashi Iwai776e1842007-08-29 15:07:11 +020012675 err = alc_auto_add_mic_boost(codec);
12676 if (err < 0)
12677 return err;
12678
Kailang Yang6227cdc2010-02-25 08:36:52 +010012679 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012680
Kailang Yangdf694da2005-12-05 19:42:22 +010012681 return 1;
12682}
12683
12684#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12685#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12686#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012687#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012688
12689
12690/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012691static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012692{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012693 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012694 alc262_auto_init_multi_out(codec);
12695 alc262_auto_init_hp_out(codec);
12696 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012697 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012698 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012699 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012700 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012701}
12702
12703/*
12704 * configuration and preset
12705 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012706static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012707 [ALC262_BASIC] = "basic",
12708 [ALC262_HIPPO] = "hippo",
12709 [ALC262_HIPPO_1] = "hippo_1",
12710 [ALC262_FUJITSU] = "fujitsu",
12711 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012712 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012713 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012714 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012715 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012716 [ALC262_BENQ_T31] = "benq-t31",
12717 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012718 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012719 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012720 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012721 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012722 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012723 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012724 [ALC262_AUTO] = "auto",
12725};
12726
12727static struct snd_pci_quirk alc262_cfg_tbl[] = {
12728 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012729 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012730 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12731 ALC262_HP_BPC),
12732 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12733 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012734 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12735 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012736 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12737 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012738 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012739 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012740 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012741 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012742 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012743 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012744 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012745 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012746 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12747 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12748 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012749 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12750 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012751 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012752 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012753 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012754 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012755 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012756 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012757 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012758 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012759#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012760 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12761 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012762#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012763 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012764 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012765 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012766 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012767 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012768 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012769 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12770 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012771 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012772 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012773 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012774 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012775 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012776 {}
12777};
12778
12779static struct alc_config_preset alc262_presets[] = {
12780 [ALC262_BASIC] = {
12781 .mixers = { alc262_base_mixer },
12782 .init_verbs = { alc262_init_verbs },
12783 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12784 .dac_nids = alc262_dac_nids,
12785 .hp_nid = 0x03,
12786 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12787 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012788 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012789 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012790 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012791 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012792 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012793 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12794 .dac_nids = alc262_dac_nids,
12795 .hp_nid = 0x03,
12796 .dig_out_nid = ALC262_DIGOUT_NID,
12797 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12798 .channel_mode = alc262_modes,
12799 .input_mux = &alc262_capture_source,
12800 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012801 .setup = alc262_hippo_setup,
12802 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012803 },
12804 [ALC262_HIPPO_1] = {
12805 .mixers = { alc262_hippo1_mixer },
12806 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12807 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12808 .dac_nids = alc262_dac_nids,
12809 .hp_nid = 0x02,
12810 .dig_out_nid = ALC262_DIGOUT_NID,
12811 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12812 .channel_mode = alc262_modes,
12813 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012814 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012815 .setup = alc262_hippo1_setup,
12816 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012817 },
Takashi Iwai834be882006-03-01 14:16:17 +010012818 [ALC262_FUJITSU] = {
12819 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012820 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12821 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012822 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12823 .dac_nids = alc262_dac_nids,
12824 .hp_nid = 0x03,
12825 .dig_out_nid = ALC262_DIGOUT_NID,
12826 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12827 .channel_mode = alc262_modes,
12828 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012829 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012830 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012831 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012832 [ALC262_HP_BPC] = {
12833 .mixers = { alc262_HP_BPC_mixer },
12834 .init_verbs = { alc262_HP_BPC_init_verbs },
12835 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12836 .dac_nids = alc262_dac_nids,
12837 .hp_nid = 0x03,
12838 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12839 .channel_mode = alc262_modes,
12840 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012841 .unsol_event = alc262_hp_bpc_unsol_event,
12842 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012843 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012844 [ALC262_HP_BPC_D7000_WF] = {
12845 .mixers = { alc262_HP_BPC_WildWest_mixer },
12846 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12847 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12848 .dac_nids = alc262_dac_nids,
12849 .hp_nid = 0x03,
12850 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12851 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012852 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012853 .unsol_event = alc262_hp_wildwest_unsol_event,
12854 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012855 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012856 [ALC262_HP_BPC_D7000_WL] = {
12857 .mixers = { alc262_HP_BPC_WildWest_mixer,
12858 alc262_HP_BPC_WildWest_option_mixer },
12859 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12860 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12861 .dac_nids = alc262_dac_nids,
12862 .hp_nid = 0x03,
12863 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12864 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012865 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012866 .unsol_event = alc262_hp_wildwest_unsol_event,
12867 .init_hook = alc262_hp_wildwest_automute,
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,
12910 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012911 .setup = alc262_hippo_setup,
12912 .init_hook = alc262_hippo_automute,
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,
12924 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012925 .setup = alc262_hippo_setup,
12926 .init_hook = alc262_hippo_automute,
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,
12955 .unsol_event = alc262_lenovo_3000_unsol_event,
12956 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012957 [ALC262_NEC] = {
12958 .mixers = { alc262_nec_mixer },
12959 .init_verbs = { alc262_nec_verbs },
12960 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12961 .dac_nids = alc262_dac_nids,
12962 .hp_nid = 0x03,
12963 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12964 .channel_mode = alc262_modes,
12965 .input_mux = &alc262_capture_source,
12966 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012967 [ALC262_TOSHIBA_S06] = {
12968 .mixers = { alc262_toshiba_s06_mixer },
12969 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12970 alc262_eapd_verbs },
12971 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12972 .capsrc_nids = alc262_dmic_capsrc_nids,
12973 .dac_nids = alc262_dac_nids,
12974 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012975 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012976 .dig_out_nid = ALC262_DIGOUT_NID,
12977 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12978 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012979 .unsol_event = alc_sku_unsol_event,
12980 .setup = alc262_toshiba_s06_setup,
12981 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012982 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012983 [ALC262_TOSHIBA_RX1] = {
12984 .mixers = { alc262_toshiba_rx1_mixer },
12985 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12986 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12987 .dac_nids = alc262_dac_nids,
12988 .hp_nid = 0x03,
12989 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12990 .channel_mode = alc262_modes,
12991 .input_mux = &alc262_capture_source,
12992 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012993 .setup = alc262_hippo_setup,
12994 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012995 },
Tony Vroonba340e82009-02-02 19:01:30 +000012996 [ALC262_TYAN] = {
12997 .mixers = { alc262_tyan_mixer },
12998 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12999 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
13000 .dac_nids = alc262_dac_nids,
13001 .hp_nid = 0x02,
13002 .dig_out_nid = ALC262_DIGOUT_NID,
13003 .num_channel_mode = ARRAY_SIZE(alc262_modes),
13004 .channel_mode = alc262_modes,
13005 .input_mux = &alc262_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020013006 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013007 .setup = alc262_tyan_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020013008 .init_hook = alc_hp_automute,
Tony Vroonba340e82009-02-02 19:01:30 +000013009 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013010};
13011
13012static int patch_alc262(struct hda_codec *codec)
13013{
13014 struct alc_spec *spec;
13015 int board_config;
13016 int err;
13017
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013018 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013019 if (spec == NULL)
13020 return -ENOMEM;
13021
13022 codec->spec = spec;
13023#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013024 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
13025 * under-run
13026 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013027 {
13028 int tmp;
13029 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
13030 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
13031 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
13032 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
13033 }
13034#endif
Kailang Yangda00c242010-03-19 11:23:45 +010013035 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013036
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013037 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
13038
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013039 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
13040 alc262_models,
13041 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010013042
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013043 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013044 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13045 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010013046 board_config = ALC262_AUTO;
13047 }
13048
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013049 if (board_config == ALC262_AUTO) {
13050 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
13051 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
13052 }
Takashi Iwai18675e42010-09-08 15:55:44 +020013053
Kailang Yangdf694da2005-12-05 19:42:22 +010013054 if (board_config == ALC262_AUTO) {
13055 /* automatic parse from the BIOS config */
13056 err = alc262_parse_auto_config(codec);
13057 if (err < 0) {
13058 alc_free(codec);
13059 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013060 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013061 printk(KERN_INFO
13062 "hda_codec: Cannot set up configuration "
13063 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013064 board_config = ALC262_BASIC;
13065 }
13066 }
13067
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013068 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010013069 err = snd_hda_attach_beep_device(codec, 0x1);
13070 if (err < 0) {
13071 alc_free(codec);
13072 return err;
13073 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013074 }
13075
Kailang Yangdf694da2005-12-05 19:42:22 +010013076 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013077 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013078
Kailang Yangdf694da2005-12-05 19:42:22 +010013079 spec->stream_analog_playback = &alc262_pcm_analog_playback;
13080 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020013081
Kailang Yangdf694da2005-12-05 19:42:22 +010013082 spec->stream_digital_playback = &alc262_pcm_digital_playback;
13083 spec->stream_digital_capture = &alc262_pcm_digital_capture;
13084
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013085 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020013086 int i;
13087 /* check whether the digital-mic has to be supported */
13088 for (i = 0; i < spec->input_mux->num_items; i++) {
13089 if (spec->input_mux->items[i].index >= 9)
13090 break;
13091 }
13092 if (i < spec->input_mux->num_items) {
13093 /* use only ADC0 */
13094 spec->adc_nids = alc262_dmic_adc_nids;
13095 spec->num_adc_nids = 1;
13096 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010013097 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020013098 /* all analog inputs */
13099 /* check whether NID 0x07 is valid */
13100 unsigned int wcap = get_wcaps(codec, 0x07);
13101
13102 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013103 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020013104 if (wcap != AC_WID_AUD_IN) {
13105 spec->adc_nids = alc262_adc_nids_alt;
13106 spec->num_adc_nids =
13107 ARRAY_SIZE(alc262_adc_nids_alt);
13108 spec->capsrc_nids = alc262_capsrc_nids_alt;
13109 } else {
13110 spec->adc_nids = alc262_adc_nids;
13111 spec->num_adc_nids =
13112 ARRAY_SIZE(alc262_adc_nids);
13113 spec->capsrc_nids = alc262_capsrc_nids;
13114 }
Kailang Yangdf694da2005-12-05 19:42:22 +010013115 }
13116 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010013117 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013118 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013119 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010013120 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010013121
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013122 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020013123
Takashi Iwai2134ea42008-01-10 16:53:55 +010013124 spec->vmaster_nid = 0x0c;
13125
Kailang Yangdf694da2005-12-05 19:42:22 +010013126 codec->patch_ops = alc_patch_ops;
13127 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013128 spec->init_hook = alc262_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020013129 spec->shutup = alc_eapd_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020013130
13131 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020013132#ifdef CONFIG_SND_HDA_POWER_SAVE
13133 if (!spec->loopback.amplist)
13134 spec->loopback.amplist = alc262_loopbacks;
13135#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013136
Kailang Yangdf694da2005-12-05 19:42:22 +010013137 return 0;
13138}
13139
Kailang Yangdf694da2005-12-05 19:42:22 +010013140/*
Kailang Yanga361d842007-06-05 12:30:55 +020013141 * ALC268 channel source setting (2 channel)
13142 */
13143#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13144#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013145
Kailang Yanga361d842007-06-05 12:30:55 +020013146static hda_nid_t alc268_dac_nids[2] = {
13147 /* front, hp */
13148 0x02, 0x03
13149};
13150
13151static hda_nid_t alc268_adc_nids[2] = {
13152 /* ADC0-1 */
13153 0x08, 0x07
13154};
13155
13156static hda_nid_t alc268_adc_nids_alt[1] = {
13157 /* ADC0 */
13158 0x08
13159};
13160
Takashi Iwaie1406342008-02-11 18:32:32 +010013161static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13162
Kailang Yanga361d842007-06-05 12:30:55 +020013163static struct snd_kcontrol_new alc268_base_mixer[] = {
13164 /* output mixer control */
13165 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13166 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13167 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13168 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013169 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13170 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13171 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013172 { }
13173};
13174
Takashi Iwai42171c12009-05-08 14:11:43 +020013175static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13176 /* output mixer control */
13177 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13178 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13179 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013180 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13181 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13182 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013183 { }
13184};
13185
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013186/* bind Beep switches of both NID 0x0f and 0x10 */
13187static struct hda_bind_ctls alc268_bind_beep_sw = {
13188 .ops = &snd_hda_bind_sw,
13189 .values = {
13190 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13191 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13192 0
13193 },
13194};
13195
13196static struct snd_kcontrol_new alc268_beep_mixer[] = {
13197 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13198 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13199 { }
13200};
13201
Kailang Yangd1a991a2007-08-15 16:21:59 +020013202static struct hda_verb alc268_eapd_verbs[] = {
13203 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13204 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13205 { }
13206};
13207
Takashi Iwaid2738092007-08-16 14:59:45 +020013208/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013209static struct hda_verb alc268_toshiba_verbs[] = {
13210 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13211 { } /* end */
13212};
13213
13214/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013215/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013216static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13217 .ops = &snd_hda_bind_vol,
13218 .values = {
13219 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13220 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13221 0
13222 },
13223};
13224
Takashi Iwai889c4392007-08-23 18:56:52 +020013225/* mute/unmute internal speaker according to the hp jack and mute state */
13226static void alc268_acer_automute(struct hda_codec *codec, int force)
13227{
13228 struct alc_spec *spec = codec->spec;
13229 unsigned int mute;
13230
13231 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013232 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013233 spec->sense_updated = 1;
13234 }
13235 if (spec->jack_present)
13236 mute = HDA_AMP_MUTE; /* mute internal speaker */
13237 else /* unmute internal speaker if necessary */
13238 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13239 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13240 HDA_AMP_MUTE, mute);
13241}
13242
13243
13244/* bind hp and internal speaker mute (with plug check) */
13245static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13246 struct snd_ctl_elem_value *ucontrol)
13247{
13248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13249 long *valp = ucontrol->value.integer.value;
13250 int change;
13251
Takashi Iwai8de56b72009-07-24 16:51:47 +020013252 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013253 if (change)
13254 alc268_acer_automute(codec, 0);
13255 return change;
13256}
Takashi Iwaid2738092007-08-16 14:59:45 +020013257
Kailang Yang8ef355d2008-08-26 13:10:22 +020013258static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13259 /* output mixer control */
13260 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13261 {
13262 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13263 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013264 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013265 .info = snd_hda_mixer_amp_switch_info,
13266 .get = snd_hda_mixer_amp_switch_get,
13267 .put = alc268_acer_master_sw_put,
13268 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13269 },
13270 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13271 { }
13272};
13273
Takashi Iwaid2738092007-08-16 14:59:45 +020013274static struct snd_kcontrol_new alc268_acer_mixer[] = {
13275 /* output mixer control */
13276 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13277 {
13278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13279 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013280 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013281 .info = snd_hda_mixer_amp_switch_info,
13282 .get = snd_hda_mixer_amp_switch_get,
13283 .put = alc268_acer_master_sw_put,
13284 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13285 },
David Henningsson5f99f862011-01-04 15:24:24 +010013286 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13287 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13288 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013289 { }
13290};
13291
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013292static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13293 /* output mixer control */
13294 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13295 {
13296 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13297 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013298 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013299 .info = snd_hda_mixer_amp_switch_info,
13300 .get = snd_hda_mixer_amp_switch_get,
13301 .put = alc268_acer_master_sw_put,
13302 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13303 },
David Henningsson5f99f862011-01-04 15:24:24 +010013304 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13305 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013306 { }
13307};
13308
Kailang Yang8ef355d2008-08-26 13:10:22 +020013309static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13310 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13311 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13312 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13313 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13314 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13316 { }
13317};
13318
Takashi Iwaid2738092007-08-16 14:59:45 +020013319static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013320 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13321 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013322 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013324 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13325 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013326 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13327 { }
13328};
13329
13330/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013331#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013332#define alc268_toshiba_setup alc262_hippo_setup
13333#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013334
13335static void alc268_acer_unsol_event(struct hda_codec *codec,
13336 unsigned int res)
13337{
Takashi Iwai889c4392007-08-23 18:56:52 +020013338 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013339 return;
13340 alc268_acer_automute(codec, 1);
13341}
13342
Takashi Iwai889c4392007-08-23 18:56:52 +020013343static void alc268_acer_init_hook(struct hda_codec *codec)
13344{
13345 alc268_acer_automute(codec, 1);
13346}
13347
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013348static void alc268_acer_lc_setup(struct hda_codec *codec)
13349{
13350 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013351 spec->autocfg.hp_pins[0] = 0x15;
13352 spec->autocfg.speaker_pins[0] = 0x14;
13353 spec->automute_mixer_nid[0] = 0x0f;
13354 spec->automute = 1;
13355 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013356 spec->ext_mic.pin = 0x18;
13357 spec->ext_mic.mux_idx = 0;
13358 spec->int_mic.pin = 0x12;
13359 spec->int_mic.mux_idx = 6;
13360 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013361}
13362
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013363static struct snd_kcontrol_new alc268_dell_mixer[] = {
13364 /* output mixer control */
13365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13366 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13367 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, 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),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013371 { }
13372};
13373
13374static struct hda_verb alc268_dell_verbs[] = {
13375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13377 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013378 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013379 { }
13380};
13381
13382/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013383static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013384{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013385 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013386
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013387 spec->autocfg.hp_pins[0] = 0x15;
13388 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013389 spec->ext_mic.pin = 0x18;
13390 spec->ext_mic.mux_idx = 0;
13391 spec->int_mic.pin = 0x19;
13392 spec->int_mic.mux_idx = 1;
13393 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020013394 spec->automute = 1;
13395 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013396}
13397
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013398static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13399 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13400 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13401 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13403 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13404 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013405 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13406 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013407 { }
13408};
13409
13410static struct hda_verb alc267_quanta_il1_verbs[] = {
13411 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13412 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13413 { }
13414};
13415
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013416static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013418 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013419 spec->autocfg.hp_pins[0] = 0x15;
13420 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013421 spec->ext_mic.pin = 0x18;
13422 spec->ext_mic.mux_idx = 0;
13423 spec->int_mic.pin = 0x19;
13424 spec->int_mic.mux_idx = 1;
13425 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020013426 spec->automute = 1;
13427 spec->automute_mode = ALC_AUTOMUTE_PIN;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013428}
13429
Kailang Yanga361d842007-06-05 12:30:55 +020013430/*
13431 * generic initialization of ADC, input mixers and output mixers
13432 */
13433static struct hda_verb alc268_base_init_verbs[] = {
13434 /* Unmute DAC0-1 and set vol = 0 */
13435 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013436 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013437
13438 /*
13439 * Set up output mixers (0x0c - 0x0e)
13440 */
13441 /* set vol=0 to output mixers */
13442 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013443 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13444
13445 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13446 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13447
13448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13449 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13450 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13451 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13452 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13453 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13454 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13455 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13456
13457 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13458 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13459 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
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},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013462
13463 /* 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
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013468 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013469
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013470 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13471 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13472 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13473 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013474
Kailang Yanga361d842007-06-05 12:30:55 +020013475 { }
13476};
13477
13478/*
13479 * generic initialization of ADC, input mixers and output mixers
13480 */
13481static struct hda_verb alc268_volume_init_verbs[] = {
13482 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013483 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13484 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013485
13486 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13487 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13488 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13489 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13490 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13491
Kailang Yanga361d842007-06-05 12:30:55 +020013492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13494 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13495
13496 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013497 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013498
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013499 /* set PCBEEP vol = 0, mute connections */
13500 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13501 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13502 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013503
13504 { }
13505};
13506
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013507static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13508 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13509 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13510 { } /* end */
13511};
13512
Kailang Yanga361d842007-06-05 12:30:55 +020013513static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13514 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13515 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013516 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013517 { } /* end */
13518};
13519
13520static struct snd_kcontrol_new alc268_capture_mixer[] = {
13521 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13522 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13523 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13524 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013525 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013526 { } /* end */
13527};
13528
13529static struct hda_input_mux alc268_capture_source = {
13530 .num_items = 4,
13531 .items = {
13532 { "Mic", 0x0 },
13533 { "Front Mic", 0x1 },
13534 { "Line", 0x2 },
13535 { "CD", 0x3 },
13536 },
13537};
13538
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013539static struct hda_input_mux alc268_acer_capture_source = {
13540 .num_items = 3,
13541 .items = {
13542 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013543 { "Internal Mic", 0x1 },
13544 { "Line", 0x2 },
13545 },
13546};
13547
13548static struct hda_input_mux alc268_acer_dmic_capture_source = {
13549 .num_items = 3,
13550 .items = {
13551 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013552 { "Internal Mic", 0x6 },
13553 { "Line", 0x2 },
13554 },
13555};
13556
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013557#ifdef CONFIG_SND_DEBUG
13558static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013559 /* Volume widgets */
13560 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13561 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13562 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13563 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13564 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13565 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13566 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13567 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13568 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13569 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13570 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13571 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13572 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013573 /* The below appears problematic on some hardwares */
13574 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013575 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13576 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13577 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13578 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13579
13580 /* Modes for retasking pin widgets */
13581 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13582 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13583 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13584 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13585
13586 /* Controls for GPIO pins, assuming they are configured as outputs */
13587 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13588 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13589 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13590 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13591
13592 /* Switches to allow the digital SPDIF output pin to be enabled.
13593 * The ALC268 does not have an SPDIF input.
13594 */
13595 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13596
13597 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13598 * this output to turn on an external amplifier.
13599 */
13600 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13601 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13602
13603 { } /* end */
13604};
13605#endif
13606
Kailang Yanga361d842007-06-05 12:30:55 +020013607/* create input playback/capture controls for the given pin */
13608static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13609 const char *ctlname, int idx)
13610{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013611 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013612 int err;
13613
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013614 switch (nid) {
13615 case 0x14:
13616 case 0x16:
13617 dac = 0x02;
13618 break;
13619 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013620 case 0x1a: /* ALC259/269 only */
13621 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013622 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013623 dac = 0x03;
13624 break;
13625 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013626 snd_printd(KERN_WARNING "hda_codec: "
13627 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013628 return 0;
13629 }
13630 if (spec->multiout.dac_nids[0] != dac &&
13631 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013632 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013633 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013634 HDA_OUTPUT));
13635 if (err < 0)
13636 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013637 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13638 }
13639
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013640 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013641 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013642 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013643 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013644 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013645 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013646 if (err < 0)
13647 return err;
13648 return 0;
13649}
13650
13651/* add playback controls from the parsed DAC table */
13652static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13653 const struct auto_pin_cfg *cfg)
13654{
13655 hda_nid_t nid;
13656 int err;
13657
Kailang Yanga361d842007-06-05 12:30:55 +020013658 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013659
13660 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013661 if (nid) {
13662 const char *name;
13663 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13664 name = "Speaker";
13665 else
13666 name = "Front";
13667 err = alc268_new_analog_output(spec, nid, name, 0);
13668 if (err < 0)
13669 return err;
13670 }
Kailang Yanga361d842007-06-05 12:30:55 +020013671
13672 nid = cfg->speaker_pins[0];
13673 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013674 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013675 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13676 if (err < 0)
13677 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013678 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013679 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13680 if (err < 0)
13681 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013682 }
13683 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013684 if (nid) {
13685 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13686 if (err < 0)
13687 return err;
13688 }
Kailang Yanga361d842007-06-05 12:30:55 +020013689
13690 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13691 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013692 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013693 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013694 if (err < 0)
13695 return err;
13696 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013697 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013698}
13699
13700/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013701static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013702 const struct auto_pin_cfg *cfg)
13703{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013704 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013705}
13706
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013707static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13708 hda_nid_t nid, int pin_type)
13709{
13710 int idx;
13711
13712 alc_set_pin_output(codec, nid, pin_type);
13713 if (nid == 0x14 || nid == 0x16)
13714 idx = 0;
13715 else
13716 idx = 1;
13717 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13718}
13719
13720static void alc268_auto_init_multi_out(struct hda_codec *codec)
13721{
13722 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013723 int i;
13724
13725 for (i = 0; i < spec->autocfg.line_outs; i++) {
13726 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013727 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13728 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13729 }
13730}
13731
13732static void alc268_auto_init_hp_out(struct hda_codec *codec)
13733{
13734 struct alc_spec *spec = codec->spec;
13735 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013736 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013737
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013738 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13739 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013740 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013741 }
13742 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13743 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013744 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013745 }
13746 if (spec->autocfg.mono_out_pin)
13747 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13748 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013749}
13750
Kailang Yanga361d842007-06-05 12:30:55 +020013751static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13752{
13753 struct alc_spec *spec = codec->spec;
13754 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13755 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13756 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13757 unsigned int dac_vol1, dac_vol2;
13758
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013759 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013760 snd_hda_codec_write(codec, speaker_nid, 0,
13761 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013762 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013763 snd_hda_codec_write(codec, 0x0f, 0,
13764 AC_VERB_SET_AMP_GAIN_MUTE,
13765 AMP_IN_UNMUTE(1));
13766 snd_hda_codec_write(codec, 0x10, 0,
13767 AC_VERB_SET_AMP_GAIN_MUTE,
13768 AMP_IN_UNMUTE(1));
13769 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013770 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013771 snd_hda_codec_write(codec, 0x0f, 0,
13772 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13773 snd_hda_codec_write(codec, 0x10, 0,
13774 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13775 }
13776
13777 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013778 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013779 dac_vol2 = AMP_OUT_ZERO;
13780 else if (line_nid == 0x15)
13781 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013782 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013783 dac_vol2 = AMP_OUT_ZERO;
13784 else if (hp_nid == 0x15)
13785 dac_vol1 = AMP_OUT_ZERO;
13786 if (line_nid != 0x16 || hp_nid != 0x16 ||
13787 spec->autocfg.line_out_pins[1] != 0x16 ||
13788 spec->autocfg.line_out_pins[2] != 0x16)
13789 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13790
13791 snd_hda_codec_write(codec, 0x02, 0,
13792 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13793 snd_hda_codec_write(codec, 0x03, 0,
13794 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13795}
13796
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013797/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013798#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13799#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013800#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013801#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13802
13803/*
13804 * BIOS auto configuration
13805 */
13806static int alc268_parse_auto_config(struct hda_codec *codec)
13807{
13808 struct alc_spec *spec = codec->spec;
13809 int err;
13810 static hda_nid_t alc268_ignore[] = { 0 };
13811
13812 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13813 alc268_ignore);
13814 if (err < 0)
13815 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013816 if (!spec->autocfg.line_outs) {
13817 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13818 spec->multiout.max_channels = 2;
13819 spec->no_analog = 1;
13820 goto dig_only;
13821 }
Kailang Yanga361d842007-06-05 12:30:55 +020013822 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013823 }
Kailang Yanga361d842007-06-05 12:30:55 +020013824 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13825 if (err < 0)
13826 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013827 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013828 if (err < 0)
13829 return err;
13830
13831 spec->multiout.max_channels = 2;
13832
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013833 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013834 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013835 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013836 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013837 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013838
Takashi Iwai892981f2009-03-02 08:04:35 +010013839 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013840 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013841
Takashi Iwaid88897e2008-10-31 15:01:37 +010013842 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013843 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013844 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013845
Takashi Iwai776e1842007-08-29 15:07:11 +020013846 err = alc_auto_add_mic_boost(codec);
13847 if (err < 0)
13848 return err;
13849
Kailang Yang6227cdc2010-02-25 08:36:52 +010013850 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013851
Kailang Yanga361d842007-06-05 12:30:55 +020013852 return 1;
13853}
13854
Kailang Yanga361d842007-06-05 12:30:55 +020013855#define alc268_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013856#define alc268_auto_init_input_src alc882_auto_init_input_src
Kailang Yanga361d842007-06-05 12:30:55 +020013857
13858/* init callback for auto-configuration model -- overriding the default init */
13859static void alc268_auto_init(struct hda_codec *codec)
13860{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013861 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013862 alc268_auto_init_multi_out(codec);
13863 alc268_auto_init_hp_out(codec);
13864 alc268_auto_init_mono_speaker_out(codec);
13865 alc268_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013866 alc268_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013867 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013868 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013869 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013870}
13871
13872/*
13873 * configuration and preset
13874 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013875static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013876 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013877 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013878 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013879 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013880 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013881 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013882 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013883 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013884#ifdef CONFIG_SND_DEBUG
13885 [ALC268_TEST] = "test",
13886#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013887 [ALC268_AUTO] = "auto",
13888};
13889
13890static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013891 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013892 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013893 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013894 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013895 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013896 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13897 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013898 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013899 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13900 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013901 /* almost compatible with toshiba but with optional digital outs;
13902 * auto-probing seems working fine
13903 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013904 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013905 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013906 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013907 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013908 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013909 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013910 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013911 {}
13912};
13913
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013914/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13915static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13916 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13917 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13918 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13919 ALC268_TOSHIBA),
13920 {}
13921};
13922
Kailang Yanga361d842007-06-05 12:30:55 +020013923static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013924 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013925 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13926 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013927 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13928 alc267_quanta_il1_verbs },
13929 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13930 .dac_nids = alc268_dac_nids,
13931 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13932 .adc_nids = alc268_adc_nids_alt,
13933 .hp_nid = 0x03,
13934 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13935 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013936 .unsol_event = alc_sku_unsol_event,
13937 .setup = alc267_quanta_il1_setup,
13938 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013939 },
Kailang Yanga361d842007-06-05 12:30:55 +020013940 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013941 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13942 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013943 .init_verbs = { alc268_base_init_verbs },
13944 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13945 .dac_nids = alc268_dac_nids,
13946 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13947 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013948 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013949 .hp_nid = 0x03,
13950 .dig_out_nid = ALC268_DIGOUT_NID,
13951 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13952 .channel_mode = alc268_modes,
13953 .input_mux = &alc268_capture_source,
13954 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013955 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013956 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013957 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013958 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13959 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013960 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13961 .dac_nids = alc268_dac_nids,
13962 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13963 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013964 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013965 .hp_nid = 0x03,
13966 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13967 .channel_mode = alc268_modes,
13968 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013969 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013970 .setup = alc268_toshiba_setup,
13971 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013972 },
13973 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013974 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013975 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013976 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13977 alc268_acer_verbs },
13978 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13979 .dac_nids = alc268_dac_nids,
13980 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13981 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013982 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013983 .hp_nid = 0x02,
13984 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13985 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013986 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013987 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013988 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013989 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013990 [ALC268_ACER_DMIC] = {
13991 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13992 alc268_beep_mixer },
13993 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13994 alc268_acer_verbs },
13995 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13996 .dac_nids = alc268_dac_nids,
13997 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13998 .adc_nids = alc268_adc_nids_alt,
13999 .capsrc_nids = alc268_capsrc_nids,
14000 .hp_nid = 0x02,
14001 .num_channel_mode = ARRAY_SIZE(alc268_modes),
14002 .channel_mode = alc268_modes,
14003 .input_mux = &alc268_acer_dmic_capture_source,
14004 .unsol_event = alc268_acer_unsol_event,
14005 .init_hook = alc268_acer_init_hook,
14006 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020014007 [ALC268_ACER_ASPIRE_ONE] = {
14008 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010014009 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014010 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020014011 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
14012 alc268_acer_aspire_one_verbs },
14013 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
14014 .dac_nids = alc268_dac_nids,
14015 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
14016 .adc_nids = alc268_adc_nids_alt,
14017 .capsrc_nids = alc268_capsrc_nids,
14018 .hp_nid = 0x03,
14019 .num_channel_mode = ARRAY_SIZE(alc268_modes),
14020 .channel_mode = alc268_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014021 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014022 .setup = alc268_acer_lc_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014023 .init_hook = alc_inithook,
Kailang Yang8ef355d2008-08-26 13:10:22 +020014024 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014025 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014026 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
14027 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014028 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
14029 alc268_dell_verbs },
14030 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
14031 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014032 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
14033 .adc_nids = alc268_adc_nids_alt,
14034 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014035 .hp_nid = 0x02,
14036 .num_channel_mode = ARRAY_SIZE(alc268_modes),
14037 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014038 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014039 .setup = alc268_dell_setup,
14040 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014041 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010014042 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014043 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
14044 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010014045 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
14046 alc268_toshiba_verbs },
14047 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
14048 .dac_nids = alc268_dac_nids,
14049 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
14050 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010014051 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010014052 .hp_nid = 0x03,
14053 .dig_out_nid = ALC268_DIGOUT_NID,
14054 .num_channel_mode = ARRAY_SIZE(alc268_modes),
14055 .channel_mode = alc268_modes,
14056 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014057 .setup = alc268_toshiba_setup,
14058 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010014059 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010014060#ifdef CONFIG_SND_DEBUG
14061 [ALC268_TEST] = {
14062 .mixers = { alc268_test_mixer, alc268_capture_mixer },
14063 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
14064 alc268_volume_init_verbs },
14065 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
14066 .dac_nids = alc268_dac_nids,
14067 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
14068 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010014069 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010014070 .hp_nid = 0x03,
14071 .dig_out_nid = ALC268_DIGOUT_NID,
14072 .num_channel_mode = ARRAY_SIZE(alc268_modes),
14073 .channel_mode = alc268_modes,
14074 .input_mux = &alc268_capture_source,
14075 },
14076#endif
Kailang Yanga361d842007-06-05 12:30:55 +020014077};
14078
14079static int patch_alc268(struct hda_codec *codec)
14080{
14081 struct alc_spec *spec;
14082 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010014083 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020014084
Julia Lawallef86f582009-12-19 08:18:03 +010014085 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020014086 if (spec == NULL)
14087 return -ENOMEM;
14088
14089 codec->spec = spec;
14090
14091 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
14092 alc268_models,
14093 alc268_cfg_tbl);
14094
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014095 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
14096 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010014097 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014098
Kailang Yanga361d842007-06-05 12:30:55 +020014099 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014100 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14101 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020014102 board_config = ALC268_AUTO;
14103 }
14104
14105 if (board_config == ALC268_AUTO) {
14106 /* automatic parse from the BIOS config */
14107 err = alc268_parse_auto_config(codec);
14108 if (err < 0) {
14109 alc_free(codec);
14110 return err;
14111 } else if (!err) {
14112 printk(KERN_INFO
14113 "hda_codec: Cannot set up configuration "
14114 "from BIOS. Using base mode...\n");
14115 board_config = ALC268_3ST;
14116 }
14117 }
14118
14119 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014120 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014121
Kailang Yanga361d842007-06-05 12:30:55 +020014122 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14123 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014124 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014125
Kailang Yanga361d842007-06-05 12:30:55 +020014126 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14127
Takashi Iwai22971e32009-02-10 11:56:44 +010014128 has_beep = 0;
14129 for (i = 0; i < spec->num_mixers; i++) {
14130 if (spec->mixers[i] == alc268_beep_mixer) {
14131 has_beep = 1;
14132 break;
14133 }
14134 }
14135
14136 if (has_beep) {
14137 err = snd_hda_attach_beep_device(codec, 0x1);
14138 if (err < 0) {
14139 alc_free(codec);
14140 return err;
14141 }
14142 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14143 /* override the amp caps for beep generator */
14144 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014145 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14146 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14147 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14148 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014149 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014150
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014151 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014152 /* check whether NID 0x07 is valid */
14153 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020014154
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014155 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014156 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014157 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014158 if (spec->auto_mic ||
14159 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014160 spec->adc_nids = alc268_adc_nids_alt;
14161 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014162 if (spec->auto_mic)
14163 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014164 if (spec->auto_mic || spec->input_mux->num_items == 1)
14165 add_mixer(spec, alc268_capture_nosrc_mixer);
14166 else
14167 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014168 } else {
14169 spec->adc_nids = alc268_adc_nids;
14170 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014171 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014172 }
14173 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014174
14175 spec->vmaster_nid = 0x02;
14176
Kailang Yanga361d842007-06-05 12:30:55 +020014177 codec->patch_ops = alc_patch_ops;
14178 if (board_config == ALC268_AUTO)
14179 spec->init_hook = alc268_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020014180 spec->shutup = alc_eapd_shutup;
Kailang Yangea1fb292008-08-26 12:58:38 +020014181
Kailang Yangbf1b0222010-10-21 08:49:56 +020014182 alc_init_jacks(codec);
14183
Kailang Yanga361d842007-06-05 12:30:55 +020014184 return 0;
14185}
14186
14187/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014188 * ALC269 channel source setting (2 channel)
14189 */
14190#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14191
14192#define alc269_dac_nids alc260_dac_nids
14193
14194static hda_nid_t alc269_adc_nids[1] = {
14195 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014196 0x08,
14197};
14198
Takashi Iwaie01bf502008-08-21 16:25:07 +020014199static hda_nid_t alc269_capsrc_nids[1] = {
14200 0x23,
14201};
14202
Kailang Yang84898e82010-02-04 14:16:14 +010014203static hda_nid_t alc269vb_adc_nids[1] = {
14204 /* ADC1 */
14205 0x09,
14206};
14207
14208static hda_nid_t alc269vb_capsrc_nids[1] = {
14209 0x22,
14210};
14211
Takashi Iwai66946352010-03-29 17:21:45 +020014212static hda_nid_t alc269_adc_candidates[] = {
David Henningsson262ac222011-04-07 11:43:00 +020014213 0x08, 0x09, 0x07, 0x11,
Takashi Iwai66946352010-03-29 17:21:45 +020014214};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014215
Kailang Yangf6a92242007-12-13 16:52:54 +010014216#define alc269_modes alc260_modes
14217#define alc269_capture_source alc880_lg_lw_capture_source
14218
14219static struct snd_kcontrol_new alc269_base_mixer[] = {
14220 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14221 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014226 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014227 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14228 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014229 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14231 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14232 { } /* end */
14233};
14234
Kailang Yang60db6b52008-08-26 13:13:00 +020014235static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14236 /* output mixer control */
14237 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14238 {
14239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14240 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014241 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014242 .info = snd_hda_mixer_amp_switch_info,
14243 .get = snd_hda_mixer_amp_switch_get,
14244 .put = alc268_acer_master_sw_put,
14245 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14246 },
14247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014249 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014250 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14251 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014252 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014253 { }
14254};
14255
Tony Vroon64154832008-11-06 15:08:49 +000014256static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14257 /* output mixer control */
14258 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14259 {
14260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14261 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014262 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014263 .info = snd_hda_mixer_amp_switch_info,
14264 .get = snd_hda_mixer_amp_switch_get,
14265 .put = alc268_acer_master_sw_put,
14266 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14267 },
14268 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14269 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014270 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014271 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14272 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014273 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014274 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14275 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014276 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014277 { }
14278};
14279
Kailang Yang84898e82010-02-04 14:16:14 +010014280static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014281 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014282 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014283 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014284 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014285 { } /* end */
14286};
14287
Kailang Yang84898e82010-02-04 14:16:14 +010014288static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14289 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14290 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14292 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14293 { } /* end */
14294};
14295
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014296static struct snd_kcontrol_new alc269_asus_mixer[] = {
14297 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14298 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14299 { } /* end */
14300};
14301
Kailang Yangf6a92242007-12-13 16:52:54 +010014302/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014303static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14304 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14305 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014306 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14307 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014308 { } /* end */
14309};
14310
14311static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014312 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14313 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014314 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014315 { } /* end */
14316};
14317
Kailang Yang84898e82010-02-04 14:16:14 +010014318static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14319 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14320 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014321 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14322 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014323 { } /* end */
14324};
14325
14326static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14327 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14328 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014329 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014330 { } /* end */
14331};
14332
Takashi Iwai26f5df22008-11-03 17:39:46 +010014333/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014334#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014335
Kailang Yang60db6b52008-08-26 13:13:00 +020014336static struct hda_verb alc269_quanta_fl1_verbs[] = {
14337 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14338 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14339 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14340 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14341 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14342 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14343 { }
14344};
14345
Tony Vroon64154832008-11-06 15:08:49 +000014346static struct hda_verb alc269_lifebook_verbs[] = {
14347 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14348 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14349 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14351 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14352 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14353 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14354 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14355 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14356 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14357 { }
14358};
14359
Kailang Yang60db6b52008-08-26 13:13:00 +020014360/* toggle speaker-output according to the hp-jack state */
14361static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14362{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014363 alc_hp_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014364
14365 snd_hda_codec_write(codec, 0x20, 0,
14366 AC_VERB_SET_COEF_INDEX, 0x0c);
14367 snd_hda_codec_write(codec, 0x20, 0,
14368 AC_VERB_SET_PROC_COEF, 0x680);
14369
14370 snd_hda_codec_write(codec, 0x20, 0,
14371 AC_VERB_SET_COEF_INDEX, 0x0c);
14372 snd_hda_codec_write(codec, 0x20, 0,
14373 AC_VERB_SET_PROC_COEF, 0x480);
14374}
14375
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014376#define alc269_lifebook_speaker_automute \
14377 alc269_quanta_fl1_speaker_automute
Tony Vroon64154832008-11-06 15:08:49 +000014378
Tony Vroon64154832008-11-06 15:08:49 +000014379static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14380{
14381 unsigned int present_laptop;
14382 unsigned int present_dock;
14383
Wu Fengguang864f92b2009-11-18 12:38:02 +080014384 present_laptop = snd_hda_jack_detect(codec, 0x18);
14385 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014386
14387 /* Laptop mic port overrides dock mic port, design decision */
14388 if (present_dock)
14389 snd_hda_codec_write(codec, 0x23, 0,
14390 AC_VERB_SET_CONNECT_SEL, 0x3);
14391 if (present_laptop)
14392 snd_hda_codec_write(codec, 0x23, 0,
14393 AC_VERB_SET_CONNECT_SEL, 0x0);
14394 if (!present_dock && !present_laptop)
14395 snd_hda_codec_write(codec, 0x23, 0,
14396 AC_VERB_SET_CONNECT_SEL, 0x1);
14397}
14398
Kailang Yang60db6b52008-08-26 13:13:00 +020014399static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14400 unsigned int res)
14401{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014402 switch (res >> 26) {
14403 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014404 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014405 break;
14406 case ALC880_MIC_EVENT:
14407 alc_mic_automute(codec);
14408 break;
14409 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014410}
14411
Tony Vroon64154832008-11-06 15:08:49 +000014412static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14413 unsigned int res)
14414{
14415 if ((res >> 26) == ALC880_HP_EVENT)
14416 alc269_lifebook_speaker_automute(codec);
14417 if ((res >> 26) == ALC880_MIC_EVENT)
14418 alc269_lifebook_mic_autoswitch(codec);
14419}
14420
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014421static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14422{
14423 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014424 spec->autocfg.hp_pins[0] = 0x15;
14425 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014426 spec->automute_mixer_nid[0] = 0x0c;
14427 spec->automute = 1;
14428 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014429 spec->ext_mic.pin = 0x18;
14430 spec->ext_mic.mux_idx = 0;
14431 spec->int_mic.pin = 0x19;
14432 spec->int_mic.mux_idx = 1;
14433 spec->auto_mic = 1;
14434}
14435
Kailang Yang60db6b52008-08-26 13:13:00 +020014436static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14437{
14438 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014439 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014440}
14441
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014442static void alc269_lifebook_setup(struct hda_codec *codec)
14443{
14444 struct alc_spec *spec = codec->spec;
14445 spec->autocfg.hp_pins[0] = 0x15;
14446 spec->autocfg.hp_pins[1] = 0x1a;
14447 spec->autocfg.speaker_pins[0] = 0x14;
14448 spec->automute_mixer_nid[0] = 0x0c;
14449 spec->automute = 1;
14450 spec->automute_mode = ALC_AUTOMUTE_MIXER;
14451}
14452
Tony Vroon64154832008-11-06 15:08:49 +000014453static void alc269_lifebook_init_hook(struct hda_codec *codec)
14454{
14455 alc269_lifebook_speaker_automute(codec);
14456 alc269_lifebook_mic_autoswitch(codec);
14457}
14458
Kailang Yang84898e82010-02-04 14:16:14 +010014459static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014460 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14461 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14462 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14463 {0x08, 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 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14467 {}
14468};
14469
Kailang Yang84898e82010-02-04 14:16:14 +010014470static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014471 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14472 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14473 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14474 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14475 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14476 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14477 {}
14478};
14479
Kailang Yang84898e82010-02-04 14:16:14 +010014480static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14481 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14482 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14483 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14484 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14485 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14486 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14487 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14488 {}
14489};
14490
14491static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14492 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14493 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14494 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14495 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14496 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14497 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14498 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14499 {}
14500};
14501
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014502static struct hda_verb alc271_acer_dmic_verbs[] = {
14503 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14504 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14505 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14507 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14508 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14509 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14510 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14511 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14512 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14513 { }
14514};
14515
Kailang Yang226b1ec2010-04-09 11:01:20 +020014516static void alc269_laptop_amic_setup(struct hda_codec *codec)
14517{
14518 struct alc_spec *spec = codec->spec;
14519 spec->autocfg.hp_pins[0] = 0x15;
14520 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014521 spec->automute_mixer_nid[0] = 0x0c;
14522 spec->automute = 1;
14523 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014524 spec->ext_mic.pin = 0x18;
14525 spec->ext_mic.mux_idx = 0;
14526 spec->int_mic.pin = 0x19;
14527 spec->int_mic.mux_idx = 1;
14528 spec->auto_mic = 1;
14529}
14530
Kailang Yang84898e82010-02-04 14:16:14 +010014531static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014532{
14533 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014534 spec->autocfg.hp_pins[0] = 0x15;
14535 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014536 spec->automute_mixer_nid[0] = 0x0c;
14537 spec->automute = 1;
14538 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014539 spec->ext_mic.pin = 0x18;
14540 spec->ext_mic.mux_idx = 0;
14541 spec->int_mic.pin = 0x12;
14542 spec->int_mic.mux_idx = 5;
14543 spec->auto_mic = 1;
14544}
14545
Kailang Yang226b1ec2010-04-09 11:01:20 +020014546static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014547{
14548 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014549 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014550 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014551 spec->automute_mixer_nid[0] = 0x0c;
14552 spec->automute = 1;
14553 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014554 spec->ext_mic.pin = 0x18;
14555 spec->ext_mic.mux_idx = 0;
14556 spec->int_mic.pin = 0x19;
14557 spec->int_mic.mux_idx = 1;
14558 spec->auto_mic = 1;
14559}
14560
Kailang Yang226b1ec2010-04-09 11:01:20 +020014561static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14562{
14563 struct alc_spec *spec = codec->spec;
14564 spec->autocfg.hp_pins[0] = 0x21;
14565 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014566 spec->automute_mixer_nid[0] = 0x0c;
14567 spec->automute = 1;
14568 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014569 spec->ext_mic.pin = 0x18;
14570 spec->ext_mic.mux_idx = 0;
14571 spec->int_mic.pin = 0x12;
14572 spec->int_mic.mux_idx = 6;
14573 spec->auto_mic = 1;
14574}
14575
Kailang Yangf6a92242007-12-13 16:52:54 +010014576/*
14577 * generic initialization of ADC, input mixers and output mixers
14578 */
14579static struct hda_verb alc269_init_verbs[] = {
14580 /*
14581 * Unmute ADC0 and set the default input to mic-in
14582 */
Kailang Yang84898e82010-02-04 14:16:14 +010014583 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014584
14585 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014586 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014587 */
14588 /* set vol=0 to output mixers */
14589 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14590 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14591
14592 /* set up input amps for analog loopback */
14593 /* Amp Indices: DAC = 0, mixer = 1 */
14594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14597 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14600
14601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14603 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14604 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14605 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14606 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14607 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14608
14609 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014611
Kailang Yang84898e82010-02-04 14:16:14 +010014612 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014613 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14614 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014615 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014616
14617 /* set EAPD */
14618 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014619 { }
14620};
14621
14622static struct hda_verb alc269vb_init_verbs[] = {
14623 /*
14624 * Unmute ADC0 and set the default input to mic-in
14625 */
14626 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14627
14628 /*
14629 * Set up output mixers (0x02 - 0x03)
14630 */
14631 /* set vol=0 to output mixers */
14632 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14633 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14634
14635 /* set up input amps for analog loopback */
14636 /* Amp Indices: DAC = 0, mixer = 1 */
14637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14640 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14642 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14643
14644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14645 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14646 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14647 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14648 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14649 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14651
14652 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14653 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14654
14655 /* FIXME: use Mux-type input source selection */
14656 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14657 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14658 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14659
14660 /* set EAPD */
14661 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014662 { }
14663};
14664
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014665#define alc269_auto_create_multi_out_ctls \
14666 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014667#define alc269_auto_create_input_ctls \
14668 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014669
14670#ifdef CONFIG_SND_HDA_POWER_SAVE
14671#define alc269_loopbacks alc880_loopbacks
14672#endif
14673
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014674/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014675#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14676#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14677#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14678#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14679
Takashi Iwaif03d3112009-03-05 14:18:16 +010014680static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14681 .substreams = 1,
14682 .channels_min = 2,
14683 .channels_max = 8,
14684 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14685 /* NID is set in alc_build_pcms */
14686 .ops = {
14687 .open = alc880_playback_pcm_open,
14688 .prepare = alc880_playback_pcm_prepare,
14689 .cleanup = alc880_playback_pcm_cleanup
14690 },
14691};
14692
14693static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14694 .substreams = 1,
14695 .channels_min = 2,
14696 .channels_max = 2,
14697 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14698 /* NID is set in alc_build_pcms */
14699};
14700
Takashi Iwaiad358792010-03-30 18:00:59 +020014701#ifdef CONFIG_SND_HDA_POWER_SAVE
14702static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14703{
14704 switch (codec->subsystem_id) {
14705 case 0x103c1586:
14706 return 1;
14707 }
14708 return 0;
14709}
14710
14711static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14712{
14713 /* update mute-LED according to the speaker mute state */
14714 if (nid == 0x01 || nid == 0x14) {
14715 int pinval;
14716 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14717 HDA_AMP_MUTE)
14718 pinval = 0x24;
14719 else
14720 pinval = 0x20;
14721 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014722 snd_hda_codec_update_cache(codec, 0x19, 0,
14723 AC_VERB_SET_PIN_WIDGET_CONTROL,
14724 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014725 }
14726 return alc_check_power_status(codec, nid);
14727}
14728#endif /* CONFIG_SND_HDA_POWER_SAVE */
14729
Takashi Iwai840b64c2010-07-13 22:49:01 +020014730static int alc275_setup_dual_adc(struct hda_codec *codec)
14731{
14732 struct alc_spec *spec = codec->spec;
14733
14734 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14735 return 0;
14736 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14737 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14738 if (spec->ext_mic.pin <= 0x12) {
14739 spec->private_adc_nids[0] = 0x08;
14740 spec->private_adc_nids[1] = 0x11;
14741 spec->private_capsrc_nids[0] = 0x23;
14742 spec->private_capsrc_nids[1] = 0x22;
14743 } else {
14744 spec->private_adc_nids[0] = 0x11;
14745 spec->private_adc_nids[1] = 0x08;
14746 spec->private_capsrc_nids[0] = 0x22;
14747 spec->private_capsrc_nids[1] = 0x23;
14748 }
14749 spec->adc_nids = spec->private_adc_nids;
14750 spec->capsrc_nids = spec->private_capsrc_nids;
14751 spec->num_adc_nids = 2;
14752 spec->dual_adc_switch = 1;
14753 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14754 spec->adc_nids[0], spec->adc_nids[1]);
14755 return 1;
14756 }
14757 return 0;
14758}
14759
Takashi Iwaid433a672010-09-20 15:11:54 +020014760/* different alc269-variants */
14761enum {
14762 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014763 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014764 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014765 ALC269_TYPE_ALC269VB,
14766 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014767 ALC269_TYPE_ALC271X,
14768};
14769
Kailang Yangf6a92242007-12-13 16:52:54 +010014770/*
14771 * BIOS auto configuration
14772 */
14773static int alc269_parse_auto_config(struct hda_codec *codec)
14774{
14775 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014776 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014777 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14778
14779 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14780 alc269_ignore);
14781 if (err < 0)
14782 return err;
14783
14784 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14785 if (err < 0)
14786 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014787 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14788 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14789 else
14790 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14791 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014792 if (err < 0)
14793 return err;
14794
14795 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14796
Takashi Iwai757899a2010-07-30 10:48:14 +020014797 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014798
Takashi Iwai603c4012008-07-30 15:01:44 +020014799 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014800 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014801
Takashi Iwaid433a672010-09-20 15:11:54 +020014802 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014803 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014804 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014805 } else {
14806 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014807 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014808 }
14809
Kailang Yangf6a92242007-12-13 16:52:54 +010014810 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014811 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014812
14813 if (!alc275_setup_dual_adc(codec))
14814 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14815 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014816
Kailang Yangf6a92242007-12-13 16:52:54 +010014817 err = alc_auto_add_mic_boost(codec);
14818 if (err < 0)
14819 return err;
14820
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014821 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014822 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014823
Kailang Yangf6a92242007-12-13 16:52:54 +010014824 return 1;
14825}
14826
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014827#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14828#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014829#define alc269_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014830#define alc269_auto_init_input_src alc882_auto_init_input_src
Kailang Yangf6a92242007-12-13 16:52:54 +010014831
14832
14833/* init callback for auto-configuration model -- overriding the default init */
14834static void alc269_auto_init(struct hda_codec *codec)
14835{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014836 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014837 alc269_auto_init_multi_out(codec);
14838 alc269_auto_init_hp_out(codec);
14839 alc269_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014840 if (!spec->dual_adc_switch)
14841 alc269_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014842 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014843 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014844 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014845}
14846
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014847static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14848{
14849 int val = alc_read_coef_idx(codec, 0x04);
14850 if (power_up)
14851 val |= 1 << 11;
14852 else
14853 val &= ~(1 << 11);
14854 alc_write_coef_idx(codec, 0x04, val);
14855}
14856
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014857static void alc269_shutup(struct hda_codec *codec)
Kailang Yang977ddd62010-09-15 10:02:29 +020014858{
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014859 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14860 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014861 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014862 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014863 msleep(150);
14864 }
Kailang Yang977ddd62010-09-15 10:02:29 +020014865}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014866
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014867#ifdef SND_HDA_NEEDS_RESUME
Kailang Yang977ddd62010-09-15 10:02:29 +020014868static int alc269_resume(struct hda_codec *codec)
14869{
Kailang Yang977ddd62010-09-15 10:02:29 +020014870 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014871 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014872 msleep(150);
14873 }
14874
14875 codec->patch_ops.init(codec);
14876
14877 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014878 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014879 msleep(200);
14880 }
14881
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014882 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14883 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014884
14885 snd_hda_codec_resume_amp(codec);
14886 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014887 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014888 return 0;
14889}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014890#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014891
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014892static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014893 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014894{
14895 int coef;
14896
Takashi Iwai58701122011-01-13 15:41:45 +010014897 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014898 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014899 coef = alc_read_coef_idx(codec, 0x1e);
14900 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14901}
14902
Takashi Iwai6981d182011-04-15 10:11:12 +020014903static void alc271_fixup_dmic(struct hda_codec *codec,
14904 const struct alc_fixup *fix, int action)
14905{
14906 static struct hda_verb verbs[] = {
14907 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14908 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14909 {}
14910 };
14911 unsigned int cfg;
14912
14913 if (strcmp(codec->chip_name, "ALC271X"))
14914 return;
14915 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
14916 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
14917 snd_hda_sequence_write(codec, verbs);
14918}
14919
Takashi Iwaiff818c22010-04-12 08:59:25 +020014920enum {
14921 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014922 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014923 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014924 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014925 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014926 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014927 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwai6981d182011-04-15 10:11:12 +020014928 ALC271_FIXUP_DMIC,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014929};
14930
Takashi Iwaiff818c22010-04-12 08:59:25 +020014931static const struct alc_fixup alc269_fixups[] = {
14932 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014933 .type = ALC_FIXUP_VERBS,
14934 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014935 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14936 {}
14937 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014938 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014939 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014940 .type = ALC_FIXUP_VERBS,
14941 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014942 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14943 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14944 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14945 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014946 },
14947 .chained = true,
14948 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014949 },
David Henningsson145a9022010-09-16 10:07:53 +020014950 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014951 .type = ALC_FIXUP_VERBS,
14952 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014953 /* Enables internal speaker */
14954 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14955 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14956 {}
14957 }
14958 },
David Henningsson022c92b2010-12-17 20:43:04 +010014959 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014960 .type = ALC_FIXUP_SKU,
14961 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014962 },
David Henningssonac612402010-12-15 09:18:18 +010014963 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014964 .type = ALC_FIXUP_PINS,
14965 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014966 { 0x17, 0x99130111 }, /* subwoofer */
14967 { }
14968 }
14969 },
Kailang Yang357f9152011-01-12 08:12:52 +010014970 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014971 .type = ALC_FIXUP_VERBS,
14972 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014973 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14974 {}
14975 }
14976 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014977 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014978 .type = ALC_FIXUP_FUNC,
14979 .v.func = alc269_fixup_hweq,
14980 .chained = true,
14981 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Takashi Iwai6981d182011-04-15 10:11:12 +020014982 },
14983 [ALC271_FIXUP_DMIC] = {
14984 .type = ALC_FIXUP_FUNC,
14985 .v.func = alc271_fixup_dmic,
14986 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014987};
14988
14989static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014990 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014991 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14992 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014993 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014994 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwai6981d182011-04-15 10:11:12 +020014995 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
David Henningsson022c92b2010-12-17 20:43:04 +010014996 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014997 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14998 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14999 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
15000 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010015001 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010015002 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020015003 {}
15004};
15005
15006
Kailang Yangf6a92242007-12-13 16:52:54 +010015007/*
15008 * configuration and preset
15009 */
Takashi Iwaiea734962011-01-17 11:29:34 +010015010static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020015011 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020015012 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010015013 [ALC269_AMIC] = "laptop-amic",
15014 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000015015 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020015016 [ALC269_LIFEBOOK] = "lifebook",
15017 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010015018};
15019
15020static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020015021 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015022 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020015023 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010015024 ALC269_AMIC),
15025 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
15026 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
15027 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
15028 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
15029 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
15030 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
15031 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
15032 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
15033 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080015034 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010015035 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
15036 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
15037 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
15038 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
15039 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
15040 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
15041 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
15042 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
15043 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
15044 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
15045 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
15046 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
15047 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
15048 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
15049 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
15050 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
15051 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
15052 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
15053 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
15054 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
15055 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
15056 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
15057 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
15058 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
15059 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
15060 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020015061 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010015062 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020015063 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010015064 ALC269_DMIC),
15065 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
15066 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020015067 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000015068 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010015069 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
15070 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
15071 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
15072 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
15073 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
15074 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010015075 {}
15076};
15077
15078static struct alc_config_preset alc269_presets[] = {
15079 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015080 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010015081 .init_verbs = { alc269_init_verbs },
15082 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15083 .dac_nids = alc269_dac_nids,
15084 .hp_nid = 0x03,
15085 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15086 .channel_mode = alc269_modes,
15087 .input_mux = &alc269_capture_source,
15088 },
Kailang Yang60db6b52008-08-26 13:13:00 +020015089 [ALC269_QUANTA_FL1] = {
15090 .mixers = { alc269_quanta_fl1_mixer },
15091 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15092 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15093 .dac_nids = alc269_dac_nids,
15094 .hp_nid = 0x03,
15095 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15096 .channel_mode = alc269_modes,
15097 .input_mux = &alc269_capture_source,
15098 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015099 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015100 .init_hook = alc269_quanta_fl1_init_hook,
15101 },
Kailang Yang84898e82010-02-04 14:16:14 +010015102 [ALC269_AMIC] = {
15103 .mixers = { alc269_laptop_mixer },
15104 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015105 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015106 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015107 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15108 .dac_nids = alc269_dac_nids,
15109 .hp_nid = 0x03,
15110 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15111 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015112 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015113 .setup = alc269_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015114 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015115 },
Kailang Yang84898e82010-02-04 14:16:14 +010015116 [ALC269_DMIC] = {
15117 .mixers = { alc269_laptop_mixer },
15118 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015119 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015120 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015121 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15122 .dac_nids = alc269_dac_nids,
15123 .hp_nid = 0x03,
15124 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15125 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015126 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015127 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015128 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010015129 },
15130 [ALC269VB_AMIC] = {
15131 .mixers = { alc269vb_laptop_mixer },
15132 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15133 .init_verbs = { alc269vb_init_verbs,
15134 alc269vb_laptop_amic_init_verbs },
15135 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15136 .dac_nids = alc269_dac_nids,
15137 .hp_nid = 0x03,
15138 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15139 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015140 .unsol_event = alc_sku_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015141 .setup = alc269vb_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015142 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010015143 },
15144 [ALC269VB_DMIC] = {
15145 .mixers = { alc269vb_laptop_mixer },
15146 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15147 .init_verbs = { alc269vb_init_verbs,
15148 alc269vb_laptop_dmic_init_verbs },
15149 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15150 .dac_nids = alc269_dac_nids,
15151 .hp_nid = 0x03,
15152 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15153 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015154 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015155 .setup = alc269vb_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015156 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015157 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015158 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015159 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015160 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015161 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015162 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015163 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15164 .dac_nids = alc269_dac_nids,
15165 .hp_nid = 0x03,
15166 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15167 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015168 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015169 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015170 .init_hook = alc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015171 },
Tony Vroon64154832008-11-06 15:08:49 +000015172 [ALC269_LIFEBOOK] = {
15173 .mixers = { alc269_lifebook_mixer },
15174 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15175 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15176 .dac_nids = alc269_dac_nids,
15177 .hp_nid = 0x03,
15178 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15179 .channel_mode = alc269_modes,
15180 .input_mux = &alc269_capture_source,
15181 .unsol_event = alc269_lifebook_unsol_event,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015182 .setup = alc269_lifebook_setup,
Tony Vroon64154832008-11-06 15:08:49 +000015183 .init_hook = alc269_lifebook_init_hook,
15184 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015185 [ALC271_ACER] = {
15186 .mixers = { alc269_asus_mixer },
15187 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15188 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15189 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15190 .dac_nids = alc269_dac_nids,
15191 .adc_nids = alc262_dmic_adc_nids,
15192 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15193 .capsrc_nids = alc262_dmic_capsrc_nids,
15194 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15195 .channel_mode = alc269_modes,
15196 .input_mux = &alc269_capture_source,
15197 .dig_out_nid = ALC880_DIGOUT_NID,
15198 .unsol_event = alc_sku_unsol_event,
15199 .setup = alc269vb_laptop_dmic_setup,
15200 .init_hook = alc_inithook,
15201 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015202};
15203
Kailang Yang977ddd62010-09-15 10:02:29 +020015204static int alc269_fill_coef(struct hda_codec *codec)
15205{
15206 int val;
15207
15208 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15209 alc_write_coef_idx(codec, 0xf, 0x960b);
15210 alc_write_coef_idx(codec, 0xe, 0x8817);
15211 }
15212
15213 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15214 alc_write_coef_idx(codec, 0xf, 0x960b);
15215 alc_write_coef_idx(codec, 0xe, 0x8814);
15216 }
15217
15218 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15219 val = alc_read_coef_idx(codec, 0x04);
15220 /* Power up output pin */
15221 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15222 }
15223
15224 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15225 val = alc_read_coef_idx(codec, 0xd);
15226 if ((val & 0x0c00) >> 10 != 0x1) {
15227 /* Capless ramp up clock control */
15228 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15229 }
15230 val = alc_read_coef_idx(codec, 0x17);
15231 if ((val & 0x01c0) >> 6 != 0x4) {
15232 /* Class D power on reset */
15233 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15234 }
15235 }
15236 return 0;
15237}
15238
Kailang Yangf6a92242007-12-13 16:52:54 +010015239static int patch_alc269(struct hda_codec *codec)
15240{
15241 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015242 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015243 int err;
15244
15245 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15246 if (spec == NULL)
15247 return -ENOMEM;
15248
15249 codec->spec = spec;
15250
Kailang Yangda00c242010-03-19 11:23:45 +010015251 alc_auto_parse_customize_define(codec);
15252
Kailang Yangc793bec2010-12-21 09:14:13 +010015253 if (codec->vendor_id == 0x10ec0269) {
15254 coef = alc_read_coef_idx(codec, 0);
15255 if ((coef & 0x00f0) == 0x0010) {
15256 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15257 spec->cdefine.platform_type == 1) {
15258 alc_codec_rename(codec, "ALC271X");
15259 spec->codec_variant = ALC269_TYPE_ALC271X;
15260 } else if ((coef & 0xf000) == 0x1000) {
15261 spec->codec_variant = ALC269_TYPE_ALC270;
15262 } else if ((coef & 0xf000) == 0x2000) {
15263 alc_codec_rename(codec, "ALC259");
15264 spec->codec_variant = ALC269_TYPE_ALC259;
15265 } else if ((coef & 0xf000) == 0x3000) {
15266 alc_codec_rename(codec, "ALC258");
15267 spec->codec_variant = ALC269_TYPE_ALC258;
15268 } else {
15269 alc_codec_rename(codec, "ALC269VB");
15270 spec->codec_variant = ALC269_TYPE_ALC269VB;
15271 }
15272 } else
15273 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15274 alc269_fill_coef(codec);
15275 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015276
Kailang Yangf6a92242007-12-13 16:52:54 +010015277 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15278 alc269_models,
15279 alc269_cfg_tbl);
15280
15281 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015282 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15283 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015284 board_config = ALC269_AUTO;
15285 }
15286
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015287 if (board_config == ALC269_AUTO) {
15288 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15289 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15290 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015291
Kailang Yangf6a92242007-12-13 16:52:54 +010015292 if (board_config == ALC269_AUTO) {
15293 /* automatic parse from the BIOS config */
15294 err = alc269_parse_auto_config(codec);
15295 if (err < 0) {
15296 alc_free(codec);
15297 return err;
15298 } else if (!err) {
15299 printk(KERN_INFO
15300 "hda_codec: Cannot set up configuration "
15301 "from BIOS. Using base mode...\n");
15302 board_config = ALC269_BASIC;
15303 }
15304 }
15305
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015306 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015307 err = snd_hda_attach_beep_device(codec, 0x1);
15308 if (err < 0) {
15309 alc_free(codec);
15310 return err;
15311 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015312 }
15313
Kailang Yangf6a92242007-12-13 16:52:54 +010015314 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015315 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015316
Kailang Yang84898e82010-02-04 14:16:14 +010015317 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015318 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15319 * fix the sample rate of analog I/O to 44.1kHz
15320 */
15321 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15322 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015323 } else if (spec->dual_adc_switch) {
15324 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15325 /* switch ADC dynamically */
15326 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015327 } else {
15328 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15329 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15330 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015331 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15332 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15333
Takashi Iwai66946352010-03-29 17:21:45 +020015334 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015335 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015336 spec->adc_nids = alc269_adc_nids;
15337 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15338 spec->capsrc_nids = alc269_capsrc_nids;
15339 } else {
15340 spec->adc_nids = alc269vb_adc_nids;
15341 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15342 spec->capsrc_nids = alc269vb_capsrc_nids;
15343 }
Kailang Yang84898e82010-02-04 14:16:14 +010015344 }
15345
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015346 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015347 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015348 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015349 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015350
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015351 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015352
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015353 spec->vmaster_nid = 0x02;
15354
Kailang Yangf6a92242007-12-13 16:52:54 +010015355 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015356#ifdef SND_HDA_NEEDS_RESUME
15357 codec->patch_ops.resume = alc269_resume;
15358#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015359 if (board_config == ALC269_AUTO)
15360 spec->init_hook = alc269_auto_init;
Takashi Iwai5402e4c2011-04-07 10:39:25 +020015361 spec->shutup = alc269_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015362
15363 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015364#ifdef CONFIG_SND_HDA_POWER_SAVE
15365 if (!spec->loopback.amplist)
15366 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015367 if (alc269_mic2_for_mute_led(codec))
15368 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015369#endif
15370
15371 return 0;
15372}
15373
15374/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015375 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15376 */
15377
15378/*
15379 * set the path ways for 2 channel output
15380 * need to set the codec line out and mic 1 pin widgets to inputs
15381 */
15382static struct hda_verb alc861_threestack_ch2_init[] = {
15383 /* set pin widget 1Ah (line in) for input */
15384 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015385 /* set pin widget 18h (mic1/2) for input, for mic also enable
15386 * the vref
15387 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015388 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15389
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015390 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15391#if 0
15392 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15393 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15394#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015395 { } /* end */
15396};
15397/*
15398 * 6ch mode
15399 * need to set the codec line out and mic 1 pin widgets to outputs
15400 */
15401static struct hda_verb alc861_threestack_ch6_init[] = {
15402 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15403 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15404 /* set pin widget 18h (mic1) for output (CLFE)*/
15405 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15406
15407 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015408 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015409
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015410 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15411#if 0
15412 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15413 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15414#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015415 { } /* end */
15416};
15417
15418static struct hda_channel_mode alc861_threestack_modes[2] = {
15419 { 2, alc861_threestack_ch2_init },
15420 { 6, alc861_threestack_ch6_init },
15421};
Takashi Iwai22309c32006-08-09 16:57:28 +020015422/* Set mic1 as input and unmute the mixer */
15423static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15424 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15425 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15426 { } /* end */
15427};
15428/* Set mic1 as output and mute mixer */
15429static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15430 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15431 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15432 { } /* end */
15433};
15434
15435static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15436 { 2, alc861_uniwill_m31_ch2_init },
15437 { 4, alc861_uniwill_m31_ch4_init },
15438};
Kailang Yangdf694da2005-12-05 19:42:22 +010015439
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015440/* Set mic1 and line-in as input and unmute the mixer */
15441static struct hda_verb alc861_asus_ch2_init[] = {
15442 /* set pin widget 1Ah (line in) for input */
15443 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015444 /* set pin widget 18h (mic1/2) for input, for mic also enable
15445 * the vref
15446 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015447 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15448
15449 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15450#if 0
15451 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15452 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15453#endif
15454 { } /* end */
15455};
15456/* Set mic1 nad line-in as output and mute mixer */
15457static struct hda_verb alc861_asus_ch6_init[] = {
15458 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15459 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15460 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15461 /* set pin widget 18h (mic1) for output (CLFE)*/
15462 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15463 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15464 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15465 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15466
15467 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15468#if 0
15469 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15470 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15471#endif
15472 { } /* end */
15473};
15474
15475static struct hda_channel_mode alc861_asus_modes[2] = {
15476 { 2, alc861_asus_ch2_init },
15477 { 6, alc861_asus_ch6_init },
15478};
15479
Kailang Yangdf694da2005-12-05 19:42:22 +010015480/* patch-ALC861 */
15481
15482static struct snd_kcontrol_new alc861_base_mixer[] = {
15483 /* output mixer control */
15484 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15485 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15486 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15487 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15488 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15489
15490 /*Input mixer control */
15491 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15492 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15493 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15494 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15495 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15496 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15497 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15498 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15499 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15500 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015501
Kailang Yangdf694da2005-12-05 19:42:22 +010015502 { } /* end */
15503};
15504
15505static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15506 /* output mixer control */
15507 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15508 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15509 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15510 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15511 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15512
15513 /* Input mixer control */
15514 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15515 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15516 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15517 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15518 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15519 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15521 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15522 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15523 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015524
Kailang Yangdf694da2005-12-05 19:42:22 +010015525 {
15526 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15527 .name = "Channel Mode",
15528 .info = alc_ch_mode_info,
15529 .get = alc_ch_mode_get,
15530 .put = alc_ch_mode_put,
15531 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15532 },
15533 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015534};
15535
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015536static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015537 /* output mixer control */
15538 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15540 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015541
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015542 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015543};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015544
Takashi Iwai22309c32006-08-09 16:57:28 +020015545static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15546 /* output mixer control */
15547 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15548 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15549 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15550 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15551 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15552
15553 /* Input mixer control */
15554 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15555 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15556 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15557 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15558 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15559 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15561 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15562 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015564
Takashi Iwai22309c32006-08-09 16:57:28 +020015565 {
15566 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15567 .name = "Channel Mode",
15568 .info = alc_ch_mode_info,
15569 .get = alc_ch_mode_get,
15570 .put = alc_ch_mode_put,
15571 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15572 },
15573 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015574};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015575
15576static struct snd_kcontrol_new alc861_asus_mixer[] = {
15577 /* output mixer control */
15578 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15579 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15580 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15581 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15582 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15583
15584 /* Input mixer control */
15585 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15586 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15587 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15588 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15589 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15590 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15592 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015594 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15595
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015596 {
15597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15598 .name = "Channel Mode",
15599 .info = alc_ch_mode_info,
15600 .get = alc_ch_mode_get,
15601 .put = alc_ch_mode_put,
15602 .private_value = ARRAY_SIZE(alc861_asus_modes),
15603 },
15604 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015605};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015606
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015607/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015608static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015609 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15610 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015611 { }
15612};
15613
Kailang Yangdf694da2005-12-05 19:42:22 +010015614/*
15615 * generic initialization of ADC, input mixers and output mixers
15616 */
15617static struct hda_verb alc861_base_init_verbs[] = {
15618 /*
15619 * Unmute ADC0 and set the default input to mic-in
15620 */
15621 /* port-A for surround (rear panel) */
15622 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15623 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15624 /* port-B for mic-in (rear panel) with vref */
15625 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15626 /* port-C for line-in (rear panel) */
15627 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15628 /* port-D for Front */
15629 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15630 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15631 /* port-E for HP out (front panel) */
15632 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15633 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015634 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015635 /* port-F for mic-in (front panel) with vref */
15636 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15637 /* port-G for CLFE (rear panel) */
15638 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15639 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15640 /* port-H for side (rear panel) */
15641 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15642 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15643 /* CD-in */
15644 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15645 /* route front mic to ADC1*/
15646 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15647 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015648
Kailang Yangdf694da2005-12-05 19:42:22 +010015649 /* Unmute DAC0~3 & spdif out*/
15650 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15651 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15652 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15653 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015655
Kailang Yangdf694da2005-12-05 19:42:22 +010015656 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15657 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15658 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15659 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15660 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015661
Kailang Yangdf694da2005-12-05 19:42:22 +010015662 /* Unmute Stereo Mixer 15 */
15663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015667
15668 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15669 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15670 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15671 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15672 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15673 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15674 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15675 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015676 /* hp used DAC 3 (Front) */
15677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015678 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15679
15680 { }
15681};
15682
15683static struct hda_verb alc861_threestack_init_verbs[] = {
15684 /*
15685 * Unmute ADC0 and set the default input to mic-in
15686 */
15687 /* port-A for surround (rear panel) */
15688 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15689 /* port-B for mic-in (rear panel) with vref */
15690 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15691 /* port-C for line-in (rear panel) */
15692 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15693 /* port-D for Front */
15694 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15695 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15696 /* port-E for HP out (front panel) */
15697 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15698 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015699 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015700 /* port-F for mic-in (front panel) with vref */
15701 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15702 /* port-G for CLFE (rear panel) */
15703 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15704 /* port-H for side (rear panel) */
15705 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15706 /* CD-in */
15707 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15708 /* route front mic to ADC1*/
15709 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15710 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15711 /* Unmute DAC0~3 & spdif out*/
15712 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15713 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15714 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15715 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015717
Kailang Yangdf694da2005-12-05 19:42:22 +010015718 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15719 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15720 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15721 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15722 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015723
Kailang Yangdf694da2005-12-05 19:42:22 +010015724 /* Unmute Stereo Mixer 15 */
15725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15726 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015728 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015729
15730 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15731 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15732 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15733 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15734 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15735 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15736 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15737 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015738 /* hp used DAC 3 (Front) */
15739 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015740 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15741 { }
15742};
Takashi Iwai22309c32006-08-09 16:57:28 +020015743
15744static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15745 /*
15746 * Unmute ADC0 and set the default input to mic-in
15747 */
15748 /* port-A for surround (rear panel) */
15749 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15750 /* port-B for mic-in (rear panel) with vref */
15751 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15752 /* port-C for line-in (rear panel) */
15753 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15754 /* port-D for Front */
15755 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15756 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15757 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015758 /* this has to be set to VREF80 */
15759 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015760 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015761 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015762 /* port-F for mic-in (front panel) with vref */
15763 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15764 /* port-G for CLFE (rear panel) */
15765 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15766 /* port-H for side (rear panel) */
15767 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15768 /* CD-in */
15769 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15770 /* route front mic to ADC1*/
15771 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15773 /* Unmute DAC0~3 & spdif out*/
15774 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15775 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15776 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15777 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15778 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015779
Takashi Iwai22309c32006-08-09 16:57:28 +020015780 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15781 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15782 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15783 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15784 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015785
Takashi Iwai22309c32006-08-09 16:57:28 +020015786 /* Unmute Stereo Mixer 15 */
15787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015791
15792 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15793 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15794 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15795 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15796 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15797 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15798 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15799 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015800 /* hp used DAC 3 (Front) */
15801 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015802 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15803 { }
15804};
15805
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015806static struct hda_verb alc861_asus_init_verbs[] = {
15807 /*
15808 * Unmute ADC0 and set the default input to mic-in
15809 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015810 /* port-A for surround (rear panel)
15811 * according to codec#0 this is the HP jack
15812 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015813 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15814 /* route front PCM to HP */
15815 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15816 /* port-B for mic-in (rear panel) with vref */
15817 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15818 /* port-C for line-in (rear panel) */
15819 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15820 /* port-D for Front */
15821 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15822 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15823 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015824 /* this has to be set to VREF80 */
15825 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015826 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015827 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015828 /* port-F for mic-in (front panel) with vref */
15829 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15830 /* port-G for CLFE (rear panel) */
15831 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15832 /* port-H for side (rear panel) */
15833 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15834 /* CD-in */
15835 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15836 /* route front mic to ADC1*/
15837 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15838 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15839 /* Unmute DAC0~3 & spdif out*/
15840 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15841 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15842 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15843 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15845 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15846 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15847 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15848 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15849 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015850
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015851 /* Unmute Stereo Mixer 15 */
15852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015856
15857 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15858 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15859 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15860 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15861 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15863 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15864 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015865 /* hp used DAC 3 (Front) */
15866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015867 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15868 { }
15869};
15870
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015871/* additional init verbs for ASUS laptops */
15872static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15873 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15874 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15875 { }
15876};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015877
Kailang Yangdf694da2005-12-05 19:42:22 +010015878/*
15879 * generic initialization of ADC, input mixers and output mixers
15880 */
15881static struct hda_verb alc861_auto_init_verbs[] = {
15882 /*
15883 * Unmute ADC0 and set the default input to mic-in
15884 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015885 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015886 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015887
Kailang Yangdf694da2005-12-05 19:42:22 +010015888 /* Unmute DAC0~3 & spdif out*/
15889 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15890 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15891 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15892 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15893 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015894
Kailang Yangdf694da2005-12-05 19:42:22 +010015895 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15896 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15897 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15898 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15899 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015900
Kailang Yangdf694da2005-12-05 19:42:22 +010015901 /* Unmute Stereo Mixer 15 */
15902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15903 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15904 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15906
Takashi Iwai1c209302009-07-22 15:17:45 +020015907 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15908 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15909 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15910 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15911 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15912 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15913 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15914 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015915
15916 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15917 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015918 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15919 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015920 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15921 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015922 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15923 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015924
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015925 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015926
15927 { }
15928};
15929
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015930static struct hda_verb alc861_toshiba_init_verbs[] = {
15931 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015932
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015933 { }
15934};
15935
15936/* toggle speaker-output according to the hp-jack state */
15937static void alc861_toshiba_automute(struct hda_codec *codec)
15938{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015939 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015940
Takashi Iwai47fd8302007-08-10 17:11:07 +020015941 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15942 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15943 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15944 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015945}
15946
15947static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15948 unsigned int res)
15949{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015950 if ((res >> 26) == ALC880_HP_EVENT)
15951 alc861_toshiba_automute(codec);
15952}
15953
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015954/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015955#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15956#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15957#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15958#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15959
15960
15961#define ALC861_DIGOUT_NID 0x07
15962
15963static struct hda_channel_mode alc861_8ch_modes[1] = {
15964 { 8, NULL }
15965};
15966
15967static hda_nid_t alc861_dac_nids[4] = {
15968 /* front, surround, clfe, side */
15969 0x03, 0x06, 0x05, 0x04
15970};
15971
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015972static hda_nid_t alc660_dac_nids[3] = {
15973 /* front, clfe, surround */
15974 0x03, 0x05, 0x06
15975};
15976
Kailang Yangdf694da2005-12-05 19:42:22 +010015977static hda_nid_t alc861_adc_nids[1] = {
15978 /* ADC0-2 */
15979 0x08,
15980};
15981
15982static struct hda_input_mux alc861_capture_source = {
15983 .num_items = 5,
15984 .items = {
15985 { "Mic", 0x0 },
15986 { "Front Mic", 0x3 },
15987 { "Line", 0x1 },
15988 { "CD", 0x4 },
15989 { "Mixer", 0x5 },
15990 },
15991};
15992
Takashi Iwai1c209302009-07-22 15:17:45 +020015993static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15994{
15995 struct alc_spec *spec = codec->spec;
15996 hda_nid_t mix, srcs[5];
15997 int i, j, num;
15998
15999 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
16000 return 0;
16001 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16002 if (num < 0)
16003 return 0;
16004 for (i = 0; i < num; i++) {
16005 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020016006 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020016007 if (type != AC_WID_AUD_OUT)
16008 continue;
16009 for (j = 0; j < spec->multiout.num_dacs; j++)
16010 if (spec->multiout.dac_nids[j] == srcs[i])
16011 break;
16012 if (j >= spec->multiout.num_dacs)
16013 return srcs[i];
16014 }
16015 return 0;
16016}
16017
Kailang Yangdf694da2005-12-05 19:42:22 +010016018/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020016019static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016020 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016021{
Takashi Iwai1c209302009-07-22 15:17:45 +020016022 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016023 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020016024 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010016025
16026 spec->multiout.dac_nids = spec->private_dac_nids;
16027 for (i = 0; i < cfg->line_outs; i++) {
16028 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020016029 dac = alc861_look_for_dac(codec, nid);
16030 if (!dac)
16031 continue;
16032 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010016033 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016034 return 0;
16035}
16036
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016037static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
16038 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016039{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016040 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020016041 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
16042}
16043
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016044#define alc861_create_out_sw(codec, pfx, nid, chs) \
16045 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
16046
Takashi Iwai1c209302009-07-22 15:17:45 +020016047/* add playback controls from the parsed DAC table */
16048static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
16049 const struct auto_pin_cfg *cfg)
16050{
16051 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010016052 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016053 "Front", "Surround", NULL /*CLFE*/, "Side"
16054 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020016055 const char *pfx = alc_get_line_out_pfx(spec, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010016056 hda_nid_t nid;
Takashi Iwaice764ab2011-04-27 16:35:23 +020016057 int i, err, noutputs;
Takashi Iwai1c209302009-07-22 15:17:45 +020016058
Takashi Iwaice764ab2011-04-27 16:35:23 +020016059 noutputs = cfg->line_outs;
16060 if (spec->multi_ios > 0)
16061 noutputs += spec->multi_ios;
16062
16063 for (i = 0; i < noutputs; i++) {
Kailang Yangdf694da2005-12-05 19:42:22 +010016064 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016065 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010016066 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016067 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010016068 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020016069 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016070 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016071 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016072 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016073 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016074 return err;
16075 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016076 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010016077 int index = i;
16078 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016079 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010016080 index = 0;
16081 }
16082 err = __alc861_create_out_sw(codec, name, nid, index, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016083 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016084 return err;
16085 }
16086 }
16087 return 0;
16088}
16089
Takashi Iwai1c209302009-07-22 15:17:45 +020016090static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016091{
Takashi Iwai1c209302009-07-22 15:17:45 +020016092 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016093 int err;
16094 hda_nid_t nid;
16095
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016096 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016097 return 0;
16098
16099 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016100 nid = alc861_look_for_dac(codec, pin);
16101 if (nid) {
16102 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16103 if (err < 0)
16104 return err;
16105 spec->multiout.hp_nid = nid;
16106 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016107 }
16108 return 0;
16109}
16110
16111/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016112static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016113 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016114{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016115 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016116}
16117
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016118static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16119 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016120 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016121{
Takashi Iwai1c209302009-07-22 15:17:45 +020016122 hda_nid_t mix, srcs[5];
16123 int i, num;
16124
Jacek Luczak564c5be2008-05-03 18:41:23 +020016125 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16126 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016127 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016128 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016129 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16130 return;
16131 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16132 if (num < 0)
16133 return;
16134 for (i = 0; i < num; i++) {
16135 unsigned int mute;
16136 if (srcs[i] == dac || srcs[i] == 0x15)
16137 mute = AMP_IN_UNMUTE(i);
16138 else
16139 mute = AMP_IN_MUTE(i);
16140 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16141 mute);
16142 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016143}
16144
16145static void alc861_auto_init_multi_out(struct hda_codec *codec)
16146{
16147 struct alc_spec *spec = codec->spec;
16148 int i;
16149
16150 for (i = 0; i < spec->autocfg.line_outs; i++) {
16151 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016152 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016153 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016154 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016155 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016156 }
16157}
16158
16159static void alc861_auto_init_hp_out(struct hda_codec *codec)
16160{
16161 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016162
Takashi Iwai15870f02009-10-05 08:25:13 +020016163 if (spec->autocfg.hp_outs)
16164 alc861_auto_set_output_and_unmute(codec,
16165 spec->autocfg.hp_pins[0],
16166 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016167 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016168 if (spec->autocfg.speaker_outs)
16169 alc861_auto_set_output_and_unmute(codec,
16170 spec->autocfg.speaker_pins[0],
16171 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016172 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016173}
16174
16175static void alc861_auto_init_analog_input(struct hda_codec *codec)
16176{
16177 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016178 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016179 int i;
16180
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016181 for (i = 0; i < cfg->num_inputs; i++) {
16182 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016183 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016184 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016185 }
16186}
16187
16188/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016189/* return 1 if successful, 0 if the proper config is not found,
16190 * or a negative error code
16191 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016192static int alc861_parse_auto_config(struct hda_codec *codec)
16193{
16194 struct alc_spec *spec = codec->spec;
16195 int err;
16196 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16197
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016198 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16199 alc861_ignore);
16200 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016201 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016202 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016203 return 0; /* can't find valid BIOS pin config */
16204
Takashi Iwai1c209302009-07-22 15:17:45 +020016205 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016206 if (err < 0)
16207 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020016208 err = alc_auto_add_multi_channel_mode(codec);
16209 if (err < 0)
16210 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016211 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016212 if (err < 0)
16213 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016214 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016215 if (err < 0)
16216 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016217 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016218 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016219 return err;
16220
16221 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16222
Takashi Iwai757899a2010-07-30 10:48:14 +020016223 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016224
Takashi Iwai603c4012008-07-30 15:01:44 +020016225 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016226 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016227
Takashi Iwaid88897e2008-10-31 15:01:37 +010016228 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016229
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016230 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016231 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016232
16233 spec->adc_nids = alc861_adc_nids;
16234 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016235 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016236
Kailang Yang6227cdc2010-02-25 08:36:52 +010016237 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016238
Kailang Yangdf694da2005-12-05 19:42:22 +010016239 return 1;
16240}
16241
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016242/* additional initialization for auto-configuration model */
16243static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016244{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016245 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016246 alc861_auto_init_multi_out(codec);
16247 alc861_auto_init_hp_out(codec);
16248 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016249 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016250 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016251 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016252}
16253
Takashi Iwaicb53c622007-08-10 17:21:45 +020016254#ifdef CONFIG_SND_HDA_POWER_SAVE
16255static struct hda_amp_list alc861_loopbacks[] = {
16256 { 0x15, HDA_INPUT, 0 },
16257 { 0x15, HDA_INPUT, 1 },
16258 { 0x15, HDA_INPUT, 2 },
16259 { 0x15, HDA_INPUT, 3 },
16260 { } /* end */
16261};
16262#endif
16263
Kailang Yangdf694da2005-12-05 19:42:22 +010016264
16265/*
16266 * configuration and preset
16267 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016268static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016269 [ALC861_3ST] = "3stack",
16270 [ALC660_3ST] = "3stack-660",
16271 [ALC861_3ST_DIG] = "3stack-dig",
16272 [ALC861_6ST_DIG] = "6stack-dig",
16273 [ALC861_UNIWILL_M31] = "uniwill-m31",
16274 [ALC861_TOSHIBA] = "toshiba",
16275 [ALC861_ASUS] = "asus",
16276 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16277 [ALC861_AUTO] = "auto",
16278};
16279
16280static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016281 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016282 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16283 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16284 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016285 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016286 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016287 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016288 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16289 * Any other models that need this preset?
16290 */
16291 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016292 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16293 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016294 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16295 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16296 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16297 /* FIXME: the below seems conflict */
16298 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16299 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16300 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016301 {}
16302};
16303
16304static struct alc_config_preset alc861_presets[] = {
16305 [ALC861_3ST] = {
16306 .mixers = { alc861_3ST_mixer },
16307 .init_verbs = { alc861_threestack_init_verbs },
16308 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16309 .dac_nids = alc861_dac_nids,
16310 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16311 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016312 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016313 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16314 .adc_nids = alc861_adc_nids,
16315 .input_mux = &alc861_capture_source,
16316 },
16317 [ALC861_3ST_DIG] = {
16318 .mixers = { alc861_base_mixer },
16319 .init_verbs = { alc861_threestack_init_verbs },
16320 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16321 .dac_nids = alc861_dac_nids,
16322 .dig_out_nid = ALC861_DIGOUT_NID,
16323 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16324 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016325 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016326 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16327 .adc_nids = alc861_adc_nids,
16328 .input_mux = &alc861_capture_source,
16329 },
16330 [ALC861_6ST_DIG] = {
16331 .mixers = { alc861_base_mixer },
16332 .init_verbs = { alc861_base_init_verbs },
16333 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16334 .dac_nids = alc861_dac_nids,
16335 .dig_out_nid = ALC861_DIGOUT_NID,
16336 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16337 .channel_mode = alc861_8ch_modes,
16338 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16339 .adc_nids = alc861_adc_nids,
16340 .input_mux = &alc861_capture_source,
16341 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016342 [ALC660_3ST] = {
16343 .mixers = { alc861_3ST_mixer },
16344 .init_verbs = { alc861_threestack_init_verbs },
16345 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16346 .dac_nids = alc660_dac_nids,
16347 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16348 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016349 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016350 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16351 .adc_nids = alc861_adc_nids,
16352 .input_mux = &alc861_capture_source,
16353 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016354 [ALC861_UNIWILL_M31] = {
16355 .mixers = { alc861_uniwill_m31_mixer },
16356 .init_verbs = { alc861_uniwill_m31_init_verbs },
16357 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16358 .dac_nids = alc861_dac_nids,
16359 .dig_out_nid = ALC861_DIGOUT_NID,
16360 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16361 .channel_mode = alc861_uniwill_m31_modes,
16362 .need_dac_fix = 1,
16363 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16364 .adc_nids = alc861_adc_nids,
16365 .input_mux = &alc861_capture_source,
16366 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016367 [ALC861_TOSHIBA] = {
16368 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016369 .init_verbs = { alc861_base_init_verbs,
16370 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016371 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16372 .dac_nids = alc861_dac_nids,
16373 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16374 .channel_mode = alc883_3ST_2ch_modes,
16375 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16376 .adc_nids = alc861_adc_nids,
16377 .input_mux = &alc861_capture_source,
16378 .unsol_event = alc861_toshiba_unsol_event,
16379 .init_hook = alc861_toshiba_automute,
16380 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016381 [ALC861_ASUS] = {
16382 .mixers = { alc861_asus_mixer },
16383 .init_verbs = { alc861_asus_init_verbs },
16384 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16385 .dac_nids = alc861_dac_nids,
16386 .dig_out_nid = ALC861_DIGOUT_NID,
16387 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16388 .channel_mode = alc861_asus_modes,
16389 .need_dac_fix = 1,
16390 .hp_nid = 0x06,
16391 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16392 .adc_nids = alc861_adc_nids,
16393 .input_mux = &alc861_capture_source,
16394 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016395 [ALC861_ASUS_LAPTOP] = {
16396 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16397 .init_verbs = { alc861_asus_init_verbs,
16398 alc861_asus_laptop_init_verbs },
16399 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16400 .dac_nids = alc861_dac_nids,
16401 .dig_out_nid = ALC861_DIGOUT_NID,
16402 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16403 .channel_mode = alc883_3ST_2ch_modes,
16404 .need_dac_fix = 1,
16405 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16406 .adc_nids = alc861_adc_nids,
16407 .input_mux = &alc861_capture_source,
16408 },
16409};
Kailang Yangdf694da2005-12-05 19:42:22 +010016410
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016411/* Pin config fixes */
16412enum {
16413 PINFIX_FSC_AMILO_PI1505,
16414};
16415
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016416static const struct alc_fixup alc861_fixups[] = {
16417 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016418 .type = ALC_FIXUP_PINS,
16419 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016420 { 0x0b, 0x0221101f }, /* HP */
16421 { 0x0f, 0x90170310 }, /* speaker */
16422 { }
16423 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016424 },
16425};
16426
16427static struct snd_pci_quirk alc861_fixup_tbl[] = {
16428 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16429 {}
16430};
Kailang Yangdf694da2005-12-05 19:42:22 +010016431
16432static int patch_alc861(struct hda_codec *codec)
16433{
16434 struct alc_spec *spec;
16435 int board_config;
16436 int err;
16437
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016438 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016439 if (spec == NULL)
16440 return -ENOMEM;
16441
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016442 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016443
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016444 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16445 alc861_models,
16446 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016447
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016448 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016449 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16450 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016451 board_config = ALC861_AUTO;
16452 }
16453
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016454 if (board_config == ALC861_AUTO) {
16455 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16456 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16457 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016458
Kailang Yangdf694da2005-12-05 19:42:22 +010016459 if (board_config == ALC861_AUTO) {
16460 /* automatic parse from the BIOS config */
16461 err = alc861_parse_auto_config(codec);
16462 if (err < 0) {
16463 alc_free(codec);
16464 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016465 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016466 printk(KERN_INFO
16467 "hda_codec: Cannot set up configuration "
16468 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016469 board_config = ALC861_3ST_DIG;
16470 }
16471 }
16472
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016473 err = snd_hda_attach_beep_device(codec, 0x23);
16474 if (err < 0) {
16475 alc_free(codec);
16476 return err;
16477 }
16478
Kailang Yangdf694da2005-12-05 19:42:22 +010016479 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016480 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016481
Kailang Yangdf694da2005-12-05 19:42:22 +010016482 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16483 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16484
Kailang Yangdf694da2005-12-05 19:42:22 +010016485 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16486 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16487
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016488 if (!spec->cap_mixer)
16489 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016490 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16491
Takashi Iwai2134ea42008-01-10 16:53:55 +010016492 spec->vmaster_nid = 0x03;
16493
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016494 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016495
Kailang Yangdf694da2005-12-05 19:42:22 +010016496 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016497 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016498 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016499#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016500 spec->power_hook = alc_power_eapd;
16501#endif
16502 }
16503#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016504 if (!spec->loopback.amplist)
16505 spec->loopback.amplist = alc861_loopbacks;
16506#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016507
Kailang Yangdf694da2005-12-05 19:42:22 +010016508 return 0;
16509}
16510
16511/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016512 * ALC861-VD support
16513 *
16514 * Based on ALC882
16515 *
16516 * In addition, an independent DAC
16517 */
16518#define ALC861VD_DIGOUT_NID 0x06
16519
16520static hda_nid_t alc861vd_dac_nids[4] = {
16521 /* front, surr, clfe, side surr */
16522 0x02, 0x03, 0x04, 0x05
16523};
16524
16525/* dac_nids for ALC660vd are in a different order - according to
16526 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016527 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016528 * of ALC660vd codecs, but for now there is only 3stack mixer
16529 * - and it is the same as in 861vd.
16530 * adc_nids in ALC660vd are (is) the same as in 861vd
16531 */
16532static hda_nid_t alc660vd_dac_nids[3] = {
16533 /* front, rear, clfe, rear_surr */
16534 0x02, 0x04, 0x03
16535};
16536
16537static hda_nid_t alc861vd_adc_nids[1] = {
16538 /* ADC0 */
16539 0x09,
16540};
16541
Takashi Iwaie1406342008-02-11 18:32:32 +010016542static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16543
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016544/* input MUX */
16545/* FIXME: should be a matrix-type input source selection */
16546static struct hda_input_mux alc861vd_capture_source = {
16547 .num_items = 4,
16548 .items = {
16549 { "Mic", 0x0 },
16550 { "Front Mic", 0x1 },
16551 { "Line", 0x2 },
16552 { "CD", 0x4 },
16553 },
16554};
16555
Kailang Yang272a5272007-05-14 11:00:38 +020016556static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016557 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016558 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016559 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016560 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016561 },
16562};
16563
Kailang Yangd1a991a2007-08-15 16:21:59 +020016564static struct hda_input_mux alc861vd_hp_capture_source = {
16565 .num_items = 2,
16566 .items = {
16567 { "Front Mic", 0x0 },
16568 { "ATAPI Mic", 0x1 },
16569 },
16570};
16571
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016572/*
16573 * 2ch mode
16574 */
16575static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16576 { 2, NULL }
16577};
16578
16579/*
16580 * 6ch mode
16581 */
16582static struct hda_verb alc861vd_6stack_ch6_init[] = {
16583 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16584 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16585 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16586 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16587 { } /* end */
16588};
16589
16590/*
16591 * 8ch mode
16592 */
16593static struct hda_verb alc861vd_6stack_ch8_init[] = {
16594 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16595 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16596 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16597 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16598 { } /* end */
16599};
16600
16601static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16602 { 6, alc861vd_6stack_ch6_init },
16603 { 8, alc861vd_6stack_ch8_init },
16604};
16605
16606static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16607 {
16608 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16609 .name = "Channel Mode",
16610 .info = alc_ch_mode_info,
16611 .get = alc_ch_mode_get,
16612 .put = alc_ch_mode_put,
16613 },
16614 { } /* end */
16615};
16616
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016617/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16618 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16619 */
16620static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16621 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16622 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16623
16624 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16625 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16626
16627 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16628 HDA_OUTPUT),
16629 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16630 HDA_OUTPUT),
16631 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16632 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16633
16634 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16635 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16636
16637 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16638
David Henningsson5f99f862011-01-04 15:24:24 +010016639 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16642
David Henningsson5f99f862011-01-04 15:24:24 +010016643 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016644 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16645 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16646
16647 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16648 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16649
16650 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16651 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16652
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016653 { } /* end */
16654};
16655
16656static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16657 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16658 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16659
16660 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16661
David Henningsson5f99f862011-01-04 15:24:24 +010016662 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016663 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16664 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16665
David Henningsson5f99f862011-01-04 15:24:24 +010016666 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016667 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16668 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16669
16670 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16671 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16672
16673 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16674 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16675
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016676 { } /* end */
16677};
16678
Kailang Yangbdd148a2007-05-08 15:19:08 +020016679static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16680 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16681 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16682 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16683
16684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16685
David Henningsson5f99f862011-01-04 15:24:24 +010016686 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16688 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16689
David Henningsson5f99f862011-01-04 15:24:24 +010016690 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016691 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16692 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16693
16694 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16695 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16696
16697 { } /* end */
16698};
16699
Tobin Davisb419f342008-03-07 11:57:51 +010016700/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016701 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016702 */
16703static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016704 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16705 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016706 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16707 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016708 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016711 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016712 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16713 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016714 { } /* end */
16715};
16716
Kailang Yangd1a991a2007-08-15 16:21:59 +020016717/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16718 * Front Mic=0x18, ATAPI Mic = 0x19,
16719 */
16720static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16721 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16722 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16723 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16724 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16725 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16726 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16727 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16728 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016729
Kailang Yangd1a991a2007-08-15 16:21:59 +020016730 { } /* end */
16731};
16732
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016733/*
16734 * generic initialization of ADC, input mixers and output mixers
16735 */
16736static struct hda_verb alc861vd_volume_init_verbs[] = {
16737 /*
16738 * Unmute ADC0 and set the default input to mic-in
16739 */
16740 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16742
16743 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16744 * the analog-loopback mixer widget
16745 */
16746 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016747 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16748 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16749 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16750 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16751 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016752
16753 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016758
16759 /*
16760 * Set up output mixers (0x02 - 0x05)
16761 */
16762 /* set vol=0 to output mixers */
16763 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16764 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16765 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16766 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16767
16768 /* set up input amps for analog loopback */
16769 /* Amp Indices: DAC = 0, mixer = 1 */
16770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16773 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16774 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16775 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16776 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16777 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16778
16779 { }
16780};
16781
16782/*
16783 * 3-stack pin configuration:
16784 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16785 */
16786static struct hda_verb alc861vd_3stack_init_verbs[] = {
16787 /*
16788 * Set pin mode and muting
16789 */
16790 /* set front pin widgets 0x14 for output */
16791 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16793 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16794
16795 /* Mic (rear) pin: input vref at 80% */
16796 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16797 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16798 /* Front Mic pin: input vref at 80% */
16799 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16800 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16801 /* Line In pin: input */
16802 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16803 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16804 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16805 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16806 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16807 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16808 /* CD pin widget for input */
16809 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16810
16811 { }
16812};
16813
16814/*
16815 * 6-stack pin configuration:
16816 */
16817static struct hda_verb alc861vd_6stack_init_verbs[] = {
16818 /*
16819 * Set pin mode and muting
16820 */
16821 /* set front pin widgets 0x14 for output */
16822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16824 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16825
16826 /* Rear Pin: output 1 (0x0d) */
16827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16829 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16830 /* CLFE Pin: output 2 (0x0e) */
16831 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16832 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16833 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16834 /* Side Pin: output 3 (0x0f) */
16835 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16836 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16837 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16838
16839 /* Mic (rear) pin: input vref at 80% */
16840 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16841 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16842 /* Front Mic pin: input vref at 80% */
16843 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16844 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16845 /* Line In pin: input */
16846 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16847 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16848 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16849 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16850 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16851 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16852 /* CD pin widget for input */
16853 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16854
16855 { }
16856};
16857
Kailang Yangbdd148a2007-05-08 15:19:08 +020016858static struct hda_verb alc861vd_eapd_verbs[] = {
16859 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16860 { }
16861};
16862
Kailang Yangf9423e72008-05-27 12:32:25 +020016863static struct hda_verb alc660vd_eapd_verbs[] = {
16864 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16865 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16866 { }
16867};
16868
Kailang Yangbdd148a2007-05-08 15:19:08 +020016869static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16870 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16871 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16873 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016874 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016875 {}
16876};
16877
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016878static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016879{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016880 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016881 spec->autocfg.hp_pins[0] = 0x1b;
16882 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016883 spec->automute = 1;
16884 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016885}
16886
16887static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16888{
Takashi Iwaid922b512011-04-28 12:18:53 +020016889 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016890 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016891}
16892
16893static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16894 unsigned int res)
16895{
16896 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016897 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016898 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016899 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016900 default:
Takashi Iwaid922b512011-04-28 12:18:53 +020016901 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016902 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016903 }
16904}
16905
Kailang Yang272a5272007-05-14 11:00:38 +020016906static struct hda_verb alc861vd_dallas_verbs[] = {
16907 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16908 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16909 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16910 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16911
16912 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16914 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16916 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16918 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16919 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016920
Kailang Yang272a5272007-05-14 11:00:38 +020016921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16922 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16925 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16926 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16927 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16928 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16929
16930 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16931 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16932 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16933 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16937 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16938
16939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16943
16944 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016945 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016946 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16947
16948 { } /* end */
16949};
16950
16951/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016952static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016953{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016954 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016955
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016956 spec->autocfg.hp_pins[0] = 0x15;
16957 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016958 spec->automute = 1;
16959 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +020016960}
16961
Takashi Iwaicb53c622007-08-10 17:21:45 +020016962#ifdef CONFIG_SND_HDA_POWER_SAVE
16963#define alc861vd_loopbacks alc880_loopbacks
16964#endif
16965
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016966/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016967#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16968#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16969#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16970#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16971
16972/*
16973 * configuration and preset
16974 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016975static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016976 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016977 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016978 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016979 [ALC861VD_3ST] = "3stack",
16980 [ALC861VD_3ST_DIG] = "3stack-digout",
16981 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016982 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016983 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016984 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016985 [ALC861VD_AUTO] = "auto",
16986};
16987
16988static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016989 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16990 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016991 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016992 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016993 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016994 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016995 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016996 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016997 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016998 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016999 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010017000 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020017001 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017002 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020017003 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017004 {}
17005};
17006
17007static struct alc_config_preset alc861vd_presets[] = {
17008 [ALC660VD_3ST] = {
17009 .mixers = { alc861vd_3st_mixer },
17010 .init_verbs = { alc861vd_volume_init_verbs,
17011 alc861vd_3stack_init_verbs },
17012 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17013 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017014 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17015 .channel_mode = alc861vd_3stack_2ch_modes,
17016 .input_mux = &alc861vd_capture_source,
17017 },
Mike Crash6963f842007-06-25 12:12:51 +020017018 [ALC660VD_3ST_DIG] = {
17019 .mixers = { alc861vd_3st_mixer },
17020 .init_verbs = { alc861vd_volume_init_verbs,
17021 alc861vd_3stack_init_verbs },
17022 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17023 .dac_nids = alc660vd_dac_nids,
17024 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020017025 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17026 .channel_mode = alc861vd_3stack_2ch_modes,
17027 .input_mux = &alc861vd_capture_source,
17028 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017029 [ALC861VD_3ST] = {
17030 .mixers = { alc861vd_3st_mixer },
17031 .init_verbs = { alc861vd_volume_init_verbs,
17032 alc861vd_3stack_init_verbs },
17033 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17034 .dac_nids = alc861vd_dac_nids,
17035 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17036 .channel_mode = alc861vd_3stack_2ch_modes,
17037 .input_mux = &alc861vd_capture_source,
17038 },
17039 [ALC861VD_3ST_DIG] = {
17040 .mixers = { alc861vd_3st_mixer },
17041 .init_verbs = { alc861vd_volume_init_verbs,
17042 alc861vd_3stack_init_verbs },
17043 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17044 .dac_nids = alc861vd_dac_nids,
17045 .dig_out_nid = ALC861VD_DIGOUT_NID,
17046 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17047 .channel_mode = alc861vd_3stack_2ch_modes,
17048 .input_mux = &alc861vd_capture_source,
17049 },
17050 [ALC861VD_6ST_DIG] = {
17051 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
17052 .init_verbs = { alc861vd_volume_init_verbs,
17053 alc861vd_6stack_init_verbs },
17054 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17055 .dac_nids = alc861vd_dac_nids,
17056 .dig_out_nid = ALC861VD_DIGOUT_NID,
17057 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
17058 .channel_mode = alc861vd_6stack_modes,
17059 .input_mux = &alc861vd_capture_source,
17060 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020017061 [ALC861VD_LENOVO] = {
17062 .mixers = { alc861vd_lenovo_mixer },
17063 .init_verbs = { alc861vd_volume_init_verbs,
17064 alc861vd_3stack_init_verbs,
17065 alc861vd_eapd_verbs,
17066 alc861vd_lenovo_unsol_verbs },
17067 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17068 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017069 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17070 .channel_mode = alc861vd_3stack_2ch_modes,
17071 .input_mux = &alc861vd_capture_source,
17072 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017073 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017074 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017075 },
Kailang Yang272a5272007-05-14 11:00:38 +020017076 [ALC861VD_DALLAS] = {
17077 .mixers = { alc861vd_dallas_mixer },
17078 .init_verbs = { alc861vd_dallas_verbs },
17079 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17080 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020017081 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17082 .channel_mode = alc861vd_3stack_2ch_modes,
17083 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020017084 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017085 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020017086 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017087 },
17088 [ALC861VD_HP] = {
17089 .mixers = { alc861vd_hp_mixer },
17090 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17091 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17092 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017093 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017094 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17095 .channel_mode = alc861vd_3stack_2ch_modes,
17096 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020017097 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017098 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020017099 .init_hook = alc_hp_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020017100 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017101 [ALC660VD_ASUS_V1S] = {
17102 .mixers = { alc861vd_lenovo_mixer },
17103 .init_verbs = { alc861vd_volume_init_verbs,
17104 alc861vd_3stack_init_verbs,
17105 alc861vd_eapd_verbs,
17106 alc861vd_lenovo_unsol_verbs },
17107 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17108 .dac_nids = alc660vd_dac_nids,
17109 .dig_out_nid = ALC861VD_DIGOUT_NID,
17110 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17111 .channel_mode = alc861vd_3stack_2ch_modes,
17112 .input_mux = &alc861vd_capture_source,
17113 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017114 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017115 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017116 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017117};
17118
17119/*
17120 * BIOS auto configuration
17121 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017122static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17123 const struct auto_pin_cfg *cfg)
17124{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017125 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017126}
17127
17128
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017129static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17130 hda_nid_t nid, int pin_type, int dac_idx)
17131{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017132 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017133}
17134
17135static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17136{
17137 struct alc_spec *spec = codec->spec;
17138 int i;
17139
17140 for (i = 0; i <= HDA_SIDE; i++) {
17141 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017142 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017143 if (nid)
17144 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017145 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017146 }
17147}
17148
17149
17150static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17151{
17152 struct alc_spec *spec = codec->spec;
17153 hda_nid_t pin;
17154
17155 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017156 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017157 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017158 pin = spec->autocfg.speaker_pins[0];
17159 if (pin)
17160 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017161}
17162
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017163#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17164
17165static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17166{
17167 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017168 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017169 int i;
17170
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017171 for (i = 0; i < cfg->num_inputs; i++) {
17172 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017173 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017174 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017175 if (nid != ALC861VD_PIN_CD_NID &&
17176 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017177 snd_hda_codec_write(codec, nid, 0,
17178 AC_VERB_SET_AMP_GAIN_MUTE,
17179 AMP_OUT_MUTE);
17180 }
17181 }
17182}
17183
Takashi Iwaif511b012008-08-15 16:46:42 +020017184#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17185
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017186#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17187#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17188
17189/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017190/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017191 * different NIDs for mute/unmute switch and volume control */
17192static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17193 const struct auto_pin_cfg *cfg)
17194{
Takashi Iwaiea734962011-01-17 11:29:34 +010017195 static const char * const chname[4] = {
17196 "Front", "Surround", "CLFE", "Side"
17197 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020017198 const char *pfx = alc_get_line_out_pfx(spec, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017199 hda_nid_t nid_v, nid_s;
Takashi Iwaice764ab2011-04-27 16:35:23 +020017200 int i, err, noutputs;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017201
Takashi Iwaice764ab2011-04-27 16:35:23 +020017202 noutputs = cfg->line_outs;
17203 if (spec->multi_ios > 0)
17204 noutputs += spec->multi_ios;
17205
17206 for (i = 0; i < noutputs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017207 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017208 continue;
17209 nid_v = alc861vd_idx_to_mixer_vol(
17210 alc880_dac_to_idx(
17211 spec->multiout.dac_nids[i]));
17212 nid_s = alc861vd_idx_to_mixer_switch(
17213 alc880_dac_to_idx(
17214 spec->multiout.dac_nids[i]));
17215
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017216 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017217 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017218 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17219 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017220 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17221 HDA_OUTPUT));
17222 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017223 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017224 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17225 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017226 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17227 HDA_OUTPUT));
17228 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017229 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017230 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17231 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017232 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17233 HDA_INPUT));
17234 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017235 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017236 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17237 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017238 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17239 HDA_INPUT));
17240 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017241 return err;
17242 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017243 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010017244 int index = i;
17245 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017246 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010017247 index = 0;
17248 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017249 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson5a882642011-03-23 08:35:07 +010017250 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017251 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17252 HDA_OUTPUT));
17253 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017254 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017255 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson5a882642011-03-23 08:35:07 +010017256 name, index,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017257 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017258 HDA_INPUT));
17259 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017260 return err;
17261 }
17262 }
17263 return 0;
17264}
17265
17266/* add playback controls for speaker and HP outputs */
17267/* Based on ALC880 version. But ALC861VD has separate,
17268 * different NIDs for mute/unmute switch and volume control */
17269static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17270 hda_nid_t pin, const char *pfx)
17271{
17272 hda_nid_t nid_v, nid_s;
17273 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017274
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017275 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017276 return 0;
17277
17278 if (alc880_is_fixed_pin(pin)) {
17279 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17280 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017281 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017282 spec->multiout.hp_nid = nid_v;
17283 else
17284 spec->multiout.extra_out_nid[0] = nid_v;
17285 /* control HP volume/switch on the output mixer amp */
17286 nid_v = alc861vd_idx_to_mixer_vol(
17287 alc880_fixed_pin_idx(pin));
17288 nid_s = alc861vd_idx_to_mixer_switch(
17289 alc880_fixed_pin_idx(pin));
17290
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017291 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017292 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17293 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017294 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017295 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017296 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17297 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017298 return err;
17299 } else if (alc880_is_multi_pin(pin)) {
17300 /* set manual connection */
17301 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017302 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017303 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17304 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017305 return err;
17306 }
17307 return 0;
17308}
17309
17310/* parse the BIOS configuration and set up the alc_spec
17311 * return 1 if successful, 0 if the proper config is not found,
17312 * or a negative error code
17313 * Based on ALC880 version - had to change it to override
17314 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17315static int alc861vd_parse_auto_config(struct hda_codec *codec)
17316{
17317 struct alc_spec *spec = codec->spec;
17318 int err;
17319 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17320
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017321 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17322 alc861vd_ignore);
17323 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017324 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017325 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017326 return 0; /* can't find valid BIOS pin config */
17327
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017328 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17329 if (err < 0)
17330 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020017331 err = alc_auto_add_multi_channel_mode(codec);
17332 if (err < 0)
17333 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017334 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17335 if (err < 0)
17336 return err;
17337 err = alc861vd_auto_create_extra_out(spec,
17338 spec->autocfg.speaker_pins[0],
17339 "Speaker");
17340 if (err < 0)
17341 return err;
17342 err = alc861vd_auto_create_extra_out(spec,
17343 spec->autocfg.hp_pins[0],
17344 "Headphone");
17345 if (err < 0)
17346 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017347 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017348 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017349 return err;
17350
17351 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17352
Takashi Iwai757899a2010-07-30 10:48:14 +020017353 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017354
Takashi Iwai603c4012008-07-30 15:01:44 +020017355 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017356 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017357
Takashi Iwaid88897e2008-10-31 15:01:37 +010017358 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017359
17360 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017361 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017362
Takashi Iwai776e1842007-08-29 15:07:11 +020017363 err = alc_auto_add_mic_boost(codec);
17364 if (err < 0)
17365 return err;
17366
Kailang Yang6227cdc2010-02-25 08:36:52 +010017367 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017368
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017369 return 1;
17370}
17371
17372/* additional initialization for auto-configuration model */
17373static void alc861vd_auto_init(struct hda_codec *codec)
17374{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017375 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017376 alc861vd_auto_init_multi_out(codec);
17377 alc861vd_auto_init_hp_out(codec);
17378 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017379 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017380 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017381 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017382 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017383}
17384
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017385enum {
17386 ALC660VD_FIX_ASUS_GPIO1
17387};
17388
17389/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017390static const struct alc_fixup alc861vd_fixups[] = {
17391 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017392 .type = ALC_FIXUP_VERBS,
17393 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017394 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17395 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17396 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17397 { }
17398 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017399 },
17400};
17401
17402static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17403 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17404 {}
17405};
17406
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017407static int patch_alc861vd(struct hda_codec *codec)
17408{
17409 struct alc_spec *spec;
17410 int err, board_config;
17411
17412 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17413 if (spec == NULL)
17414 return -ENOMEM;
17415
17416 codec->spec = spec;
17417
17418 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17419 alc861vd_models,
17420 alc861vd_cfg_tbl);
17421
17422 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017423 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17424 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017425 board_config = ALC861VD_AUTO;
17426 }
17427
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017428 if (board_config == ALC861VD_AUTO) {
17429 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17430 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17431 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017432
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017433 if (board_config == ALC861VD_AUTO) {
17434 /* automatic parse from the BIOS config */
17435 err = alc861vd_parse_auto_config(codec);
17436 if (err < 0) {
17437 alc_free(codec);
17438 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017439 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017440 printk(KERN_INFO
17441 "hda_codec: Cannot set up configuration "
17442 "from BIOS. Using base mode...\n");
17443 board_config = ALC861VD_3ST;
17444 }
17445 }
17446
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017447 err = snd_hda_attach_beep_device(codec, 0x23);
17448 if (err < 0) {
17449 alc_free(codec);
17450 return err;
17451 }
17452
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017453 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017454 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017455
Kailang Yang2f893282008-05-27 12:14:47 +020017456 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017457 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017458 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017459 }
17460
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017461 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17462 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17463
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017464 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17465 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17466
Takashi Iwaidd704692009-08-11 08:45:11 +020017467 if (!spec->adc_nids) {
17468 spec->adc_nids = alc861vd_adc_nids;
17469 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17470 }
17471 if (!spec->capsrc_nids)
17472 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017473
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017474 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017475 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017476
Takashi Iwai2134ea42008-01-10 16:53:55 +010017477 spec->vmaster_nid = 0x02;
17478
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017479 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017480
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017481 codec->patch_ops = alc_patch_ops;
17482
17483 if (board_config == ALC861VD_AUTO)
17484 spec->init_hook = alc861vd_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020017485 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017486#ifdef CONFIG_SND_HDA_POWER_SAVE
17487 if (!spec->loopback.amplist)
17488 spec->loopback.amplist = alc861vd_loopbacks;
17489#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017490
17491 return 0;
17492}
17493
17494/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017495 * ALC662 support
17496 *
17497 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17498 * configuration. Each pin widget can choose any input DACs and a mixer.
17499 * Each ADC is connected from a mixer of all inputs. This makes possible
17500 * 6-channel independent captures.
17501 *
17502 * In addition, an independent DAC for the multi-playback (not used in this
17503 * driver yet).
17504 */
17505#define ALC662_DIGOUT_NID 0x06
17506#define ALC662_DIGIN_NID 0x0a
17507
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080017508static hda_nid_t alc662_dac_nids[3] = {
17509 /* front, rear, clfe */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017510 0x02, 0x03, 0x04
17511};
17512
Kailang Yang622e84c2009-04-21 07:39:04 +020017513static hda_nid_t alc272_dac_nids[2] = {
17514 0x02, 0x03
17515};
17516
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017517static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017518 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017519 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017520};
Takashi Iwaie1406342008-02-11 18:32:32 +010017521
Kailang Yang622e84c2009-04-21 07:39:04 +020017522static hda_nid_t alc272_adc_nids[1] = {
17523 /* ADC1-2 */
17524 0x08,
17525};
17526
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017527static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017528static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17529
Takashi Iwaie1406342008-02-11 18:32:32 +010017530
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017531/* input MUX */
17532/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017533static struct hda_input_mux alc662_capture_source = {
17534 .num_items = 4,
17535 .items = {
17536 { "Mic", 0x0 },
17537 { "Front Mic", 0x1 },
17538 { "Line", 0x2 },
17539 { "CD", 0x4 },
17540 },
17541};
17542
17543static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17544 .num_items = 2,
17545 .items = {
17546 { "Mic", 0x1 },
17547 { "Line", 0x2 },
17548 },
17549};
Kailang Yang291702f2007-10-16 14:28:03 +020017550
Kailang Yang6dda9f42008-05-27 12:05:31 +020017551static struct hda_input_mux alc663_capture_source = {
17552 .num_items = 3,
17553 .items = {
17554 { "Mic", 0x0 },
17555 { "Front Mic", 0x1 },
17556 { "Line", 0x2 },
17557 },
17558};
17559
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017560#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017561static struct hda_input_mux alc272_nc10_capture_source = {
17562 .num_items = 16,
17563 .items = {
17564 { "Autoselect Mic", 0x0 },
17565 { "Internal Mic", 0x1 },
17566 { "In-0x02", 0x2 },
17567 { "In-0x03", 0x3 },
17568 { "In-0x04", 0x4 },
17569 { "In-0x05", 0x5 },
17570 { "In-0x06", 0x6 },
17571 { "In-0x07", 0x7 },
17572 { "In-0x08", 0x8 },
17573 { "In-0x09", 0x9 },
17574 { "In-0x0a", 0x0a },
17575 { "In-0x0b", 0x0b },
17576 { "In-0x0c", 0x0c },
17577 { "In-0x0d", 0x0d },
17578 { "In-0x0e", 0x0e },
17579 { "In-0x0f", 0x0f },
17580 },
17581};
17582#endif
17583
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017584/*
17585 * 2ch mode
17586 */
17587static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17588 { 2, NULL }
17589};
17590
17591/*
17592 * 2ch mode
17593 */
17594static struct hda_verb alc662_3ST_ch2_init[] = {
17595 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17596 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17597 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17598 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17599 { } /* end */
17600};
17601
17602/*
17603 * 6ch mode
17604 */
17605static struct hda_verb alc662_3ST_ch6_init[] = {
17606 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17607 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17608 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17609 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17610 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17611 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17612 { } /* end */
17613};
17614
17615static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17616 { 2, alc662_3ST_ch2_init },
17617 { 6, alc662_3ST_ch6_init },
17618};
17619
17620/*
17621 * 2ch mode
17622 */
17623static struct hda_verb alc662_sixstack_ch6_init[] = {
17624 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17625 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17626 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17627 { } /* end */
17628};
17629
17630/*
17631 * 6ch mode
17632 */
17633static struct hda_verb alc662_sixstack_ch8_init[] = {
17634 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17635 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17636 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17637 { } /* end */
17638};
17639
17640static struct hda_channel_mode alc662_5stack_modes[2] = {
17641 { 2, alc662_sixstack_ch6_init },
17642 { 6, alc662_sixstack_ch8_init },
17643};
17644
17645/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17646 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17647 */
17648
17649static struct snd_kcontrol_new alc662_base_mixer[] = {
17650 /* output mixer control */
17651 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017652 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017653 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017654 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017655 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17656 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017657 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17658 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017659 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17660
17661 /*Input mixer control */
17662 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17663 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17664 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17665 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17666 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17667 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17668 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17669 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017670 { } /* end */
17671};
17672
17673static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17674 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017675 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17677 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17678 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17679 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17680 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17683 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17684 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017685 { } /* end */
17686};
17687
17688static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17689 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017690 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017691 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017692 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017693 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17694 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017695 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17696 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17698 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17699 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17700 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17701 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17702 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17703 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17704 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17705 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017706 { } /* end */
17707};
17708
17709static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17710 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17711 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017712 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17713 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017714 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17715 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17716 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17717 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17718 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017719 { } /* end */
17720};
17721
Kailang Yang291702f2007-10-16 14:28:03 +020017722static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017723 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17724 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017725
David Henningsson5f99f862011-01-04 15:24:24 +010017726 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17728 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017729
David Henningsson5f99f862011-01-04 15:24:24 +010017730 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017731 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17732 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017733 { } /* end */
17734};
17735
Kailang Yang8c427222008-01-10 13:03:59 +010017736static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017737 ALC262_HIPPO_MASTER_SWITCH,
17738 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017739 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017740 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17741 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017742 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17743 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17744 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17747 { } /* end */
17748};
17749
Kailang Yangf1d4e282008-08-26 14:03:29 +020017750static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17751 .ops = &snd_hda_bind_vol,
17752 .values = {
17753 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17754 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17755 0
17756 },
17757};
17758
17759static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17760 .ops = &snd_hda_bind_sw,
17761 .values = {
17762 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17763 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17764 0
17765 },
17766};
17767
Kailang Yang6dda9f42008-05-27 12:05:31 +020017768static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017769 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17770 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17773 { } /* end */
17774};
17775
17776static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17777 .ops = &snd_hda_bind_sw,
17778 .values = {
17779 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17780 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17781 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17782 0
17783 },
17784};
17785
17786static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17787 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17788 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17789 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17790 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17791 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17792 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17793
17794 { } /* end */
17795};
17796
17797static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17798 .ops = &snd_hda_bind_sw,
17799 .values = {
17800 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17801 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17802 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17803 0
17804 },
17805};
17806
17807static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17808 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17809 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17811 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17812 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17813 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17814 { } /* end */
17815};
17816
17817static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017818 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17819 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017820 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17823 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17824 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17825 { } /* end */
17826};
17827
17828static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17829 .ops = &snd_hda_bind_vol,
17830 .values = {
17831 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17832 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17833 0
17834 },
17835};
17836
17837static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17838 .ops = &snd_hda_bind_sw,
17839 .values = {
17840 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17841 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17842 0
17843 },
17844};
17845
17846static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17847 HDA_BIND_VOL("Master Playback Volume",
17848 &alc663_asus_two_bind_master_vol),
17849 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17850 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017851 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017854 { } /* end */
17855};
17856
17857static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17858 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17859 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17860 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17863 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017864 { } /* end */
17865};
17866
17867static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17868 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17869 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17870 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17871 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17872 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17873
17874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017876 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17877 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017878 { } /* end */
17879};
17880
17881static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17882 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17883 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17884 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17885
17886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17887 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017888 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17889 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17892 { } /* end */
17893};
17894
Kailang Yangebb83ee2009-12-17 12:23:00 +010017895static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17896 .ops = &snd_hda_bind_sw,
17897 .values = {
17898 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17899 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17900 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17901 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17902 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17903 0
17904 },
17905};
17906
17907static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17908 .ops = &snd_hda_bind_sw,
17909 .values = {
17910 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17911 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17912 0
17913 },
17914};
17915
17916static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17917 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17918 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17919 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17920 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17921 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17922 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17923 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17926 { } /* end */
17927};
17928
17929static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17930 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17931 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17932 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17933 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17934 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17937 { } /* end */
17938};
17939
17940
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017941static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17942 {
17943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17944 .name = "Channel Mode",
17945 .info = alc_ch_mode_info,
17946 .get = alc_ch_mode_get,
17947 .put = alc_ch_mode_put,
17948 },
17949 { } /* end */
17950};
17951
17952static struct hda_verb alc662_init_verbs[] = {
17953 /* ADC: mute amp left and right */
17954 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17955 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017956
Kailang Yangb60dd392007-09-20 12:50:29 +020017957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017963
17964 /* Front Pin: output 0 (0x0c) */
17965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17967
17968 /* Rear Pin: output 1 (0x0d) */
17969 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17971
17972 /* CLFE Pin: output 2 (0x0e) */
17973 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17974 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17975
17976 /* Mic (rear) pin: input vref at 80% */
17977 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17978 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17979 /* Front Mic pin: input vref at 80% */
17980 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17981 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17982 /* Line In pin: input */
17983 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17984 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17985 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17986 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17987 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17988 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17989 /* CD pin widget for input */
17990 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17991
17992 /* FIXME: use matrix-type input source selection */
17993 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17994 /* Input mixer */
17995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017997
Takashi Iwaia7f23712011-04-07 10:24:23 +020017998 { }
17999};
18000
18001static struct hda_verb alc662_eapd_init_verbs[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020018002 /* always trun on EAPD */
18003 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
18004 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018005 { }
18006};
18007
18008static struct hda_verb alc662_sue_init_verbs[] = {
18009 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18010 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020018011 {}
18012};
18013
18014static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
18015 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18016 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18017 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018018};
18019
Kailang Yang8c427222008-01-10 13:03:59 +010018020/* Set Unsolicited Event*/
18021static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
18022 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18023 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18024 {}
18025};
18026
Kailang Yang6dda9f42008-05-27 12:05:31 +020018027static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18029 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020018030 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18031 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020018032 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18033 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18034 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020018035 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18036 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18037 {}
18038};
18039
Kailang Yangf1d4e282008-08-26 14:03:29 +020018040static struct hda_verb alc663_21jd_amic_init_verbs[] = {
18041 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18042 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18043 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18044 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18045 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18046 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18047 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18048 {}
18049};
18050
18051static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
18052 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18053 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18054 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18055 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18058 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18059 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18060 {}
18061};
18062
18063static struct hda_verb alc663_15jd_amic_init_verbs[] = {
18064 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18069 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18070 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18071 {}
18072};
18073
18074static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
18075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18076 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18077 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18078 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18084 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18085 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18086 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18087 {}
18088};
18089
18090static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18092 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18093 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18094 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18097 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18100 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18101 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18102 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18103 {}
18104};
18105
Kailang Yang6dda9f42008-05-27 12:05:31 +020018106static struct hda_verb alc663_g71v_init_verbs[] = {
18107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18108 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18109 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18110
18111 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18112 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18113 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18114
18115 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18116 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18117 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18118 {}
18119};
18120
18121static struct hda_verb alc663_g50v_init_verbs[] = {
18122 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18123 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18124 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18125
18126 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18127 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18128 {}
18129};
18130
Kailang Yangf1d4e282008-08-26 14:03:29 +020018131static struct hda_verb alc662_ecs_init_verbs[] = {
18132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18134 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18135 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18136 {}
18137};
18138
Kailang Yang622e84c2009-04-21 07:39:04 +020018139static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18140 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18141 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18143 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18144 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18145 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18146 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18147 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18148 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18149 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18150 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18151 {}
18152};
18153
18154static struct hda_verb alc272_dell_init_verbs[] = {
18155 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18156 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18158 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18159 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18160 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18161 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18162 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18164 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18165 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18166 {}
18167};
18168
Kailang Yangebb83ee2009-12-17 12:23:00 +010018169static struct hda_verb alc663_mode7_init_verbs[] = {
18170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18171 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18172 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18173 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18174 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18175 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18176 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18177 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18178 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18179 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18181 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18182 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18183 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18184 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18185 {}
18186};
18187
18188static struct hda_verb alc663_mode8_init_verbs[] = {
18189 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18192 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18193 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18194 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18195 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18196 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18197 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18198 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18199 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18202 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18203 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18204 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18205 {}
18206};
18207
Kailang Yangf1d4e282008-08-26 14:03:29 +020018208static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18209 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18210 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18211 { } /* end */
18212};
18213
Kailang Yang622e84c2009-04-21 07:39:04 +020018214static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18215 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18216 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18217 { } /* end */
18218};
18219
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018220static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18221{
18222 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018223 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018224
Wu Fengguang864f92b2009-11-18 12:38:02 +080018225 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018226 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018227
Takashi Iwai47fd8302007-08-10 17:11:07 +020018228 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18229 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018230}
18231
18232static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18233{
18234 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018235 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018236
Wu Fengguang864f92b2009-11-18 12:38:02 +080018237 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018238 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018239
Takashi Iwai47fd8302007-08-10 17:11:07 +020018240 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18241 HDA_AMP_MUTE, bits);
18242 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18243 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018244}
18245
18246static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18247 unsigned int res)
18248{
18249 if ((res >> 26) == ALC880_HP_EVENT)
18250 alc662_lenovo_101e_all_automute(codec);
18251 if ((res >> 26) == ALC880_FRONT_EVENT)
18252 alc662_lenovo_101e_ispeaker_automute(codec);
18253}
18254
Kailang Yang291702f2007-10-16 14:28:03 +020018255/* unsolicited event for HP jack sensing */
18256static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18257 unsigned int res)
18258{
Kailang Yang291702f2007-10-16 14:28:03 +020018259 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018260 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018261 else
18262 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018263}
18264
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018265static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018266{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018267 struct alc_spec *spec = codec->spec;
18268
18269 alc262_hippo1_setup(codec);
18270 spec->ext_mic.pin = 0x18;
18271 spec->ext_mic.mux_idx = 0;
18272 spec->int_mic.pin = 0x19;
18273 spec->int_mic.mux_idx = 1;
18274 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018275}
18276
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018277static void alc662_eeepc_inithook(struct hda_codec *codec)
18278{
18279 alc262_hippo_automute(codec);
18280 alc_mic_automute(codec);
18281}
18282
18283static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018284{
Takashi Iwai42171c12009-05-08 14:11:43 +020018285 struct alc_spec *spec = codec->spec;
18286
18287 spec->autocfg.hp_pins[0] = 0x14;
18288 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018289}
18290
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018291#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18292
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018293static void alc663_m51va_setup(struct hda_codec *codec)
18294{
18295 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018296 spec->autocfg.hp_pins[0] = 0x21;
18297 spec->autocfg.speaker_pins[0] = 0x14;
18298 spec->automute_mixer_nid[0] = 0x0c;
18299 spec->automute = 1;
18300 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018301 spec->ext_mic.pin = 0x18;
18302 spec->ext_mic.mux_idx = 0;
18303 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018304 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018305 spec->auto_mic = 1;
18306}
18307
Kailang Yangf1d4e282008-08-26 14:03:29 +020018308/* ***************** Mode1 ******************************/
Kailang Yangebb83ee2009-12-17 12:23:00 +010018309static void alc663_mode1_setup(struct hda_codec *codec)
18310{
18311 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018312 spec->autocfg.hp_pins[0] = 0x21;
18313 spec->autocfg.speaker_pins[0] = 0x14;
18314 spec->automute_mixer_nid[0] = 0x0c;
18315 spec->automute = 1;
18316 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018317 spec->ext_mic.pin = 0x18;
18318 spec->ext_mic.mux_idx = 0;
18319 spec->int_mic.pin = 0x19;
18320 spec->int_mic.mux_idx = 1;
18321 spec->auto_mic = 1;
18322}
18323
Kailang Yangf1d4e282008-08-26 14:03:29 +020018324/* ***************** Mode2 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018325static void alc662_mode2_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018326{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018327 struct alc_spec *spec = codec->spec;
18328 spec->autocfg.hp_pins[0] = 0x1b;
18329 spec->autocfg.speaker_pins[0] = 0x14;
18330 spec->automute = 1;
18331 spec->automute_mode = ALC_AUTOMUTE_PIN;
18332 spec->ext_mic.pin = 0x18;
18333 spec->ext_mic.mux_idx = 0;
18334 spec->int_mic.pin = 0x19;
18335 spec->int_mic.mux_idx = 1;
18336 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018337}
18338
Kailang Yangf1d4e282008-08-26 14:03:29 +020018339/* ***************** Mode3 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018340static void alc663_mode3_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018341{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018342 struct alc_spec *spec = codec->spec;
18343 spec->autocfg.hp_pins[0] = 0x21;
18344 spec->autocfg.hp_pins[0] = 0x15;
18345 spec->autocfg.speaker_pins[0] = 0x14;
18346 spec->automute = 1;
18347 spec->automute_mode = ALC_AUTOMUTE_PIN;
18348 spec->ext_mic.pin = 0x18;
18349 spec->ext_mic.mux_idx = 0;
18350 spec->int_mic.pin = 0x19;
18351 spec->int_mic.mux_idx = 1;
18352 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018353}
18354
Kailang Yangf1d4e282008-08-26 14:03:29 +020018355/* ***************** Mode4 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018356static void alc663_mode4_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018357{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018358 struct alc_spec *spec = codec->spec;
18359 spec->autocfg.hp_pins[0] = 0x21;
18360 spec->autocfg.speaker_pins[0] = 0x14;
18361 spec->autocfg.speaker_pins[1] = 0x16;
18362 spec->automute_mixer_nid[0] = 0x0c;
18363 spec->automute_mixer_nid[1] = 0x0e;
18364 spec->automute = 1;
18365 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18366 spec->ext_mic.pin = 0x18;
18367 spec->ext_mic.mux_idx = 0;
18368 spec->int_mic.pin = 0x19;
18369 spec->int_mic.mux_idx = 1;
18370 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018371}
18372
Kailang Yangf1d4e282008-08-26 14:03:29 +020018373/* ***************** Mode5 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018374static void alc663_mode5_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018375{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018376 struct alc_spec *spec = codec->spec;
18377 spec->autocfg.hp_pins[0] = 0x15;
18378 spec->autocfg.speaker_pins[0] = 0x14;
18379 spec->autocfg.speaker_pins[1] = 0x16;
18380 spec->automute_mixer_nid[0] = 0x0c;
18381 spec->automute_mixer_nid[1] = 0x0e;
18382 spec->automute = 1;
18383 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18384 spec->ext_mic.pin = 0x18;
18385 spec->ext_mic.mux_idx = 0;
18386 spec->int_mic.pin = 0x19;
18387 spec->int_mic.mux_idx = 1;
18388 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018389}
18390
Kailang Yangf1d4e282008-08-26 14:03:29 +020018391/* ***************** Mode6 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018392static void alc663_mode6_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018393{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018394 struct alc_spec *spec = codec->spec;
18395 spec->autocfg.hp_pins[0] = 0x1b;
18396 spec->autocfg.hp_pins[0] = 0x15;
18397 spec->autocfg.speaker_pins[0] = 0x14;
18398 spec->automute_mixer_nid[0] = 0x0c;
18399 spec->automute = 1;
18400 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18401 spec->ext_mic.pin = 0x18;
18402 spec->ext_mic.mux_idx = 0;
18403 spec->int_mic.pin = 0x19;
18404 spec->int_mic.mux_idx = 1;
18405 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018406}
18407
Kailang Yangebb83ee2009-12-17 12:23:00 +010018408/* ***************** Mode7 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018409static void alc663_mode7_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010018410{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018411 struct alc_spec *spec = codec->spec;
18412 spec->autocfg.hp_pins[0] = 0x1b;
18413 spec->autocfg.hp_pins[0] = 0x21;
18414 spec->autocfg.speaker_pins[0] = 0x14;
18415 spec->autocfg.speaker_pins[0] = 0x17;
18416 spec->automute = 1;
18417 spec->automute_mode = ALC_AUTOMUTE_PIN;
18418 spec->ext_mic.pin = 0x18;
18419 spec->ext_mic.mux_idx = 0;
18420 spec->int_mic.pin = 0x19;
18421 spec->int_mic.mux_idx = 1;
18422 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018423}
18424
18425/* ***************** Mode8 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018426static void alc663_mode8_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010018427{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018428 struct alc_spec *spec = codec->spec;
18429 spec->autocfg.hp_pins[0] = 0x21;
18430 spec->autocfg.hp_pins[1] = 0x15;
18431 spec->autocfg.speaker_pins[0] = 0x14;
18432 spec->autocfg.speaker_pins[0] = 0x17;
18433 spec->automute = 1;
18434 spec->automute_mode = ALC_AUTOMUTE_PIN;
18435 spec->ext_mic.pin = 0x18;
18436 spec->ext_mic.mux_idx = 0;
18437 spec->int_mic.pin = 0x12;
18438 spec->int_mic.mux_idx = 9;
18439 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018440}
18441
Kailang Yang6dda9f42008-05-27 12:05:31 +020018442static void alc663_g71v_hp_automute(struct hda_codec *codec)
18443{
18444 unsigned int present;
18445 unsigned char bits;
18446
Wu Fengguang864f92b2009-11-18 12:38:02 +080018447 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018448 bits = present ? HDA_AMP_MUTE : 0;
18449 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18450 HDA_AMP_MUTE, bits);
18451 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18452 HDA_AMP_MUTE, bits);
18453}
18454
18455static void alc663_g71v_front_automute(struct hda_codec *codec)
18456{
18457 unsigned int present;
18458 unsigned char bits;
18459
Wu Fengguang864f92b2009-11-18 12:38:02 +080018460 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018461 bits = present ? HDA_AMP_MUTE : 0;
18462 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18463 HDA_AMP_MUTE, bits);
18464}
18465
18466static void alc663_g71v_unsol_event(struct hda_codec *codec,
18467 unsigned int res)
18468{
18469 switch (res >> 26) {
18470 case ALC880_HP_EVENT:
18471 alc663_g71v_hp_automute(codec);
18472 break;
18473 case ALC880_FRONT_EVENT:
18474 alc663_g71v_front_automute(codec);
18475 break;
18476 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018477 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018478 break;
18479 }
18480}
18481
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018482#define alc663_g71v_setup alc663_m51va_setup
18483
Kailang Yang6dda9f42008-05-27 12:05:31 +020018484static void alc663_g71v_inithook(struct hda_codec *codec)
18485{
18486 alc663_g71v_front_automute(codec);
18487 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018488 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018489}
18490
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018491#define alc663_g50v_setup alc663_m51va_setup
18492
Kailang Yangf1d4e282008-08-26 14:03:29 +020018493static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18494 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018495 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018496
David Henningsson5f99f862011-01-04 15:24:24 +010018497 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018498 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18499 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018500
David Henningsson5f99f862011-01-04 15:24:24 +010018501 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018502 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18503 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018504 { } /* end */
18505};
18506
Chris Pockelé9541ba12009-05-12 08:08:53 +020018507static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18508 /* Master Playback automatically created from Speaker and Headphone */
18509 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18510 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18511 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18512 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18513
David Henningsson8607f7c2010-12-20 14:43:54 +010018514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18515 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018516 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018517
David Henningsson28c4edb2010-12-20 14:24:29 +010018518 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18519 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018520 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018521 { } /* end */
18522};
18523
Takashi Iwaicb53c622007-08-10 17:21:45 +020018524#ifdef CONFIG_SND_HDA_POWER_SAVE
18525#define alc662_loopbacks alc880_loopbacks
18526#endif
18527
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018528
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018529/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018530#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18531#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18532#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18533#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18534
18535/*
18536 * configuration and preset
18537 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018538static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018539 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18540 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18541 [ALC662_3ST_6ch] = "3stack-6ch",
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080018542 [ALC662_5ST_DIG] = "5stack-dig",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018543 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018544 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018545 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018546 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018547 [ALC663_ASUS_M51VA] = "m51va",
18548 [ALC663_ASUS_G71V] = "g71v",
18549 [ALC663_ASUS_H13] = "h13",
18550 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018551 [ALC663_ASUS_MODE1] = "asus-mode1",
18552 [ALC662_ASUS_MODE2] = "asus-mode2",
18553 [ALC663_ASUS_MODE3] = "asus-mode3",
18554 [ALC663_ASUS_MODE4] = "asus-mode4",
18555 [ALC663_ASUS_MODE5] = "asus-mode5",
18556 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018557 [ALC663_ASUS_MODE7] = "asus-mode7",
18558 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018559 [ALC272_DELL] = "dell",
18560 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018561 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018562 [ALC662_AUTO] = "auto",
18563};
18564
18565static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018566 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018567 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18568 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018569 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18570 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018571 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018572 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18573 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18574 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18575 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018576 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18577 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018578 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018579 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18580 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18581 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18582 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18583 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018584 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018585 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18586 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018587 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18588 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18589 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18590 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018591 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018592 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18593 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18594 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018595 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18596 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18597 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18598 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018599 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018600 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18601 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018602 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018603 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18604 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18605 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018606 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018607 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018608 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18609 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018610 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18611 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18612 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018613 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018614 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18615 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018616 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018617 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018618 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018619 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18620 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18621 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018622 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018623 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18624 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018625 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018626 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018627 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018628 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018629 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18630 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018631 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018632 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018633 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018634 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018635 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018636 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018637 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018638 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018639 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18640 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018641 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018642 {}
18643};
18644
18645static struct alc_config_preset alc662_presets[] = {
18646 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018647 .mixers = { alc662_3ST_2ch_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018648 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018649 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18650 .dac_nids = alc662_dac_nids,
18651 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018652 .dig_in_nid = ALC662_DIGIN_NID,
18653 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18654 .channel_mode = alc662_3ST_2ch_modes,
18655 .input_mux = &alc662_capture_source,
18656 },
18657 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018658 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018659 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018660 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18661 .dac_nids = alc662_dac_nids,
18662 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018663 .dig_in_nid = ALC662_DIGIN_NID,
18664 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18665 .channel_mode = alc662_3ST_6ch_modes,
18666 .need_dac_fix = 1,
18667 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018668 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018669 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018670 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018671 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018672 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18673 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018674 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18675 .channel_mode = alc662_3ST_6ch_modes,
18676 .need_dac_fix = 1,
18677 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018678 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018679 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018680 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018681 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018682 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18683 .dac_nids = alc662_dac_nids,
18684 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018685 .dig_in_nid = ALC662_DIGIN_NID,
18686 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18687 .channel_mode = alc662_5stack_modes,
18688 .input_mux = &alc662_capture_source,
18689 },
18690 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018691 .mixers = { alc662_lenovo_101e_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018692 .init_verbs = { alc662_init_verbs,
18693 alc662_eapd_init_verbs,
18694 alc662_sue_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018695 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18696 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018697 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18698 .channel_mode = alc662_3ST_2ch_modes,
18699 .input_mux = &alc662_lenovo_101e_capture_source,
18700 .unsol_event = alc662_lenovo_101e_unsol_event,
18701 .init_hook = alc662_lenovo_101e_all_automute,
18702 },
Kailang Yang291702f2007-10-16 14:28:03 +020018703 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018704 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018705 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018706 alc662_eapd_init_verbs,
Kailang Yang291702f2007-10-16 14:28:03 +020018707 alc662_eeepc_sue_init_verbs },
18708 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18709 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018710 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18711 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018712 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018713 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018714 .init_hook = alc662_eeepc_inithook,
18715 },
Kailang Yang8c427222008-01-10 13:03:59 +010018716 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018717 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018718 alc662_chmode_mixer },
18719 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018720 alc662_eapd_init_verbs,
Kailang Yang8c427222008-01-10 13:03:59 +010018721 alc662_eeepc_ep20_sue_init_verbs },
18722 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18723 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018724 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18725 .channel_mode = alc662_3ST_6ch_modes,
18726 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018727 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018728 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018729 .init_hook = alc662_eeepc_ep20_inithook,
18730 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018731 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018732 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018733 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018734 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018735 alc662_ecs_init_verbs },
18736 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18737 .dac_nids = alc662_dac_nids,
18738 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18739 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018740 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018741 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018742 .init_hook = alc662_eeepc_inithook,
18743 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018744 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018745 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018746 .init_verbs = { alc662_init_verbs,
18747 alc662_eapd_init_verbs,
18748 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018749 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18750 .dac_nids = alc662_dac_nids,
18751 .dig_out_nid = ALC662_DIGOUT_NID,
18752 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18753 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018754 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018755 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018756 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018757 },
18758 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018759 .mixers = { alc663_g71v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018760 .init_verbs = { alc662_init_verbs,
18761 alc662_eapd_init_verbs,
18762 alc663_g71v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018763 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18764 .dac_nids = alc662_dac_nids,
18765 .dig_out_nid = ALC662_DIGOUT_NID,
18766 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18767 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018768 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018769 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018770 .init_hook = alc663_g71v_inithook,
18771 },
18772 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018773 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018774 .init_verbs = { alc662_init_verbs,
18775 alc662_eapd_init_verbs,
18776 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018777 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18778 .dac_nids = alc662_dac_nids,
18779 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18780 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018781 .setup = alc663_m51va_setup,
18782 .unsol_event = alc_sku_unsol_event,
18783 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018784 },
18785 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018786 .mixers = { alc663_g50v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018787 .init_verbs = { alc662_init_verbs,
18788 alc662_eapd_init_verbs,
18789 alc663_g50v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018790 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18791 .dac_nids = alc662_dac_nids,
18792 .dig_out_nid = ALC662_DIGOUT_NID,
18793 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18794 .channel_mode = alc662_3ST_6ch_modes,
18795 .input_mux = &alc663_capture_source,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018796 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018797 .setup = alc663_g50v_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018798 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018799 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018800 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018801 .mixers = { alc663_m51va_mixer },
18802 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018803 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018804 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018805 alc663_21jd_amic_init_verbs },
18806 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18807 .hp_nid = 0x03,
18808 .dac_nids = alc662_dac_nids,
18809 .dig_out_nid = ALC662_DIGOUT_NID,
18810 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18811 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018812 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018813 .setup = alc663_mode1_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018814 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018815 },
18816 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018817 .mixers = { alc662_1bjd_mixer },
18818 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018819 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018820 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018821 alc662_1bjd_amic_init_verbs },
18822 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18823 .dac_nids = alc662_dac_nids,
18824 .dig_out_nid = ALC662_DIGOUT_NID,
18825 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18826 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018827 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018828 .setup = alc662_mode2_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018829 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018830 },
18831 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018832 .mixers = { alc663_two_hp_m1_mixer },
18833 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018834 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018835 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018836 alc663_two_hp_amic_m1_init_verbs },
18837 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18838 .hp_nid = 0x03,
18839 .dac_nids = alc662_dac_nids,
18840 .dig_out_nid = ALC662_DIGOUT_NID,
18841 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18842 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018843 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018844 .setup = alc663_mode3_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018845 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018846 },
18847 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018848 .mixers = { alc663_asus_21jd_clfe_mixer },
18849 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018850 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018851 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018852 alc663_21jd_amic_init_verbs},
18853 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18854 .hp_nid = 0x03,
18855 .dac_nids = alc662_dac_nids,
18856 .dig_out_nid = ALC662_DIGOUT_NID,
18857 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18858 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018859 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018860 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018861 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018862 },
18863 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018864 .mixers = { alc663_asus_15jd_clfe_mixer },
18865 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018866 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018867 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018868 alc663_15jd_amic_init_verbs },
18869 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18870 .hp_nid = 0x03,
18871 .dac_nids = alc662_dac_nids,
18872 .dig_out_nid = ALC662_DIGOUT_NID,
18873 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18874 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018875 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018876 .setup = alc663_mode5_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018877 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018878 },
18879 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018880 .mixers = { alc663_two_hp_m2_mixer },
18881 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018882 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018883 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018884 alc663_two_hp_amic_m2_init_verbs },
18885 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18886 .hp_nid = 0x03,
18887 .dac_nids = alc662_dac_nids,
18888 .dig_out_nid = ALC662_DIGOUT_NID,
18889 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18890 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018891 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018892 .setup = alc663_mode6_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018893 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018894 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018895 [ALC663_ASUS_MODE7] = {
18896 .mixers = { alc663_mode7_mixer },
18897 .cap_mixer = alc662_auto_capture_mixer,
18898 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018899 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018900 alc663_mode7_init_verbs },
18901 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18902 .hp_nid = 0x03,
18903 .dac_nids = alc662_dac_nids,
18904 .dig_out_nid = ALC662_DIGOUT_NID,
18905 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18906 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018907 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018908 .setup = alc663_mode7_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018909 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018910 },
18911 [ALC663_ASUS_MODE8] = {
18912 .mixers = { alc663_mode8_mixer },
18913 .cap_mixer = alc662_auto_capture_mixer,
18914 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018915 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018916 alc663_mode8_init_verbs },
18917 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18918 .hp_nid = 0x03,
18919 .dac_nids = alc662_dac_nids,
18920 .dig_out_nid = ALC662_DIGOUT_NID,
18921 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18922 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018923 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018924 .setup = alc663_mode8_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018925 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018926 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018927 [ALC272_DELL] = {
18928 .mixers = { alc663_m51va_mixer },
18929 .cap_mixer = alc272_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018930 .init_verbs = { alc662_init_verbs,
18931 alc662_eapd_init_verbs,
18932 alc272_dell_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018933 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018934 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018935 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18936 .adc_nids = alc272_adc_nids,
18937 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18938 .capsrc_nids = alc272_capsrc_nids,
18939 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018940 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018941 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018942 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018943 },
18944 [ALC272_DELL_ZM1] = {
18945 .mixers = { alc663_m51va_mixer },
18946 .cap_mixer = alc662_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018947 .init_verbs = { alc662_init_verbs,
18948 alc662_eapd_init_verbs,
18949 alc272_dell_zm1_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018950 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018951 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018952 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18953 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018954 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018955 .capsrc_nids = alc662_capsrc_nids,
18956 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018957 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018958 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018959 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018960 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018961 [ALC272_SAMSUNG_NC10] = {
18962 .mixers = { alc272_nc10_mixer },
18963 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018964 alc662_eapd_init_verbs,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018965 alc663_21jd_amic_init_verbs },
18966 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18967 .dac_nids = alc272_dac_nids,
18968 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18969 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018970 /*.input_mux = &alc272_nc10_capture_source,*/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018971 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018972 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018973 .init_hook = alc_inithook,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018974 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018975};
18976
18977
18978/*
18979 * BIOS auto configuration
18980 */
18981
Takashi Iwai7085ec12009-10-02 09:03:58 +020018982/* convert from MIX nid to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020018983static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018984{
Takashi Iwai604401a2011-04-27 15:14:23 +020018985 hda_nid_t list[5];
Takashi Iwai1304ac82011-04-06 15:16:21 +020018986 int i, num;
18987
18988 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
18989 for (i = 0; i < num; i++) {
18990 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
18991 return list[i];
18992 }
18993 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018994}
18995
Takashi Iwai604401a2011-04-27 15:14:23 +020018996/* go down to the selector widget before the mixer */
18997static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
18998{
18999 hda_nid_t srcs[5];
19000 int num = snd_hda_get_connections(codec, pin, srcs,
19001 ARRAY_SIZE(srcs));
19002 if (num != 1 ||
19003 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
19004 return pin;
19005 return srcs[0];
19006}
19007
Takashi Iwai7085ec12009-10-02 09:03:58 +020019008/* get MIX nid connected to the given pin targeted to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020019009static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019010 hda_nid_t dac)
19011{
David Henningssoncc1c4522010-11-24 14:17:47 +010019012 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019013 int i, num;
19014
Takashi Iwai604401a2011-04-27 15:14:23 +020019015 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019016 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19017 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020019018 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019019 return mix[i];
19020 }
19021 return 0;
19022}
19023
Takashi Iwaice764ab2011-04-27 16:35:23 +020019024/* select the connection from pin to DAC if needed */
19025static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
19026 hda_nid_t dac)
19027{
19028 hda_nid_t mix[5];
19029 int i, num;
19030
19031 pin = alc_go_down_to_selector(codec, pin);
19032 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19033 if (num < 2)
19034 return 0;
19035 for (i = 0; i < num; i++) {
19036 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
19037 snd_hda_codec_update_cache(codec, pin, 0,
19038 AC_VERB_SET_CONNECT_SEL, i);
19039 return 0;
19040 }
19041 }
19042 return 0;
19043}
19044
Takashi Iwai7085ec12009-10-02 09:03:58 +020019045/* look for an empty DAC slot */
Takashi Iwai604401a2011-04-27 15:14:23 +020019046static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019047{
19048 struct alc_spec *spec = codec->spec;
19049 hda_nid_t srcs[5];
19050 int i, j, num;
19051
Takashi Iwai604401a2011-04-27 15:14:23 +020019052 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019053 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020019054 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020019055 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019056 if (!nid)
19057 continue;
19058 for (j = 0; j < spec->multiout.num_dacs; j++)
19059 if (spec->multiout.dac_nids[j] == nid)
19060 break;
19061 if (j >= spec->multiout.num_dacs)
19062 return nid;
19063 }
19064 return 0;
19065}
19066
19067/* fill in the dac_nids table from the parsed pin configuration */
19068static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19069 const struct auto_pin_cfg *cfg)
19070{
19071 struct alc_spec *spec = codec->spec;
19072 int i;
19073 hda_nid_t dac;
19074
19075 spec->multiout.dac_nids = spec->private_dac_nids;
19076 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020019077 dac = alc_auto_look_for_dac(codec, cfg->line_out_pins[i]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019078 if (!dac)
19079 continue;
19080 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19081 }
19082 return 0;
19083}
19084
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019085static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19086 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019087{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019088 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019089 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19090}
19091
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019092static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19093 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019094{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019095 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019096 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19097}
19098
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019099#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19100 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19101#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19102 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019103#define alc662_add_stereo_vol(spec, pfx, nid) \
19104 alc662_add_vol_ctl(spec, pfx, nid, 3)
19105#define alc662_add_stereo_sw(spec, pfx, nid) \
19106 alc662_add_sw_ctl(spec, pfx, nid, 3)
19107
19108/* add playback controls from the parsed DAC table */
19109static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19110 const struct auto_pin_cfg *cfg)
19111{
19112 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010019113 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019114 "Front", "Surround", NULL /*CLFE*/, "Side"
19115 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020019116 const char *pfx = alc_get_line_out_pfx(spec, true);
19117 hda_nid_t nid, mix, pin;
19118 int i, err, noutputs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019119
Takashi Iwaice764ab2011-04-27 16:35:23 +020019120 noutputs = cfg->line_outs;
19121 if (spec->multi_ios > 0)
19122 noutputs += spec->multi_ios;
19123
19124 for (i = 0; i < noutputs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019125 nid = spec->multiout.dac_nids[i];
19126 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019127 continue;
Takashi Iwaice764ab2011-04-27 16:35:23 +020019128 if (i >= cfg->line_outs)
19129 pin = spec->multi_io[i - 1].pin;
19130 else
19131 pin = cfg->line_out_pins[i];
19132 mix = alc_auto_dac_to_mix(codec, pin, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019133 if (!mix)
19134 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019135 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019136 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019137 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019138 if (err < 0)
19139 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019140 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019141 if (err < 0)
19142 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019143 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019144 if (err < 0)
19145 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019146 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019147 if (err < 0)
19148 return err;
19149 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019150 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010019151 int index = i;
19152 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019153 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010019154 index = 0;
19155 }
19156 err = __alc662_add_vol_ctl(spec, name, nid, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019157 if (err < 0)
19158 return err;
David Henningsson5a882642011-03-23 08:35:07 +010019159 err = __alc662_add_sw_ctl(spec, name, mix, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019160 if (err < 0)
19161 return err;
19162 }
19163 }
19164 return 0;
19165}
19166
19167/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019168/* return DAC nid if any new DAC is assigned */
19169static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019170 const char *pfx)
19171{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019172 struct alc_spec *spec = codec->spec;
19173 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019174 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019175
19176 if (!pin)
19177 return 0;
Takashi Iwai604401a2011-04-27 15:14:23 +020019178 nid = alc_auto_look_for_dac(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019179 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019180 /* the corresponding DAC is already occupied */
19181 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19182 return 0; /* no way */
19183 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019184 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019185 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19186 }
19187
Takashi Iwai604401a2011-04-27 15:14:23 +020019188 mix = alc_auto_dac_to_mix(codec, pin, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019189 if (!mix)
19190 return 0;
19191 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19192 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019193 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019194 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19195 if (err < 0)
19196 return err;
19197 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019198}
19199
19200/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019201#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019202 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019203
19204static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19205 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019206 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019207{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019208 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019209 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019210
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019211 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019212 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020019213 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020019214 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019215 continue;
Takashi Iwai0e53f342011-04-07 12:27:32 +020019216 /* need the manual connection? */
19217 if (num > 1)
19218 snd_hda_codec_write(codec, nid, 0,
19219 AC_VERB_SET_CONNECT_SEL, i);
19220 /* unmute mixer widget inputs */
19221 snd_hda_codec_write(codec, srcs[i], 0,
19222 AC_VERB_SET_AMP_GAIN_MUTE,
19223 AMP_IN_UNMUTE(0));
19224 snd_hda_codec_write(codec, srcs[i], 0,
19225 AC_VERB_SET_AMP_GAIN_MUTE,
19226 AMP_IN_UNMUTE(1));
Takashi Iwai7085ec12009-10-02 09:03:58 +020019227 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019228 }
19229}
19230
19231static void alc662_auto_init_multi_out(struct hda_codec *codec)
19232{
19233 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019234 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019235 int i;
19236
19237 for (i = 0; i <= HDA_SIDE; i++) {
19238 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19239 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019240 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019241 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019242 }
19243}
19244
19245static void alc662_auto_init_hp_out(struct hda_codec *codec)
19246{
19247 struct alc_spec *spec = codec->spec;
19248 hda_nid_t pin;
19249
19250 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019251 if (pin)
19252 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19253 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019254 pin = spec->autocfg.speaker_pins[0];
19255 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019256 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19257 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019258}
19259
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019260#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19261
19262static void alc662_auto_init_analog_input(struct hda_codec *codec)
19263{
19264 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019265 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019266 int i;
19267
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019268 for (i = 0; i < cfg->num_inputs; i++) {
19269 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019270 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019271 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019272 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019273 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019274 snd_hda_codec_write(codec, nid, 0,
19275 AC_VERB_SET_AMP_GAIN_MUTE,
19276 AMP_OUT_MUTE);
19277 }
19278 }
19279}
19280
Takashi Iwaif511b012008-08-15 16:46:42 +020019281#define alc662_auto_init_input_src alc882_auto_init_input_src
19282
Takashi Iwaice764ab2011-04-27 16:35:23 +020019283/*
19284 * multi-io helper
19285 */
19286static int alc_auto_fill_multi_ios(struct hda_codec *codec,
19287 unsigned int location)
19288{
19289 struct alc_spec *spec = codec->spec;
19290 struct auto_pin_cfg *cfg = &spec->autocfg;
19291 int type, i, num_pins = 0;
19292
19293 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
19294 for (i = 0; i < cfg->num_inputs; i++) {
19295 hda_nid_t nid = cfg->inputs[i].pin;
19296 hda_nid_t dac;
19297 unsigned int defcfg, caps;
19298 if (cfg->inputs[i].type != type)
19299 continue;
19300 defcfg = snd_hda_codec_get_pincfg(codec, nid);
19301 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
19302 continue;
19303 if (location && get_defcfg_location(defcfg) != location)
19304 continue;
19305 caps = snd_hda_query_pin_caps(codec, nid);
19306 if (!(caps & AC_PINCAP_OUT))
19307 continue;
19308 dac = alc_auto_look_for_dac(codec, nid);
19309 if (!dac)
19310 continue;
19311 spec->multi_io[num_pins].pin = nid;
19312 spec->multi_io[num_pins].dac = dac;
19313 num_pins++;
19314 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19315 }
19316 }
19317 spec->multiout.num_dacs = 1;
19318 if (num_pins < 2)
19319 return 0;
19320 return num_pins;
19321}
19322
19323static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
19324 struct snd_ctl_elem_info *uinfo)
19325{
19326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19327 struct alc_spec *spec = codec->spec;
19328
19329 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
19330 uinfo->count = 1;
19331 uinfo->value.enumerated.items = spec->multi_ios + 1;
19332 if (uinfo->value.enumerated.item > spec->multi_ios)
19333 uinfo->value.enumerated.item = spec->multi_ios;
19334 sprintf(uinfo->value.enumerated.name, "%dch",
19335 (uinfo->value.enumerated.item + 1) * 2);
19336 return 0;
19337}
19338
19339static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
19340 struct snd_ctl_elem_value *ucontrol)
19341{
19342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19343 struct alc_spec *spec = codec->spec;
19344 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
19345 return 0;
19346}
19347
19348static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
19349{
19350 struct alc_spec *spec = codec->spec;
19351 hda_nid_t nid = spec->multi_io[idx].pin;
19352
19353 if (!spec->multi_io[idx].ctl_in)
19354 spec->multi_io[idx].ctl_in =
19355 snd_hda_codec_read(codec, nid, 0,
19356 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
19357 if (output) {
19358 snd_hda_codec_update_cache(codec, nid, 0,
19359 AC_VERB_SET_PIN_WIDGET_CONTROL,
19360 PIN_OUT);
19361 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
19362 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
19363 HDA_AMP_MUTE, 0);
19364 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
19365 } else {
19366 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
19367 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
19368 HDA_AMP_MUTE, HDA_AMP_MUTE);
19369 snd_hda_codec_update_cache(codec, nid, 0,
19370 AC_VERB_SET_PIN_WIDGET_CONTROL,
19371 spec->multi_io[idx].ctl_in);
19372 }
19373 return 0;
19374}
19375
19376static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
19377 struct snd_ctl_elem_value *ucontrol)
19378{
19379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19380 struct alc_spec *spec = codec->spec;
19381 int i, ch;
19382
19383 ch = ucontrol->value.enumerated.item[0];
19384 if (ch < 0 || ch > spec->multi_ios)
19385 return -EINVAL;
19386 if (ch == (spec->ext_channel_count - 1) / 2)
19387 return 0;
19388 spec->ext_channel_count = (ch + 1) * 2;
19389 for (i = 0; i < spec->multi_ios; i++)
19390 alc_set_multi_io(codec, i, i < ch);
19391 spec->multiout.max_channels = spec->ext_channel_count;
19392 return 1;
19393}
19394
19395static struct snd_kcontrol_new alc_auto_channel_mode_enum = {
19396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
19397 .name = "Channel Mode",
19398 .info = alc_auto_ch_mode_info,
19399 .get = alc_auto_ch_mode_get,
19400 .put = alc_auto_ch_mode_put,
19401};
19402
19403static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
19404{
19405 struct alc_spec *spec = codec->spec;
19406 struct auto_pin_cfg *cfg = &spec->autocfg;
19407 unsigned int location, defcfg;
19408 int num_pins;
19409
19410 if (cfg->line_outs != 1 ||
19411 cfg->line_out_type != AUTO_PIN_LINE_OUT)
19412 return 0;
19413
19414 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
19415 location = get_defcfg_location(defcfg);
19416
19417 num_pins = alc_auto_fill_multi_ios(codec, location);
19418 if (num_pins > 0) {
19419 struct snd_kcontrol_new *knew;
19420
19421 knew = alc_kcontrol_new(spec);
19422 if (!knew)
19423 return -ENOMEM;
19424 *knew = alc_auto_channel_mode_enum;
19425 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
19426 if (!knew->name)
19427 return -ENOMEM;
19428
19429 spec->multi_ios = num_pins;
19430 spec->ext_channel_count = 2;
19431 spec->multiout.num_dacs = num_pins + 1;
19432 }
19433 return 0;
19434}
19435
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019436static int alc662_parse_auto_config(struct hda_codec *codec)
19437{
19438 struct alc_spec *spec = codec->spec;
19439 int err;
19440 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19441
19442 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19443 alc662_ignore);
19444 if (err < 0)
19445 return err;
19446 if (!spec->autocfg.line_outs)
19447 return 0; /* can't find valid BIOS pin config */
19448
Takashi Iwai7085ec12009-10-02 09:03:58 +020019449 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019450 if (err < 0)
19451 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020019452 err = alc_auto_add_multi_channel_mode(codec);
19453 if (err < 0)
19454 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019455 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019456 if (err < 0)
19457 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019458 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019459 spec->autocfg.speaker_pins[0],
19460 "Speaker");
19461 if (err < 0)
19462 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019463 if (err)
19464 spec->multiout.extra_out_nid[0] = err;
19465 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019466 "Headphone");
19467 if (err < 0)
19468 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019469 if (err)
19470 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019471 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019472 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019473 return err;
19474
19475 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19476
Takashi Iwai757899a2010-07-30 10:48:14 +020019477 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019478
Takashi Iwai603c4012008-07-30 15:01:44 +020019479 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019480 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019481
19482 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019483 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019484
Takashi Iwaiee979a142008-09-02 15:42:20 +020019485 err = alc_auto_add_mic_boost(codec);
19486 if (err < 0)
19487 return err;
19488
Kailang Yang6227cdc2010-02-25 08:36:52 +010019489 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19490 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19491 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19492 else
19493 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019494
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019495 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019496}
19497
19498/* additional initialization for auto-configuration model */
19499static void alc662_auto_init(struct hda_codec *codec)
19500{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019501 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019502 alc662_auto_init_multi_out(codec);
19503 alc662_auto_init_hp_out(codec);
19504 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019505 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019506 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019507 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019508 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019509}
19510
Todd Broch6be79482010-12-07 16:51:05 -080019511static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019512 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019513{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019514 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019515 return;
Todd Broch6be79482010-12-07 16:51:05 -080019516 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19517 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19518 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19519 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19520 (0 << AC_AMPCAP_MUTE_SHIFT)))
19521 printk(KERN_WARNING
19522 "hda_codec: failed to override amp caps for NID 0x2\n");
19523}
19524
David Henningsson6cb3b702010-09-09 08:51:44 +020019525enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019526 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019527 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019528 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019529 ALC662_FIXUP_CZC_P10T,
Takashi Iwaic6b35872011-03-28 12:05:31 +020019530 ALC662_FIXUP_GIGABYTE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019531};
19532
19533static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019534 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019535 .type = ALC_FIXUP_PINS,
19536 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019537 { 0x15, 0x99130112 }, /* subwoofer */
19538 { }
19539 }
19540 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019541 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019542 .type = ALC_FIXUP_PINS,
19543 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019544 { 0x17, 0x99130112 }, /* subwoofer */
19545 { }
19546 }
19547 },
Todd Broch6be79482010-12-07 16:51:05 -080019548 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019549 .type = ALC_FIXUP_FUNC,
19550 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019551 },
19552 [ALC662_FIXUP_CZC_P10T] = {
19553 .type = ALC_FIXUP_VERBS,
19554 .v.verbs = (const struct hda_verb[]) {
19555 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19556 {}
19557 }
19558 },
Takashi Iwaic6b35872011-03-28 12:05:31 +020019559 [ALC662_FIXUP_GIGABYTE] = {
19560 .type = ALC_FIXUP_PINS,
19561 .v.pins = (const struct alc_pincfg[]) {
19562 { 0x14, 0x1114410 }, /* set as speaker */
19563 { }
19564 }
19565 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019566};
19567
19568static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019569 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019570 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019571 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Takashi Iwaic6b35872011-03-28 12:05:31 +020019572 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", ALC662_FIXUP_GIGABYTE),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019573 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019574 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019575 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019576 {}
19577};
19578
Todd Broch6be79482010-12-07 16:51:05 -080019579static const struct alc_model_fixup alc662_fixup_models[] = {
19580 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19581 {}
19582};
David Henningsson6cb3b702010-09-09 08:51:44 +020019583
19584
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019585static int patch_alc662(struct hda_codec *codec)
19586{
19587 struct alc_spec *spec;
19588 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019589 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019590
19591 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19592 if (!spec)
19593 return -ENOMEM;
19594
19595 codec->spec = spec;
19596
Kailang Yangda00c242010-03-19 11:23:45 +010019597 alc_auto_parse_customize_define(codec);
19598
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019599 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19600
Kailang Yang693194f2010-10-21 08:51:48 +020019601 coef = alc_read_coef_idx(codec, 0);
19602 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019603 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019604 else if (coef & (1 << 14) &&
19605 codec->bus->pci->subsystem_vendor == 0x1025 &&
19606 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019607 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019608 else if (coef == 0x4011)
19609 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019610
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019611 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19612 alc662_models,
19613 alc662_cfg_tbl);
19614 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019615 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19616 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019617 board_config = ALC662_AUTO;
19618 }
19619
19620 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019621 alc_pick_fixup(codec, alc662_fixup_models,
19622 alc662_fixup_tbl, alc662_fixups);
19623 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019624 /* automatic parse from the BIOS config */
19625 err = alc662_parse_auto_config(codec);
19626 if (err < 0) {
19627 alc_free(codec);
19628 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019629 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019630 printk(KERN_INFO
19631 "hda_codec: Cannot set up configuration "
19632 "from BIOS. Using base mode...\n");
19633 board_config = ALC662_3ST_2ch_DIG;
19634 }
19635 }
19636
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019637 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019638 err = snd_hda_attach_beep_device(codec, 0x1);
19639 if (err < 0) {
19640 alc_free(codec);
19641 return err;
19642 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019643 }
19644
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019645 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019646 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019647
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019648 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19649 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19650
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019651 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19652 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19653
Takashi Iwaidd704692009-08-11 08:45:11 +020019654 if (!spec->adc_nids) {
19655 spec->adc_nids = alc662_adc_nids;
19656 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19657 }
19658 if (!spec->capsrc_nids)
19659 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019660
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019661 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019662 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019663
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019664 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019665 switch (codec->vendor_id) {
19666 case 0x10ec0662:
19667 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19668 break;
19669 case 0x10ec0272:
19670 case 0x10ec0663:
19671 case 0x10ec0665:
19672 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19673 break;
19674 case 0x10ec0273:
19675 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19676 break;
19677 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019678 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019679 spec->vmaster_nid = 0x02;
19680
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019681 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19682
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019683 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019684 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019685 spec->init_hook = alc662_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020019686 spec->shutup = alc_eapd_shutup;
David Henningsson6cb3b702010-09-09 08:51:44 +020019687
Kailang Yangbf1b0222010-10-21 08:49:56 +020019688 alc_init_jacks(codec);
19689
Takashi Iwaicb53c622007-08-10 17:21:45 +020019690#ifdef CONFIG_SND_HDA_POWER_SAVE
19691 if (!spec->loopback.amplist)
19692 spec->loopback.amplist = alc662_loopbacks;
19693#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019694
19695 return 0;
19696}
19697
Kailang Yang274693f2009-12-03 10:07:50 +010019698static int patch_alc888(struct hda_codec *codec)
19699{
19700 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19701 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019702 if (codec->vendor_id == 0x10ec0887)
19703 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19704 else
19705 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019706 if (!codec->chip_name) {
19707 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019708 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019709 }
19710 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019711 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019712 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019713}
19714
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019715/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019716 * ALC680 support
19717 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019718#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019719#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19720#define alc680_modes alc260_modes
19721
19722static hda_nid_t alc680_dac_nids[3] = {
19723 /* Lout1, Lout2, hp */
19724 0x02, 0x03, 0x04
19725};
19726
19727static hda_nid_t alc680_adc_nids[3] = {
19728 /* ADC0-2 */
19729 /* DMIC, MIC, Line-in*/
19730 0x07, 0x08, 0x09
19731};
19732
Kailang Yangc69aefa2010-08-17 10:39:22 +020019733/*
19734 * Analog capture ADC cgange
19735 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019736static void alc680_rec_autoswitch(struct hda_codec *codec)
19737{
19738 struct alc_spec *spec = codec->spec;
19739 struct auto_pin_cfg *cfg = &spec->autocfg;
19740 int pin_found = 0;
19741 int type_found = AUTO_PIN_LAST;
19742 hda_nid_t nid;
19743 int i;
19744
19745 for (i = 0; i < cfg->num_inputs; i++) {
19746 nid = cfg->inputs[i].pin;
19747 if (!(snd_hda_query_pin_caps(codec, nid) &
19748 AC_PINCAP_PRES_DETECT))
19749 continue;
19750 if (snd_hda_jack_detect(codec, nid)) {
19751 if (cfg->inputs[i].type < type_found) {
19752 type_found = cfg->inputs[i].type;
19753 pin_found = nid;
19754 }
19755 }
19756 }
19757
19758 nid = 0x07;
19759 if (pin_found)
19760 snd_hda_get_connections(codec, pin_found, &nid, 1);
19761
19762 if (nid != spec->cur_adc)
19763 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19764 spec->cur_adc = nid;
19765 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19766 spec->cur_adc_format);
19767}
19768
Kailang Yangc69aefa2010-08-17 10:39:22 +020019769static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19770 struct hda_codec *codec,
19771 unsigned int stream_tag,
19772 unsigned int format,
19773 struct snd_pcm_substream *substream)
19774{
19775 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019776
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019777 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019778 spec->cur_adc_stream_tag = stream_tag;
19779 spec->cur_adc_format = format;
19780
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019781 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019782 return 0;
19783}
19784
19785static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19786 struct hda_codec *codec,
19787 struct snd_pcm_substream *substream)
19788{
19789 snd_hda_codec_cleanup_stream(codec, 0x07);
19790 snd_hda_codec_cleanup_stream(codec, 0x08);
19791 snd_hda_codec_cleanup_stream(codec, 0x09);
19792 return 0;
19793}
19794
19795static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19796 .substreams = 1, /* can be overridden */
19797 .channels_min = 2,
19798 .channels_max = 2,
19799 /* NID is set in alc_build_pcms */
19800 .ops = {
19801 .prepare = alc680_capture_pcm_prepare,
19802 .cleanup = alc680_capture_pcm_cleanup
19803 },
19804};
19805
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019806static struct snd_kcontrol_new alc680_base_mixer[] = {
19807 /* output mixer control */
19808 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19809 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19810 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019812 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19813 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19814 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019815 { }
19816};
19817
Kailang Yangc69aefa2010-08-17 10:39:22 +020019818static struct hda_bind_ctls alc680_bind_cap_vol = {
19819 .ops = &snd_hda_bind_vol,
19820 .values = {
19821 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19822 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19823 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19824 0
19825 },
19826};
19827
19828static struct hda_bind_ctls alc680_bind_cap_switch = {
19829 .ops = &snd_hda_bind_sw,
19830 .values = {
19831 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19832 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19833 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19834 0
19835 },
19836};
19837
19838static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19839 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19840 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019841 { } /* end */
19842};
19843
19844/*
19845 * generic initialization of ADC, input mixers and output mixers
19846 */
19847static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019848 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19849 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19850 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019851
Kailang Yangc69aefa2010-08-17 10:39:22 +020019852 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19855 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19856 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19857 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019858
19859 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19863 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019864
19865 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19866 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019867 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019868
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019869 { }
19870};
19871
Kailang Yangc69aefa2010-08-17 10:39:22 +020019872/* toggle speaker-output according to the hp-jack state */
19873static void alc680_base_setup(struct hda_codec *codec)
19874{
19875 struct alc_spec *spec = codec->spec;
19876
19877 spec->autocfg.hp_pins[0] = 0x16;
19878 spec->autocfg.speaker_pins[0] = 0x14;
19879 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019880 spec->autocfg.num_inputs = 2;
19881 spec->autocfg.inputs[0].pin = 0x18;
19882 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19883 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019884 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Takashi Iwaid922b512011-04-28 12:18:53 +020019885 spec->automute = 1;
19886 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019887}
19888
19889static void alc680_unsol_event(struct hda_codec *codec,
19890 unsigned int res)
19891{
19892 if ((res >> 26) == ALC880_HP_EVENT)
Takashi Iwaid922b512011-04-28 12:18:53 +020019893 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019894 if ((res >> 26) == ALC880_MIC_EVENT)
19895 alc680_rec_autoswitch(codec);
19896}
19897
19898static void alc680_inithook(struct hda_codec *codec)
19899{
Takashi Iwaid922b512011-04-28 12:18:53 +020019900 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019901 alc680_rec_autoswitch(codec);
19902}
19903
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019904/* create input playback/capture controls for the given pin */
19905static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19906 const char *ctlname, int idx)
19907{
19908 hda_nid_t dac;
19909 int err;
19910
19911 switch (nid) {
19912 case 0x14:
19913 dac = 0x02;
19914 break;
19915 case 0x15:
19916 dac = 0x03;
19917 break;
19918 case 0x16:
19919 dac = 0x04;
19920 break;
19921 default:
19922 return 0;
19923 }
19924 if (spec->multiout.dac_nids[0] != dac &&
19925 spec->multiout.dac_nids[1] != dac) {
19926 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19927 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19928 HDA_OUTPUT));
19929 if (err < 0)
19930 return err;
19931
19932 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19933 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19934
19935 if (err < 0)
19936 return err;
19937 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19938 }
19939
19940 return 0;
19941}
19942
19943/* add playback controls from the parsed DAC table */
19944static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19945 const struct auto_pin_cfg *cfg)
19946{
19947 hda_nid_t nid;
19948 int err;
19949
19950 spec->multiout.dac_nids = spec->private_dac_nids;
19951
19952 nid = cfg->line_out_pins[0];
19953 if (nid) {
19954 const char *name;
19955 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19956 name = "Speaker";
19957 else
19958 name = "Front";
19959 err = alc680_new_analog_output(spec, nid, name, 0);
19960 if (err < 0)
19961 return err;
19962 }
19963
19964 nid = cfg->speaker_pins[0];
19965 if (nid) {
19966 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19967 if (err < 0)
19968 return err;
19969 }
19970 nid = cfg->hp_pins[0];
19971 if (nid) {
19972 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19973 if (err < 0)
19974 return err;
19975 }
19976
19977 return 0;
19978}
19979
19980static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19981 hda_nid_t nid, int pin_type)
19982{
19983 alc_set_pin_output(codec, nid, pin_type);
19984}
19985
19986static void alc680_auto_init_multi_out(struct hda_codec *codec)
19987{
19988 struct alc_spec *spec = codec->spec;
19989 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19990 if (nid) {
19991 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19992 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19993 }
19994}
19995
19996static void alc680_auto_init_hp_out(struct hda_codec *codec)
19997{
19998 struct alc_spec *spec = codec->spec;
19999 hda_nid_t pin;
20000
20001 pin = spec->autocfg.hp_pins[0];
20002 if (pin)
20003 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
20004 pin = spec->autocfg.speaker_pins[0];
20005 if (pin)
20006 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
20007}
20008
20009/* pcm configuration: identical with ALC880 */
20010#define alc680_pcm_analog_playback alc880_pcm_analog_playback
20011#define alc680_pcm_analog_capture alc880_pcm_analog_capture
20012#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
20013#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020020014#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020015
20016/*
20017 * BIOS auto configuration
20018 */
20019static int alc680_parse_auto_config(struct hda_codec *codec)
20020{
20021 struct alc_spec *spec = codec->spec;
20022 int err;
20023 static hda_nid_t alc680_ignore[] = { 0 };
20024
20025 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
20026 alc680_ignore);
20027 if (err < 0)
20028 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020029
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020030 if (!spec->autocfg.line_outs) {
20031 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
20032 spec->multiout.max_channels = 2;
20033 spec->no_analog = 1;
20034 goto dig_only;
20035 }
20036 return 0; /* can't find valid BIOS pin config */
20037 }
20038 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
20039 if (err < 0)
20040 return err;
20041
20042 spec->multiout.max_channels = 2;
20043
20044 dig_only:
20045 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020020046 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020047 if (spec->kctls.list)
20048 add_mixer(spec, spec->kctls.list);
20049
20050 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020051
20052 err = alc_auto_add_mic_boost(codec);
20053 if (err < 0)
20054 return err;
20055
20056 return 1;
20057}
20058
20059#define alc680_auto_init_analog_input alc882_auto_init_analog_input
20060
20061/* init callback for auto-configuration model -- overriding the default init */
20062static void alc680_auto_init(struct hda_codec *codec)
20063{
20064 struct alc_spec *spec = codec->spec;
20065 alc680_auto_init_multi_out(codec);
20066 alc680_auto_init_hp_out(codec);
20067 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020020068 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020069 if (spec->unsol_event)
20070 alc_inithook(codec);
20071}
20072
20073/*
20074 * configuration and preset
20075 */
Takashi Iwaiea734962011-01-17 11:29:34 +010020076static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020020077 [ALC680_BASE] = "base",
20078 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020079};
20080
20081static struct snd_pci_quirk alc680_cfg_tbl[] = {
20082 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
20083 {}
20084};
20085
20086static struct alc_config_preset alc680_presets[] = {
20087 [ALC680_BASE] = {
20088 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020020089 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020090 .init_verbs = { alc680_init_verbs },
20091 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
20092 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020093 .dig_out_nid = ALC680_DIGOUT_NID,
20094 .num_channel_mode = ARRAY_SIZE(alc680_modes),
20095 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020020096 .unsol_event = alc680_unsol_event,
20097 .setup = alc680_base_setup,
20098 .init_hook = alc680_inithook,
20099
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020100 },
20101};
20102
20103static int patch_alc680(struct hda_codec *codec)
20104{
20105 struct alc_spec *spec;
20106 int board_config;
20107 int err;
20108
20109 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
20110 if (spec == NULL)
20111 return -ENOMEM;
20112
20113 codec->spec = spec;
20114
20115 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
20116 alc680_models,
20117 alc680_cfg_tbl);
20118
20119 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
20120 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
20121 codec->chip_name);
20122 board_config = ALC680_AUTO;
20123 }
20124
20125 if (board_config == ALC680_AUTO) {
20126 /* automatic parse from the BIOS config */
20127 err = alc680_parse_auto_config(codec);
20128 if (err < 0) {
20129 alc_free(codec);
20130 return err;
20131 } else if (!err) {
20132 printk(KERN_INFO
20133 "hda_codec: Cannot set up configuration "
20134 "from BIOS. Using base mode...\n");
20135 board_config = ALC680_BASE;
20136 }
20137 }
20138
20139 if (board_config != ALC680_AUTO)
20140 setup_preset(codec, &alc680_presets[board_config]);
20141
20142 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020143 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020144 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020145 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020146
20147 if (!spec->adc_nids) {
20148 spec->adc_nids = alc680_adc_nids;
20149 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20150 }
20151
20152 if (!spec->cap_mixer)
20153 set_capture_mixer(codec);
20154
20155 spec->vmaster_nid = 0x02;
20156
20157 codec->patch_ops = alc_patch_ops;
20158 if (board_config == ALC680_AUTO)
20159 spec->init_hook = alc680_auto_init;
20160
20161 return 0;
20162}
20163
20164/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020165 * patch entries
20166 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020167static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020168 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020169 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020170 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020171 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020172 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020173 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020174 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020175 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020176 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020177 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020178 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20179 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20180 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020181 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020182 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020183 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20184 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020185 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020186 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020187 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020188 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020189 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020190 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020191 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020192 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020193 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020194 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020195 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020196 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020197 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020198 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020199 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020200 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020201 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020202 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020203 {} /* terminator */
20204};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020205
20206MODULE_ALIAS("snd-hda-codec-id:10ec*");
20207
20208MODULE_LICENSE("GPL");
20209MODULE_DESCRIPTION("Realtek HD-audio codec");
20210
20211static struct hda_codec_preset_list realtek_list = {
20212 .preset = snd_hda_preset_realtek,
20213 .owner = THIS_MODULE,
20214};
20215
20216static int __init patch_realtek_init(void)
20217{
20218 return snd_hda_add_codec_preset(&realtek_list);
20219}
20220
20221static void __exit patch_realtek_exit(void)
20222{
20223 snd_hda_delete_codec_preset(&realtek_list);
20224}
20225
20226module_init(patch_realtek_init)
20227module_exit(patch_realtek_exit)