blob: 9ba4279c690d2bb87b30bcfc9c4fcac62d5ffde3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
Kailang Yang9ad0e492010-09-14 23:22:00 +0200285struct alc_jack {
286 hda_nid_t nid;
287 int type;
288 struct snd_jack *jack;
289};
290
Takashi Iwai6c819492009-08-10 18:47:44 +0200291#define MUX_IDX_UNDEF ((unsigned char)-1)
292
Kailang Yangda00c242010-03-19 11:23:45 +0100293struct alc_customize_define {
294 unsigned int sku_cfg;
295 unsigned char port_connectivity;
296 unsigned char check_sum;
297 unsigned char customization;
298 unsigned char external_amp;
299 unsigned int enable_pcbeep:1;
300 unsigned int platform_type:1;
301 unsigned int swap:1;
302 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200303 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100304};
305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306struct alc_spec {
307 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100308 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100310 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100311 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200313 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200314 * don't forget NULL
315 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200316 */
317 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200319 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 struct hda_pcm_stream *stream_analog_playback;
321 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100322 struct hda_pcm_stream *stream_analog_alt_playback;
323 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200325 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 struct hda_pcm_stream *stream_digital_playback;
327 struct hda_pcm_stream *stream_digital_capture;
328
329 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200330 struct hda_multi_out multiout; /* playback set-up
331 * max_channels, dacs must be set
332 * dig_out_nid and hp_nid are optional
333 */
Takashi Iwai63300792008-01-24 15:31:36 +0100334 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100335 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100336 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
338 /* capture */
339 unsigned int num_adc_nids;
340 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100341 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200342 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Takashi Iwai840b64c2010-07-13 22:49:01 +0200344 /* capture setup for dynamic dual-adc switch */
345 unsigned int cur_adc_idx;
346 hda_nid_t cur_adc;
347 unsigned int cur_adc_stream_tag;
348 unsigned int cur_adc_format;
349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200351 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 const struct hda_input_mux *input_mux;
353 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200354 struct alc_mic_route ext_mic;
355 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100358 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200360 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200361 int const_channel_count;
362 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363
364 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100365 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200366
Kailang Yang9ad0e492010-09-14 23:22:00 +0200367 /* jack detection */
368 struct snd_array jacks;
369
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200370 /* dynamic controls, init_verbs and input_mux */
371 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100372 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200373 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200374 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200375 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200376 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
377 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100378
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100379 /* hooks */
380 void (*init_hook)(struct hda_codec *codec);
381 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100382#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500383 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100384#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100385
Takashi Iwai834be882006-03-01 14:16:17 +0100386 /* for pin sensing */
387 unsigned int sense_updated: 1;
388 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100389 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200390 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200391
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100392 /* other flags */
393 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200394 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200395 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200396 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100397
Takashi Iwai2134ea42008-01-10 16:53:55 +0100398 /* for virtual master */
399 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200400#ifdef CONFIG_SND_HDA_POWER_SAVE
401 struct hda_loopback_check loopback;
402#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200403
404 /* for PLL fix */
405 hda_nid_t pll_nid;
406 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100407};
408
409/*
410 * configuration template - to be copied to the spec instance
411 */
412struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200413 struct snd_kcontrol_new *mixers[5]; /* should be identical size
414 * with spec
415 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100416 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100417 const struct hda_verb *init_verbs[5];
418 unsigned int num_dacs;
419 hda_nid_t *dac_nids;
420 hda_nid_t dig_out_nid; /* optional */
421 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800422 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100423 unsigned int num_adc_nids;
424 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100425 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100426 hda_nid_t dig_in_nid;
427 unsigned int num_channel_mode;
428 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200429 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200430 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200431 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100432 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100433 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200434 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100435 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200436#ifdef CONFIG_SND_HDA_POWER_SAVE
437 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500438 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200439#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440};
441
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
443/*
444 * input MUX handling
445 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200446static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448{
449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
450 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200451 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
452 if (mux_idx >= spec->num_mux_defs)
453 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100454 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
455 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200456 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457}
458
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
464 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
465
466 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
467 return 0;
468}
469
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472{
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100475 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100477 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100478 hda_nid_t nid = spec->capsrc_nids ?
479 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200480 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
Takashi Iwaicd896c32008-11-18 12:36:33 +0100482 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
483 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100484 if (!imux->num_items && mux_idx > 0)
485 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100486
Takashi Iwaia22d5432009-07-27 12:54:26 +0200487 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200488 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100489 /* Matrix-mixer style (e.g. ALC882) */
490 unsigned int *cur_val = &spec->cur_mux[adc_idx];
491 unsigned int i, idx;
492
493 idx = ucontrol->value.enumerated.item[0];
494 if (idx >= imux->num_items)
495 idx = imux->num_items - 1;
496 if (*cur_val == idx)
497 return 0;
498 for (i = 0; i < imux->num_items; i++) {
499 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
500 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
501 imux->items[i].index,
502 HDA_AMP_MUTE, v);
503 }
504 *cur_val = idx;
505 return 1;
506 } else {
507 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100508 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100509 &spec->cur_mux[adc_idx]);
510 }
511}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200512
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513/*
514 * channel mode setting
515 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200516static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518{
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100521 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
522 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523}
524
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200525static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100530 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200531 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200532 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533}
534
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200535static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537{
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200540 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
541 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200542 &spec->ext_channel_count);
543 if (err >= 0 && !spec->const_channel_count) {
544 spec->multiout.max_channels = spec->ext_channel_count;
545 if (spec->need_dac_fix)
546 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
547 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200548 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549}
550
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200553 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 * being part of a format specifier. Maximum allowed length of a value is
555 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100556 *
557 * Note: some retasking pin complexes seem to ignore requests for input
558 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
559 * are requested. Therefore order this list so that this behaviour will not
560 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200561 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
562 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200563 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100564static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100565 "Mic 50pc bias", "Mic 80pc bias",
566 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567};
568static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100569 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570};
571/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200572 * in the pin being assumed to be exclusively an input or an output pin. In
573 * addition, "input" pins may or may not process the mic bias option
574 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
575 * accept requests for bias as of chip versions up to March 2006) and/or
576 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200578#define ALC_PIN_DIR_IN 0x00
579#define ALC_PIN_DIR_OUT 0x01
580#define ALC_PIN_DIR_INOUT 0x02
581#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
582#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583
Kailang Yangea1fb292008-08-26 12:58:38 +0200584/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585 * For each direction the minimum and maximum values are given.
586 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200587static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588 { 0, 2 }, /* ALC_PIN_DIR_IN */
589 { 3, 4 }, /* ALC_PIN_DIR_OUT */
590 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200591 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
592 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100593};
594#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
595#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
596#define alc_pin_mode_n_items(_dir) \
597 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
598
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200599static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
600 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200601{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100602 unsigned int item_num = uinfo->value.enumerated.item;
603 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
604
605 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200606 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100607 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
608
609 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
610 item_num = alc_pin_mode_min(dir);
611 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200612 return 0;
613}
614
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200615static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200617{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100618 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200622 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200623 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
624 AC_VERB_GET_PIN_WIDGET_CONTROL,
625 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200626
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100627 /* Find enumerated value for current pinctl setting */
628 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200629 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200631 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100632 return 0;
633}
634
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200635static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100637{
638 signed int change;
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 hda_nid_t nid = kcontrol->private_value & 0xffff;
641 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
642 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
644 AC_VERB_GET_PIN_WIDGET_CONTROL,
645 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200647 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100648 val = alc_pin_mode_min(dir);
649
650 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100651 if (change) {
652 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200653 snd_hda_codec_write_cache(codec, nid, 0,
654 AC_VERB_SET_PIN_WIDGET_CONTROL,
655 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100656
Kailang Yangea1fb292008-08-26 12:58:38 +0200657 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100658 * for the requested pin mode. Enum values of 2 or less are
659 * input modes.
660 *
661 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200662 * reduces noise slightly (particularly on input) so we'll
663 * do it. However, having both input and output buffers
664 * enabled simultaneously doesn't seem to be problematic if
665 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100666 */
667 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200668 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
669 HDA_AMP_MUTE, HDA_AMP_MUTE);
670 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
671 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100672 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200673 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
674 HDA_AMP_MUTE, HDA_AMP_MUTE);
675 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
676 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100677 }
678 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200679 return change;
680}
681
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100682#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200683 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100684 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100685 .info = alc_pin_mode_info, \
686 .get = alc_pin_mode_get, \
687 .put = alc_pin_mode_put, \
688 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100689
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100690/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
691 * together using a mask with more than one bit set. This control is
692 * currently used only by the ALC260 test model. At this stage they are not
693 * needed for any "production" models.
694 */
695#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200696#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200697
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200698static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
699 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100700{
701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
702 hda_nid_t nid = kcontrol->private_value & 0xffff;
703 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
704 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705 unsigned int val = snd_hda_codec_read(codec, nid, 0,
706 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100707
708 *valp = (val & mask) != 0;
709 return 0;
710}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200711static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
712 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100713{
714 signed int change;
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716 hda_nid_t nid = kcontrol->private_value & 0xffff;
717 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
718 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200719 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
720 AC_VERB_GET_GPIO_DATA,
721 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100722
723 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200724 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
725 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100726 gpio_data &= ~mask;
727 else
728 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200729 snd_hda_codec_write_cache(codec, nid, 0,
730 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100731
732 return change;
733}
734#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
735 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100736 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100737 .info = alc_gpio_data_info, \
738 .get = alc_gpio_data_get, \
739 .put = alc_gpio_data_put, \
740 .private_value = nid | (mask<<16) }
741#endif /* CONFIG_SND_DEBUG */
742
Jonathan Woithe92621f12006-02-28 11:47:47 +0100743/* A switch control to allow the enabling of the digital IO pins on the
744 * ALC260. This is incredibly simplistic; the intention of this control is
745 * to provide something in the test model allowing digital outputs to be
746 * identified if present. If models are found which can utilise these
747 * outputs a more complete mixer control can be devised for those models if
748 * necessary.
749 */
750#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200751#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200752
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200753static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
754 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100755{
756 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
757 hda_nid_t nid = kcontrol->private_value & 0xffff;
758 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
759 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200760 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100761 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100762
763 *valp = (val & mask) != 0;
764 return 0;
765}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200766static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
767 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100768{
769 signed int change;
770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
771 hda_nid_t nid = kcontrol->private_value & 0xffff;
772 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
773 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200774 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100775 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200776 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100777
778 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200779 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100780 if (val==0)
781 ctrl_data &= ~mask;
782 else
783 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200784 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
785 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100786
787 return change;
788}
789#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
790 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100791 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100792 .info = alc_spdif_ctrl_info, \
793 .get = alc_spdif_ctrl_get, \
794 .put = alc_spdif_ctrl_put, \
795 .private_value = nid | (mask<<16) }
796#endif /* CONFIG_SND_DEBUG */
797
Jonathan Woithef8225f62008-01-08 12:16:54 +0100798/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
799 * Again, this is only used in the ALC26x test models to help identify when
800 * the EAPD line must be asserted for features to work.
801 */
802#ifdef CONFIG_SND_DEBUG
803#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
804
805static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
806 struct snd_ctl_elem_value *ucontrol)
807{
808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
809 hda_nid_t nid = kcontrol->private_value & 0xffff;
810 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
811 long *valp = ucontrol->value.integer.value;
812 unsigned int val = snd_hda_codec_read(codec, nid, 0,
813 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
814
815 *valp = (val & mask) != 0;
816 return 0;
817}
818
819static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
820 struct snd_ctl_elem_value *ucontrol)
821{
822 int change;
823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
824 hda_nid_t nid = kcontrol->private_value & 0xffff;
825 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
826 long val = *ucontrol->value.integer.value;
827 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
828 AC_VERB_GET_EAPD_BTLENABLE,
829 0x00);
830
831 /* Set/unset the masked control bit(s) as needed */
832 change = (!val ? 0 : mask) != (ctrl_data & mask);
833 if (!val)
834 ctrl_data &= ~mask;
835 else
836 ctrl_data |= mask;
837 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
838 ctrl_data);
839
840 return change;
841}
842
843#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
844 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100845 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100846 .info = alc_eapd_ctrl_info, \
847 .get = alc_eapd_ctrl_get, \
848 .put = alc_eapd_ctrl_put, \
849 .private_value = nid | (mask<<16) }
850#endif /* CONFIG_SND_DEBUG */
851
Kailang Yangdf694da2005-12-05 19:42:22 +0100852/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100853 * set up the input pin config (depending on the given auto-pin type)
854 */
855static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
856 int auto_pin_type)
857{
858 unsigned int val = PIN_IN;
859
Takashi Iwai86e29592010-09-09 14:50:17 +0200860 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100861 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200862 unsigned int oldval;
863 oldval = snd_hda_codec_read(codec, nid, 0,
864 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100865 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100866 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200867 /* if the default pin setup is vref50, we give it priority */
868 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100869 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200870 else if (pincap & AC_PINCAP_VREF_50)
871 val = PIN_VREF50;
872 else if (pincap & AC_PINCAP_VREF_100)
873 val = PIN_VREF100;
874 else if (pincap & AC_PINCAP_VREF_GRD)
875 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100876 }
877 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
878}
879
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200880static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
881{
882 struct alc_spec *spec = codec->spec;
883 struct auto_pin_cfg *cfg = &spec->autocfg;
884
885 if (!cfg->line_outs) {
886 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
887 cfg->line_out_pins[cfg->line_outs])
888 cfg->line_outs++;
889 }
890 if (!cfg->speaker_outs) {
891 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
892 cfg->speaker_pins[cfg->speaker_outs])
893 cfg->speaker_outs++;
894 }
895 if (!cfg->hp_outs) {
896 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
897 cfg->hp_pins[cfg->hp_outs])
898 cfg->hp_outs++;
899 }
900}
901
Takashi Iwai23f0c042009-02-26 13:03:58 +0100902/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100903 */
904static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
905{
906 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
907 return;
908 spec->mixers[spec->num_mixers++] = mix;
909}
910
911static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
912{
913 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
914 return;
915 spec->init_verbs[spec->num_init_verbs++] = verb;
916}
917
918/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100919 * set up from the preset table
920 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200921static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200922 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100923{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200924 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100925 int i;
926
927 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100928 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100929 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200930 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
931 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100932 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200933
Kailang Yangdf694da2005-12-05 19:42:22 +0100934 spec->channel_mode = preset->channel_mode;
935 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200936 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200937 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100938
Hector Martin3b315d72009-06-02 10:54:19 +0200939 if (preset->const_channel_count)
940 spec->multiout.max_channels = preset->const_channel_count;
941 else
942 spec->multiout.max_channels = spec->channel_mode[0].channels;
943 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100944
945 spec->multiout.num_dacs = preset->num_dacs;
946 spec->multiout.dac_nids = preset->dac_nids;
947 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800948 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100949 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200950
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200951 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200952 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200953 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100954 spec->input_mux = preset->input_mux;
955
956 spec->num_adc_nids = preset->num_adc_nids;
957 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100958 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100959 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100960
961 spec->unsol_event = preset->unsol_event;
962 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200963#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100964 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200965 spec->loopback.amplist = preset->loopbacks;
966#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200967
968 if (preset->setup)
969 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200970
971 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100972}
973
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200974/* Enable GPIO mask and set output */
975static struct hda_verb alc_gpio1_init_verbs[] = {
976 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
978 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
979 { }
980};
981
982static struct hda_verb alc_gpio2_init_verbs[] = {
983 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
985 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
986 { }
987};
988
Kailang Yangbdd148a2007-05-08 15:19:08 +0200989static struct hda_verb alc_gpio3_init_verbs[] = {
990 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
992 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
993 { }
994};
995
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200996/*
997 * Fix hardware PLL issue
998 * On some codecs, the analog PLL gating control must be off while
999 * the default value is 1.
1000 */
1001static void alc_fix_pll(struct hda_codec *codec)
1002{
1003 struct alc_spec *spec = codec->spec;
1004 unsigned int val;
1005
1006 if (!spec->pll_nid)
1007 return;
1008 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1009 spec->pll_coef_idx);
1010 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1011 AC_VERB_GET_PROC_COEF, 0);
1012 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1013 spec->pll_coef_idx);
1014 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1015 val & ~(1 << spec->pll_coef_bit));
1016}
1017
1018static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1019 unsigned int coef_idx, unsigned int coef_bit)
1020{
1021 struct alc_spec *spec = codec->spec;
1022 spec->pll_nid = nid;
1023 spec->pll_coef_idx = coef_idx;
1024 spec->pll_coef_bit = coef_bit;
1025 alc_fix_pll(codec);
1026}
1027
Kailang Yang9ad0e492010-09-14 23:22:00 +02001028#ifdef CONFIG_SND_HDA_INPUT_JACK
1029static void alc_free_jack_priv(struct snd_jack *jack)
1030{
1031 struct alc_jack *jacks = jack->private_data;
1032 jacks->nid = 0;
1033 jacks->jack = NULL;
1034}
1035
1036static int alc_add_jack(struct hda_codec *codec,
1037 hda_nid_t nid, int type)
1038{
1039 struct alc_spec *spec;
1040 struct alc_jack *jack;
1041 const char *name;
1042 int err;
1043
1044 spec = codec->spec;
1045 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1046 jack = snd_array_new(&spec->jacks);
1047 if (!jack)
1048 return -ENOMEM;
1049
1050 jack->nid = nid;
1051 jack->type = type;
1052 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1053
1054 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1055 if (err < 0)
1056 return err;
1057 jack->jack->private_data = jack;
1058 jack->jack->private_free = alc_free_jack_priv;
1059 return 0;
1060}
1061
1062static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1063{
1064 struct alc_spec *spec = codec->spec;
1065 struct alc_jack *jacks = spec->jacks.list;
1066
1067 if (jacks) {
1068 int i;
1069 for (i = 0; i < spec->jacks.used; i++) {
1070 if (jacks->nid == nid) {
1071 unsigned int present;
1072 present = snd_hda_jack_detect(codec, nid);
1073
1074 present = (present) ? jacks->type : 0;
1075
1076 snd_jack_report(jacks->jack, present);
1077 }
1078 jacks++;
1079 }
1080 }
1081}
1082
1083static int alc_init_jacks(struct hda_codec *codec)
1084{
1085 struct alc_spec *spec = codec->spec;
1086 int err;
1087 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1088 unsigned int mic_nid = spec->ext_mic.pin;
1089
Takashi Iwai265a0242010-09-21 11:26:21 +02001090 if (hp_nid) {
1091 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1092 if (err < 0)
1093 return err;
1094 alc_report_jack(codec, hp_nid);
1095 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001096
Takashi Iwai265a0242010-09-21 11:26:21 +02001097 if (mic_nid) {
1098 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1099 if (err < 0)
1100 return err;
1101 alc_report_jack(codec, mic_nid);
1102 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001103
1104 return 0;
1105}
1106#else
1107static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1108{
1109}
1110
1111static inline int alc_init_jacks(struct hda_codec *codec)
1112{
1113 return 0;
1114}
1115#endif
1116
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001117static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001118{
1119 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001120 unsigned int mute;
1121 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001122 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001123
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001124 spec->jack_present = 0;
1125 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1126 nid = spec->autocfg.hp_pins[i];
1127 if (!nid)
1128 break;
1129 if (snd_hda_jack_detect(codec, nid)) {
1130 spec->jack_present = 1;
1131 break;
1132 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001133 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001134 }
1135
1136 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1137 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001138 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1139 nid = spec->autocfg.speaker_pins[i];
1140 if (!nid)
1141 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001142 if (pinctl) {
1143 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001144 AC_VERB_SET_PIN_WIDGET_CONTROL,
1145 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001146 } else {
1147 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1148 HDA_AMP_MUTE, mute);
1149 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001150 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001151}
1152
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001153static void alc_automute_pin(struct hda_codec *codec)
1154{
1155 alc_automute_speaker(codec, 1);
1156}
1157
Takashi Iwai6c819492009-08-10 18:47:44 +02001158static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1159 hda_nid_t nid)
1160{
1161 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1162 int i, nums;
1163
1164 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1165 for (i = 0; i < nums; i++)
1166 if (conn[i] == nid)
1167 return i;
1168 return -1;
1169}
1170
Takashi Iwai840b64c2010-07-13 22:49:01 +02001171/* switch the current ADC according to the jack state */
1172static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1173{
1174 struct alc_spec *spec = codec->spec;
1175 unsigned int present;
1176 hda_nid_t new_adc;
1177
1178 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1179 if (present)
1180 spec->cur_adc_idx = 1;
1181 else
1182 spec->cur_adc_idx = 0;
1183 new_adc = spec->adc_nids[spec->cur_adc_idx];
1184 if (spec->cur_adc && spec->cur_adc != new_adc) {
1185 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001186 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001187 spec->cur_adc = new_adc;
1188 snd_hda_codec_setup_stream(codec, new_adc,
1189 spec->cur_adc_stream_tag, 0,
1190 spec->cur_adc_format);
1191 }
1192}
1193
Kailang Yang7fb0d782008-10-15 11:12:35 +02001194static void alc_mic_automute(struct hda_codec *codec)
1195{
1196 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001197 struct alc_mic_route *dead, *alive;
1198 unsigned int present, type;
1199 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001200
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001201 if (!spec->auto_mic)
1202 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001203 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1204 return;
1205 if (snd_BUG_ON(!spec->adc_nids))
1206 return;
1207
Takashi Iwai840b64c2010-07-13 22:49:01 +02001208 if (spec->dual_adc_switch) {
1209 alc_dual_mic_adc_auto_switch(codec);
1210 return;
1211 }
1212
Takashi Iwai6c819492009-08-10 18:47:44 +02001213 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1214
Wu Fengguang864f92b2009-11-18 12:38:02 +08001215 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001216 if (present) {
1217 alive = &spec->ext_mic;
1218 dead = &spec->int_mic;
1219 } else {
1220 alive = &spec->int_mic;
1221 dead = &spec->ext_mic;
1222 }
1223
Takashi Iwai6c819492009-08-10 18:47:44 +02001224 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1225 if (type == AC_WID_AUD_MIX) {
1226 /* Matrix-mixer style (e.g. ALC882) */
1227 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1228 alive->mux_idx,
1229 HDA_AMP_MUTE, 0);
1230 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1231 dead->mux_idx,
1232 HDA_AMP_MUTE, HDA_AMP_MUTE);
1233 } else {
1234 /* MUX style (e.g. ALC880) */
1235 snd_hda_codec_write_cache(codec, cap_nid, 0,
1236 AC_VERB_SET_CONNECT_SEL,
1237 alive->mux_idx);
1238 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001239 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001240
1241 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001242}
1243
Kailang Yangc9b58002007-10-16 14:30:01 +02001244/* unsolicited event for HP jack sensing */
1245static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1246{
1247 if (codec->vendor_id == 0x10ec0880)
1248 res >>= 28;
1249 else
1250 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001251 switch (res) {
1252 case ALC880_HP_EVENT:
1253 alc_automute_pin(codec);
1254 break;
1255 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001256 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001257 break;
1258 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001259}
1260
1261static void alc_inithook(struct hda_codec *codec)
1262{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001263 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001264 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001265}
1266
Kailang Yangf9423e72008-05-27 12:32:25 +02001267/* additional initialization for ALC888 variants */
1268static void alc888_coef_init(struct hda_codec *codec)
1269{
1270 unsigned int tmp;
1271
1272 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1273 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1274 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001275 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001276 /* alc888S-VC */
1277 snd_hda_codec_read(codec, 0x20, 0,
1278 AC_VERB_SET_PROC_COEF, 0x830);
1279 else
1280 /* alc888-VB */
1281 snd_hda_codec_read(codec, 0x20, 0,
1282 AC_VERB_SET_PROC_COEF, 0x3030);
1283}
1284
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001285static void alc889_coef_init(struct hda_codec *codec)
1286{
1287 unsigned int tmp;
1288
1289 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1290 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1291 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1292 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1293}
1294
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001295/* turn on/off EAPD control (only if available) */
1296static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1297{
1298 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1299 return;
1300 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1301 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1302 on ? 2 : 0);
1303}
1304
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001305static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001306{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001307 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001308
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001309 switch (type) {
1310 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001311 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1312 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001313 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001314 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1315 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001316 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001317 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1318 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001319 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001320 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001321 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001322 set_eapd(codec, 0x0f, 1);
1323 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001324 break;
1325 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001326 case 0x10ec0267:
1327 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001328 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001329 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001330 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001331 case 0x10ec0660:
1332 case 0x10ec0662:
1333 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001334 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001335 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001336 set_eapd(codec, 0x14, 1);
1337 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001339 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 switch (codec->vendor_id) {
1341 case 0x10ec0260:
1342 snd_hda_codec_write(codec, 0x1a, 0,
1343 AC_VERB_SET_COEF_INDEX, 7);
1344 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1345 AC_VERB_GET_PROC_COEF, 0);
1346 snd_hda_codec_write(codec, 0x1a, 0,
1347 AC_VERB_SET_COEF_INDEX, 7);
1348 snd_hda_codec_write(codec, 0x1a, 0,
1349 AC_VERB_SET_PROC_COEF,
1350 tmp | 0x2010);
1351 break;
1352 case 0x10ec0262:
1353 case 0x10ec0880:
1354 case 0x10ec0882:
1355 case 0x10ec0883:
1356 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001357 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001358 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001359 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001360 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001361 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001362 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001363 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001364#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001365 case 0x10ec0267:
1366 case 0x10ec0268:
1367 snd_hda_codec_write(codec, 0x20, 0,
1368 AC_VERB_SET_COEF_INDEX, 7);
1369 tmp = snd_hda_codec_read(codec, 0x20, 0,
1370 AC_VERB_GET_PROC_COEF, 0);
1371 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001372 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001373 snd_hda_codec_write(codec, 0x20, 0,
1374 AC_VERB_SET_PROC_COEF,
1375 tmp | 0x3000);
1376 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001377#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001378 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001379 break;
1380 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001381}
Kailang Yangea1fb292008-08-26 12:58:38 +02001382
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001383static void alc_init_auto_hp(struct hda_codec *codec)
1384{
1385 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001386 struct auto_pin_cfg *cfg = &spec->autocfg;
1387 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001388
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001389 if (!cfg->hp_pins[0]) {
1390 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001391 return;
1392 }
1393
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001394 if (!cfg->speaker_pins[0]) {
1395 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1396 return;
1397 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1398 sizeof(cfg->speaker_pins));
1399 cfg->speaker_outs = cfg->line_outs;
1400 }
1401
1402 if (!cfg->hp_pins[0]) {
1403 memcpy(cfg->hp_pins, cfg->line_out_pins,
1404 sizeof(cfg->hp_pins));
1405 cfg->hp_outs = cfg->line_outs;
1406 }
1407
1408 for (i = 0; i < cfg->hp_outs; i++) {
1409 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1410 cfg->hp_pins[i]);
1411 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001412 AC_VERB_SET_UNSOLICITED_ENABLE,
1413 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001414 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001415 spec->unsol_event = alc_sku_unsol_event;
1416}
1417
Takashi Iwai6c819492009-08-10 18:47:44 +02001418static void alc_init_auto_mic(struct hda_codec *codec)
1419{
1420 struct alc_spec *spec = codec->spec;
1421 struct auto_pin_cfg *cfg = &spec->autocfg;
1422 hda_nid_t fixed, ext;
1423 int i;
1424
1425 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001426 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001427 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001428 return;
1429
1430 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001431 for (i = 0; i < cfg->num_inputs; i++) {
1432 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001433 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001434 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001435 switch (snd_hda_get_input_pin_attr(defcfg)) {
1436 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001437 if (fixed)
1438 return; /* already occupied */
1439 fixed = nid;
1440 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001441 case INPUT_PIN_ATTR_UNUSED:
1442 return; /* invalid entry */
1443 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001444 if (ext)
1445 return; /* already occupied */
1446 ext = nid;
1447 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001448 }
1449 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001450 if (!ext || !fixed)
1451 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001452 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1453 return; /* no unsol support */
1454 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1455 ext, fixed);
1456 spec->ext_mic.pin = ext;
1457 spec->int_mic.pin = fixed;
1458 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1459 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1460 spec->auto_mic = 1;
1461 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1462 AC_VERB_SET_UNSOLICITED_ENABLE,
1463 AC_USRSP_EN | ALC880_MIC_EVENT);
1464 spec->unsol_event = alc_sku_unsol_event;
1465}
1466
David Henningsson90622912010-10-14 14:50:18 +02001467/* Could be any non-zero and even value. When used as fixup, tells
1468 * the driver to ignore any present sku defines.
1469 */
1470#define ALC_FIXUP_SKU_IGNORE (2)
1471
Kailang Yangda00c242010-03-19 11:23:45 +01001472static int alc_auto_parse_customize_define(struct hda_codec *codec)
1473{
1474 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001475 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001476 struct alc_spec *spec = codec->spec;
1477
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001478 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1479
David Henningsson90622912010-10-14 14:50:18 +02001480 if (spec->cdefine.fixup) {
1481 ass = spec->cdefine.sku_cfg;
1482 if (ass == ALC_FIXUP_SKU_IGNORE)
1483 return -1;
1484 goto do_sku;
1485 }
1486
Kailang Yangda00c242010-03-19 11:23:45 +01001487 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001488 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001489 goto do_sku;
1490
1491 nid = 0x1d;
1492 if (codec->vendor_id == 0x10ec0260)
1493 nid = 0x17;
1494 ass = snd_hda_codec_get_pincfg(codec, nid);
1495
1496 if (!(ass & 1)) {
1497 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1498 codec->chip_name, ass);
1499 return -1;
1500 }
1501
1502 /* check sum */
1503 tmp = 0;
1504 for (i = 1; i < 16; i++) {
1505 if ((ass >> i) & 1)
1506 tmp++;
1507 }
1508 if (((ass >> 16) & 0xf) != tmp)
1509 return -1;
1510
1511 spec->cdefine.port_connectivity = ass >> 30;
1512 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1513 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1514 spec->cdefine.customization = ass >> 8;
1515do_sku:
1516 spec->cdefine.sku_cfg = ass;
1517 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1518 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1519 spec->cdefine.swap = (ass & 0x2) >> 1;
1520 spec->cdefine.override = ass & 0x1;
1521
1522 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1523 nid, spec->cdefine.sku_cfg);
1524 snd_printd("SKU: port_connectivity=0x%x\n",
1525 spec->cdefine.port_connectivity);
1526 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1527 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1528 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1529 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1530 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1531 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1532 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1533
1534 return 0;
1535}
1536
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001537/* check subsystem ID and set up device-specific initialization;
1538 * return 1 if initialized, 0 if invalid SSID
1539 */
1540/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1541 * 31 ~ 16 : Manufacture ID
1542 * 15 ~ 8 : SKU ID
1543 * 7 ~ 0 : Assembly ID
1544 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1545 */
1546static int alc_subsystem_id(struct hda_codec *codec,
1547 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001548 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001549{
1550 unsigned int ass, tmp, i;
1551 unsigned nid;
1552 struct alc_spec *spec = codec->spec;
1553
David Henningsson90622912010-10-14 14:50:18 +02001554 if (spec->cdefine.fixup) {
1555 ass = spec->cdefine.sku_cfg;
1556 if (ass == ALC_FIXUP_SKU_IGNORE)
1557 return 0;
1558 goto do_sku;
1559 }
1560
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001561 ass = codec->subsystem_id & 0xffff;
1562 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1563 goto do_sku;
1564
1565 /* invalid SSID, check the special NID pin defcfg instead */
1566 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001567 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001568 * 29~21 : reserve
1569 * 20 : PCBEEP input
1570 * 19~16 : Check sum (15:1)
1571 * 15~1 : Custom
1572 * 0 : override
1573 */
1574 nid = 0x1d;
1575 if (codec->vendor_id == 0x10ec0260)
1576 nid = 0x17;
1577 ass = snd_hda_codec_get_pincfg(codec, nid);
1578 snd_printd("realtek: No valid SSID, "
1579 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001580 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001581 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001582 return 0;
1583 if ((ass >> 30) != 1) /* no physical connection */
1584 return 0;
1585
1586 /* check sum */
1587 tmp = 0;
1588 for (i = 1; i < 16; i++) {
1589 if ((ass >> i) & 1)
1590 tmp++;
1591 }
1592 if (((ass >> 16) & 0xf) != tmp)
1593 return 0;
1594do_sku:
1595 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1596 ass & 0xffff, codec->vendor_id);
1597 /*
1598 * 0 : override
1599 * 1 : Swap Jack
1600 * 2 : 0 --> Desktop, 1 --> Laptop
1601 * 3~5 : External Amplifier control
1602 * 7~6 : Reserved
1603 */
1604 tmp = (ass & 0x38) >> 3; /* external Amp control */
1605 switch (tmp) {
1606 case 1:
1607 spec->init_amp = ALC_INIT_GPIO1;
1608 break;
1609 case 3:
1610 spec->init_amp = ALC_INIT_GPIO2;
1611 break;
1612 case 7:
1613 spec->init_amp = ALC_INIT_GPIO3;
1614 break;
1615 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001616 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001617 spec->init_amp = ALC_INIT_DEFAULT;
1618 break;
1619 }
1620
1621 /* is laptop or Desktop and enable the function "Mute internal speaker
1622 * when the external headphone out jack is plugged"
1623 */
1624 if (!(ass & 0x8000))
1625 return 1;
1626 /*
1627 * 10~8 : Jack location
1628 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1629 * 14~13: Resvered
1630 * 15 : 1 --> enable the function "Mute internal speaker
1631 * when the external headphone out jack is plugged"
1632 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001633 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001634 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001635 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1636 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001637 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001638 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001639 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001640 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001641 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001642 else if (tmp == 3)
1643 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001644 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001645 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001646 for (i = 0; i < spec->autocfg.line_outs; i++)
1647 if (spec->autocfg.line_out_pins[i] == nid)
1648 return 1;
1649 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001650 }
1651
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001652 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001653 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001654 return 1;
1655}
Kailang Yangea1fb292008-08-26 12:58:38 +02001656
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001657static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001658 hda_nid_t porta, hda_nid_t porte,
1659 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001660{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001661 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001662 struct alc_spec *spec = codec->spec;
1663 snd_printd("realtek: "
1664 "Enable default setup for auto mode as fallback\n");
1665 spec->init_amp = ALC_INIT_DEFAULT;
1666 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001667 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001668 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001669}
1670
Takashi Iwai41e41f12005-06-08 14:48:49 +02001671/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001672 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001673 */
1674
1675struct alc_pincfg {
1676 hda_nid_t nid;
1677 u32 val;
1678};
1679
Todd Broche1eb5f12010-12-06 11:19:51 -08001680struct alc_model_fixup {
1681 const int id;
1682 const char *name;
1683};
1684
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001685struct alc_fixup {
David Henningsson90622912010-10-14 14:50:18 +02001686 unsigned int sku;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001687 const struct alc_pincfg *pins;
1688 const struct hda_verb *verbs;
Takashi Iwai9d578832010-11-22 13:29:19 +01001689 void (*func)(struct hda_codec *codec, const struct alc_fixup *fix,
1690 int pre_init);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001691};
1692
Todd Broche1eb5f12010-12-06 11:19:51 -08001693static void __alc_pick_fixup(struct hda_codec *codec,
1694 const struct alc_fixup *fix,
1695 const char *modelname,
1696 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001697{
1698 const struct alc_pincfg *cfg;
David Henningsson90622912010-10-14 14:50:18 +02001699 struct alc_spec *spec;
Takashi Iwaif95474e2007-07-10 00:47:43 +02001700
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001701 cfg = fix->pins;
David Henningsson90622912010-10-14 14:50:18 +02001702 if (pre_init && fix->sku) {
1703#ifdef CONFIG_SND_DEBUG_VERBOSE
1704 snd_printdd(KERN_INFO "hda_codec: %s: Apply sku override for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001705 codec->chip_name, modelname);
David Henningsson90622912010-10-14 14:50:18 +02001706#endif
1707 spec = codec->spec;
1708 spec->cdefine.sku_cfg = fix->sku;
1709 spec->cdefine.fixup = 1;
1710 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001711 if (pre_init && cfg) {
1712#ifdef CONFIG_SND_DEBUG_VERBOSE
1713 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001714 codec->chip_name, modelname);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001715#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001716 for (; cfg->nid; cfg++)
1717 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1718 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001719 if (!pre_init && fix->verbs) {
1720#ifdef CONFIG_SND_DEBUG_VERBOSE
1721 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001722 codec->chip_name, modelname);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001723#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001724 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001725 }
Takashi Iwai9d578832010-11-22 13:29:19 +01001726 if (fix->func) {
1727#ifdef CONFIG_SND_DEBUG_VERBOSE
1728 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-func for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001729 codec->chip_name, modelname);
Takashi Iwai9d578832010-11-22 13:29:19 +01001730#endif
1731 fix->func(codec, fix, pre_init);
1732 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001733}
1734
Todd Broche1eb5f12010-12-06 11:19:51 -08001735static void alc_pick_fixup(struct hda_codec *codec,
1736 const struct snd_pci_quirk *quirk,
1737 const struct alc_fixup *fix,
1738 int pre_init)
1739{
1740 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1741 if (quirk) {
1742 fix += quirk->value;
1743#ifdef CONFIG_SND_DEBUG_VERBOSE
1744 __alc_pick_fixup(codec, fix, quirk->name, pre_init);
1745#else
1746 __alc_pick_fixup(codec, fix, NULL, pre_init);
1747#endif
1748 }
1749}
1750
1751static void alc_pick_fixup_model(struct hda_codec *codec,
1752 const struct alc_model_fixup *models,
1753 const struct snd_pci_quirk *quirk,
1754 const struct alc_fixup *fix,
1755 int pre_init)
1756{
1757 if (codec->modelname && models) {
1758 while (models->name) {
1759 if (!strcmp(codec->modelname, models->name)) {
1760 fix += models->id;
1761 break;
1762 }
1763 models++;
1764 }
1765 __alc_pick_fixup(codec, fix, codec->modelname, pre_init);
1766 } else {
1767 alc_pick_fixup(codec, quirk, fix, pre_init);
1768 }
1769}
1770
Kailang Yang274693f2009-12-03 10:07:50 +01001771static int alc_read_coef_idx(struct hda_codec *codec,
1772 unsigned int coef_idx)
1773{
1774 unsigned int val;
1775 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1776 coef_idx);
1777 val = snd_hda_codec_read(codec, 0x20, 0,
1778 AC_VERB_GET_PROC_COEF, 0);
1779 return val;
1780}
1781
Kailang Yang977ddd62010-09-15 10:02:29 +02001782static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1783 unsigned int coef_val)
1784{
1785 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1786 coef_idx);
1787 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1788 coef_val);
1789}
1790
Takashi Iwai757899a2010-07-30 10:48:14 +02001791/* set right pin controls for digital I/O */
1792static void alc_auto_init_digital(struct hda_codec *codec)
1793{
1794 struct alc_spec *spec = codec->spec;
1795 int i;
1796 hda_nid_t pin;
1797
1798 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1799 pin = spec->autocfg.dig_out_pins[i];
1800 if (pin) {
1801 snd_hda_codec_write(codec, pin, 0,
1802 AC_VERB_SET_PIN_WIDGET_CONTROL,
1803 PIN_OUT);
1804 }
1805 }
1806 pin = spec->autocfg.dig_in_pin;
1807 if (pin)
1808 snd_hda_codec_write(codec, pin, 0,
1809 AC_VERB_SET_PIN_WIDGET_CONTROL,
1810 PIN_IN);
1811}
1812
1813/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1814static void alc_auto_parse_digital(struct hda_codec *codec)
1815{
1816 struct alc_spec *spec = codec->spec;
1817 int i, err;
1818 hda_nid_t dig_nid;
1819
1820 /* support multiple SPDIFs; the secondary is set up as a slave */
1821 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1822 err = snd_hda_get_connections(codec,
1823 spec->autocfg.dig_out_pins[i],
1824 &dig_nid, 1);
1825 if (err < 0)
1826 continue;
1827 if (!i) {
1828 spec->multiout.dig_out_nid = dig_nid;
1829 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1830 } else {
1831 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1832 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1833 break;
1834 spec->slave_dig_outs[i - 1] = dig_nid;
1835 }
1836 }
1837
1838 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001839 dig_nid = codec->start_nid;
1840 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1841 unsigned int wcaps = get_wcaps(codec, dig_nid);
1842 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1843 continue;
1844 if (!(wcaps & AC_WCAP_DIGITAL))
1845 continue;
1846 if (!(wcaps & AC_WCAP_CONN_LIST))
1847 continue;
1848 err = get_connection_index(codec, dig_nid,
1849 spec->autocfg.dig_in_pin);
1850 if (err >= 0) {
1851 spec->dig_in_nid = dig_nid;
1852 break;
1853 }
1854 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001855 }
1856}
1857
Takashi Iwaif95474e2007-07-10 00:47:43 +02001858/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001859 * ALC888
1860 */
1861
1862/*
1863 * 2ch mode
1864 */
1865static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1866/* Mic-in jack as mic in */
1867 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1868 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1869/* Line-in jack as Line in */
1870 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1871 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1872/* Line-Out as Front */
1873 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1874 { } /* end */
1875};
1876
1877/*
1878 * 4ch mode
1879 */
1880static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1881/* Mic-in jack as mic in */
1882 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1883 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1884/* Line-in jack as Surround */
1885 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1886 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1887/* Line-Out as Front */
1888 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1889 { } /* end */
1890};
1891
1892/*
1893 * 6ch mode
1894 */
1895static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1896/* Mic-in jack as CLFE */
1897 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1898 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1899/* Line-in jack as Surround */
1900 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1901 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1902/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1903 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1904 { } /* end */
1905};
1906
1907/*
1908 * 8ch mode
1909 */
1910static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1911/* Mic-in jack as CLFE */
1912 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1913 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1914/* Line-in jack as Surround */
1915 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1916 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1917/* Line-Out as Side */
1918 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1919 { } /* end */
1920};
1921
1922static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1923 { 2, alc888_4ST_ch2_intel_init },
1924 { 4, alc888_4ST_ch4_intel_init },
1925 { 6, alc888_4ST_ch6_intel_init },
1926 { 8, alc888_4ST_ch8_intel_init },
1927};
1928
1929/*
1930 * ALC888 Fujitsu Siemens Amillo xa3530
1931 */
1932
1933static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1934/* Front Mic: set to PIN_IN (empty by default) */
1935 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1936/* Connect Internal HP to Front */
1937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1939 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1940/* Connect Bass HP to Front */
1941 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1943 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1944/* Connect Line-Out side jack (SPDIF) to Side */
1945 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1946 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1947 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1948/* Connect Mic jack to CLFE */
1949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1950 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1951 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1952/* Connect Line-in jack to Surround */
1953 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1956/* Connect HP out jack to Front */
1957 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1959 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1960/* Enable unsolicited event for HP jack and Line-out jack */
1961 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1962 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1963 {}
1964};
1965
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001966static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001967{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001968 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001969}
1970
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001971static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1972 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001973{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001974 if (codec->vendor_id == 0x10ec0880)
1975 res >>= 28;
1976 else
1977 res >>= 26;
1978 if (res == ALC880_HP_EVENT)
1979 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001980}
1981
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001982static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001983{
1984 struct alc_spec *spec = codec->spec;
1985
1986 spec->autocfg.hp_pins[0] = 0x15;
1987 spec->autocfg.speaker_pins[0] = 0x14;
1988 spec->autocfg.speaker_pins[1] = 0x16;
1989 spec->autocfg.speaker_pins[2] = 0x17;
1990 spec->autocfg.speaker_pins[3] = 0x19;
1991 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001992}
1993
1994static void alc889_intel_init_hook(struct hda_codec *codec)
1995{
1996 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001997 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001998}
1999
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002000static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002001{
2002 struct alc_spec *spec = codec->spec;
2003
2004 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
2005 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
2006 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
2007 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002008}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002009
2010/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002011 * ALC888 Acer Aspire 4930G model
2012 */
2013
2014static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
2015/* Front Mic: set to PIN_IN (empty by default) */
2016 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2017/* Unselect Front Mic by default in input mixer 3 */
2018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002019/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002020 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2021/* Connect Internal HP to front */
2022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2023 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2024 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2025/* Connect HP out to front */
2026 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2028 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2029 { }
2030};
2031
Hector Martin3b315d72009-06-02 10:54:19 +02002032/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002033 * ALC888 Acer Aspire 6530G model
2034 */
2035
2036static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002037/* Route to built-in subwoofer as well as speakers */
2038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2040 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2041 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002042/* Bias voltage on for external mic port */
2043 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002044/* Front Mic: set to PIN_IN (empty by default) */
2045 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2046/* Unselect Front Mic by default in input mixer 3 */
2047 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002048/* Enable unsolicited event for HP jack */
2049 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2050/* Enable speaker output */
2051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002053 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002054/* Enable headphone output */
2055 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2057 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002058 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002059 { }
2060};
2061
2062/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002063 *ALC888 Acer Aspire 7730G model
2064 */
2065
2066static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2067/* Bias voltage on for external mic port */
2068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2069/* Front Mic: set to PIN_IN (empty by default) */
2070 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2071/* Unselect Front Mic by default in input mixer 3 */
2072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2073/* Enable unsolicited event for HP jack */
2074 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2075/* Enable speaker output */
2076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2077 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2079/* Enable headphone output */
2080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2083 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2084/*Enable internal subwoofer */
2085 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2086 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2087 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2088 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2089 { }
2090};
2091
2092/*
Hector Martin018df412009-06-04 00:13:40 +02002093 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002094 */
2095
Hector Martin018df412009-06-04 00:13:40 +02002096static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002097/* Front Mic: set to PIN_IN (empty by default) */
2098 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2099/* Unselect Front Mic by default in input mixer 3 */
2100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2101/* Enable unsolicited event for HP jack */
2102 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2103/* Connect Internal Front to Front */
2104 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2105 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2106 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2107/* Connect Internal Rear to Rear */
2108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2110 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2111/* Connect Internal CLFE to CLFE */
2112 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2113 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2114 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2115/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002116 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002117 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2119/* Enable all DACs */
2120/* DAC DISABLE/MUTE 1? */
2121/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2122 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2123 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2124/* DAC DISABLE/MUTE 2? */
2125/* some bit here disables the other DACs. Init=0x4900 */
2126 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2127 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002128/* DMIC fix
2129 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2130 * which makes the stereo useless. However, either the mic or the ALC889
2131 * makes the signal become a difference/sum signal instead of standard
2132 * stereo, which is annoying. So instead we flip this bit which makes the
2133 * codec replicate the sum signal to both channels, turning it into a
2134 * normal mono mic.
2135 */
2136/* DMIC_CONTROL? Init value = 0x0001 */
2137 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2138 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002139 { }
2140};
2141
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002142static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002143 /* Front mic only available on one ADC */
2144 {
2145 .num_items = 4,
2146 .items = {
2147 { "Mic", 0x0 },
2148 { "Line", 0x2 },
2149 { "CD", 0x4 },
2150 { "Front Mic", 0xb },
2151 },
2152 },
2153 {
2154 .num_items = 3,
2155 .items = {
2156 { "Mic", 0x0 },
2157 { "Line", 0x2 },
2158 { "CD", 0x4 },
2159 },
2160 }
2161};
2162
Tony Vroond2fd4b02009-06-21 00:40:10 +01002163static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2164 /* Interal mic only available on one ADC */
2165 {
Tony Vroon684a8842009-06-26 09:27:50 +01002166 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002167 .items = {
2168 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002169 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002170 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002171 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002172 { "Int Mic", 0xb },
2173 },
2174 },
2175 {
Tony Vroon684a8842009-06-26 09:27:50 +01002176 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002177 .items = {
2178 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002179 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002180 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002181 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002182 },
2183 }
2184};
2185
Hector Martin018df412009-06-04 00:13:40 +02002186static struct hda_input_mux alc889_capture_sources[3] = {
2187 /* Digital mic only available on first "ADC" */
2188 {
2189 .num_items = 5,
2190 .items = {
2191 { "Mic", 0x0 },
2192 { "Line", 0x2 },
2193 { "CD", 0x4 },
2194 { "Front Mic", 0xb },
2195 { "Input Mix", 0xa },
2196 },
2197 },
2198 {
2199 .num_items = 4,
2200 .items = {
2201 { "Mic", 0x0 },
2202 { "Line", 0x2 },
2203 { "CD", 0x4 },
2204 { "Input Mix", 0xa },
2205 },
2206 },
2207 {
2208 .num_items = 4,
2209 .items = {
2210 { "Mic", 0x0 },
2211 { "Line", 0x2 },
2212 { "CD", 0x4 },
2213 { "Input Mix", 0xa },
2214 },
2215 }
2216};
2217
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002218static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2220 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2221 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2222 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2223 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2224 HDA_OUTPUT),
2225 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2226 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2227 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2228 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2229 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2230 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2231 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2232 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2233 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2235 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2236 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002237 { } /* end */
2238};
2239
Hector Martin556eea92009-12-20 22:51:23 +01002240static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2241 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2242 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2243 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2244 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2245 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2246 HDA_OUTPUT),
2247 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2248 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2249 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2250 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2251 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2255 { } /* end */
2256};
2257
2258
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002259static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002260{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002261 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002262
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002263 spec->autocfg.hp_pins[0] = 0x15;
2264 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002265 spec->autocfg.speaker_pins[1] = 0x16;
2266 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002267}
2268
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002269static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002270{
2271 struct alc_spec *spec = codec->spec;
2272
2273 spec->autocfg.hp_pins[0] = 0x15;
2274 spec->autocfg.speaker_pins[0] = 0x14;
2275 spec->autocfg.speaker_pins[1] = 0x16;
2276 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002277}
2278
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002279static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2280{
2281 struct alc_spec *spec = codec->spec;
2282
2283 spec->autocfg.hp_pins[0] = 0x15;
2284 spec->autocfg.speaker_pins[0] = 0x14;
2285 spec->autocfg.speaker_pins[1] = 0x16;
2286 spec->autocfg.speaker_pins[2] = 0x17;
2287}
2288
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002289static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002290{
2291 struct alc_spec *spec = codec->spec;
2292
2293 spec->autocfg.hp_pins[0] = 0x15;
2294 spec->autocfg.speaker_pins[0] = 0x14;
2295 spec->autocfg.speaker_pins[1] = 0x16;
2296 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002297}
2298
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002299/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002300 * ALC880 3-stack model
2301 *
2302 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002303 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2304 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 */
2306
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002307static hda_nid_t alc880_dac_nids[4] = {
2308 /* front, rear, clfe, rear_surr */
2309 0x02, 0x05, 0x04, 0x03
2310};
2311
2312static hda_nid_t alc880_adc_nids[3] = {
2313 /* ADC0-2 */
2314 0x07, 0x08, 0x09,
2315};
2316
2317/* The datasheet says the node 0x07 is connected from inputs,
2318 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002319 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002321static hda_nid_t alc880_adc_nids_alt[2] = {
2322 /* ADC1-2 */
2323 0x08, 0x09,
2324};
2325
2326#define ALC880_DIGOUT_NID 0x06
2327#define ALC880_DIGIN_NID 0x0a
2328
2329static struct hda_input_mux alc880_capture_source = {
2330 .num_items = 4,
2331 .items = {
2332 { "Mic", 0x0 },
2333 { "Front Mic", 0x3 },
2334 { "Line", 0x2 },
2335 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002337};
2338
2339/* channel source setting (2/6 channel selection for 3-stack) */
2340/* 2ch mode */
2341static struct hda_verb alc880_threestack_ch2_init[] = {
2342 /* set line-in to input, mute it */
2343 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2344 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2345 /* set mic-in to input vref 80%, mute it */
2346 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2347 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002348 { } /* end */
2349};
2350
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002351/* 6ch mode */
2352static struct hda_verb alc880_threestack_ch6_init[] = {
2353 /* set line-in to output, unmute it */
2354 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2355 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2356 /* set mic-in to output, unmute it */
2357 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2358 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2359 { } /* end */
2360};
2361
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002362static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002363 { 2, alc880_threestack_ch2_init },
2364 { 6, alc880_threestack_ch6_init },
2365};
2366
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002367static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002368 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002369 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002370 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002371 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002372 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2373 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002374 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2375 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2377 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2378 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2379 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2382 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2383 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002385 {
2386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2387 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002388 .info = alc_ch_mode_info,
2389 .get = alc_ch_mode_get,
2390 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002391 },
2392 { } /* end */
2393};
2394
2395/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002396static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2397 struct snd_ctl_elem_info *uinfo)
2398{
2399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2400 struct alc_spec *spec = codec->spec;
2401 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002402
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002403 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002404 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2405 HDA_INPUT);
2406 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002407 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002408 return err;
2409}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002411static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2412 unsigned int size, unsigned int __user *tlv)
2413{
2414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2415 struct alc_spec *spec = codec->spec;
2416 int err;
2417
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002418 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002419 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2420 HDA_INPUT);
2421 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002422 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002423 return err;
2424}
2425
2426typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2427 struct snd_ctl_elem_value *ucontrol);
2428
2429static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2430 struct snd_ctl_elem_value *ucontrol,
2431 getput_call_t func)
2432{
2433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2434 struct alc_spec *spec = codec->spec;
2435 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2436 int err;
2437
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002438 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002439 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2440 3, 0, HDA_INPUT);
2441 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002442 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002443 return err;
2444}
2445
2446static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2447 struct snd_ctl_elem_value *ucontrol)
2448{
2449 return alc_cap_getput_caller(kcontrol, ucontrol,
2450 snd_hda_mixer_amp_volume_get);
2451}
2452
2453static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2454 struct snd_ctl_elem_value *ucontrol)
2455{
2456 return alc_cap_getput_caller(kcontrol, ucontrol,
2457 snd_hda_mixer_amp_volume_put);
2458}
2459
2460/* capture mixer elements */
2461#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2462
2463static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2464 struct snd_ctl_elem_value *ucontrol)
2465{
2466 return alc_cap_getput_caller(kcontrol, ucontrol,
2467 snd_hda_mixer_amp_switch_get);
2468}
2469
2470static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2471 struct snd_ctl_elem_value *ucontrol)
2472{
2473 return alc_cap_getput_caller(kcontrol, ucontrol,
2474 snd_hda_mixer_amp_switch_put);
2475}
2476
Takashi Iwaia23b6882009-03-23 15:21:36 +01002477#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002478 { \
2479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2480 .name = "Capture Switch", \
2481 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2482 .count = num, \
2483 .info = alc_cap_sw_info, \
2484 .get = alc_cap_sw_get, \
2485 .put = alc_cap_sw_put, \
2486 }, \
2487 { \
2488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2489 .name = "Capture Volume", \
2490 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2491 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2492 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2493 .count = num, \
2494 .info = alc_cap_vol_info, \
2495 .get = alc_cap_vol_get, \
2496 .put = alc_cap_vol_put, \
2497 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002498 }
2499
2500#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002501 { \
2502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2503 /* .name = "Capture Source", */ \
2504 .name = "Input Source", \
2505 .count = num, \
2506 .info = alc_mux_enum_info, \
2507 .get = alc_mux_enum_get, \
2508 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002509 }
2510
2511#define DEFINE_CAPMIX(num) \
2512static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2513 _DEFINE_CAPMIX(num), \
2514 _DEFINE_CAPSRC(num), \
2515 { } /* end */ \
2516}
2517
2518#define DEFINE_CAPMIX_NOSRC(num) \
2519static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2520 _DEFINE_CAPMIX(num), \
2521 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002522}
2523
2524/* up to three ADCs */
2525DEFINE_CAPMIX(1);
2526DEFINE_CAPMIX(2);
2527DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002528DEFINE_CAPMIX_NOSRC(1);
2529DEFINE_CAPMIX_NOSRC(2);
2530DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531
2532/*
2533 * ALC880 5-stack model
2534 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002535 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2536 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002537 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2538 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2539 */
2540
2541/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002542static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002543 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002544 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545 { } /* end */
2546};
2547
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002548/* channel source setting (6/8 channel selection for 5-stack) */
2549/* 6ch mode */
2550static struct hda_verb alc880_fivestack_ch6_init[] = {
2551 /* set line-in to input, mute it */
2552 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2553 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002554 { } /* end */
2555};
2556
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002557/* 8ch mode */
2558static struct hda_verb alc880_fivestack_ch8_init[] = {
2559 /* set line-in to output, unmute it */
2560 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2561 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2562 { } /* end */
2563};
2564
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002565static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002566 { 6, alc880_fivestack_ch6_init },
2567 { 8, alc880_fivestack_ch8_init },
2568};
2569
2570
2571/*
2572 * ALC880 6-stack model
2573 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002574 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2575 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002576 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2577 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2578 */
2579
2580static hda_nid_t alc880_6st_dac_nids[4] = {
2581 /* front, rear, clfe, rear_surr */
2582 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002583};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002584
2585static struct hda_input_mux alc880_6stack_capture_source = {
2586 .num_items = 4,
2587 .items = {
2588 { "Mic", 0x0 },
2589 { "Front Mic", 0x1 },
2590 { "Line", 0x2 },
2591 { "CD", 0x4 },
2592 },
2593};
2594
2595/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002596static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002597 { 8, NULL },
2598};
2599
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002600static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002601 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002602 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002603 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002604 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002605 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2606 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002607 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2608 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002609 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002610 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002611 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2612 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2613 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2614 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2617 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2618 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002619 {
2620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2621 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002622 .info = alc_ch_mode_info,
2623 .get = alc_ch_mode_get,
2624 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002625 },
2626 { } /* end */
2627};
2628
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002629
2630/*
2631 * ALC880 W810 model
2632 *
2633 * W810 has rear IO for:
2634 * Front (DAC 02)
2635 * Surround (DAC 03)
2636 * Center/LFE (DAC 04)
2637 * Digital out (06)
2638 *
2639 * The system also has a pair of internal speakers, and a headphone jack.
2640 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002641 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002642 * There is a variable resistor to control the speaker or headphone
2643 * volume. This is a hardware-only device without a software API.
2644 *
2645 * Plugging headphones in will disable the internal speakers. This is
2646 * implemented in hardware, not via the driver using jack sense. In
2647 * a similar fashion, plugging into the rear socket marked "front" will
2648 * disable both the speakers and headphones.
2649 *
2650 * For input, there's a microphone jack, and an "audio in" jack.
2651 * These may not do anything useful with this driver yet, because I
2652 * haven't setup any initialization verbs for these yet...
2653 */
2654
2655static hda_nid_t alc880_w810_dac_nids[3] = {
2656 /* front, rear/surround, clfe */
2657 0x02, 0x03, 0x04
2658};
2659
2660/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002661static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 { 6, NULL }
2663};
2664
2665/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002666static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002667 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002668 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002669 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002670 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2672 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002673 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2674 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002675 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2676 { } /* end */
2677};
2678
2679
2680/*
2681 * Z710V model
2682 *
2683 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002684 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2685 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002686 */
2687
2688static hda_nid_t alc880_z71v_dac_nids[1] = {
2689 0x02
2690};
2691#define ALC880_Z71V_HP_DAC 0x03
2692
2693/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002694static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002695 { 2, NULL }
2696};
2697
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002698static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002699 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002700 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002701 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002702 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002703 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2704 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2707 { } /* end */
2708};
2709
2710
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711/*
2712 * ALC880 F1734 model
2713 *
2714 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2715 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2716 */
2717
2718static hda_nid_t alc880_f1734_dac_nids[1] = {
2719 0x03
2720};
2721#define ALC880_F1734_HP_DAC 0x02
2722
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002723static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002724 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002725 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002726 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2727 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002728 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2729 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002732 { } /* end */
2733};
2734
Takashi Iwai937b4162008-02-11 14:52:36 +01002735static struct hda_input_mux alc880_f1734_capture_source = {
2736 .num_items = 2,
2737 .items = {
2738 { "Mic", 0x1 },
2739 { "CD", 0x4 },
2740 },
2741};
2742
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002743
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002744/*
2745 * ALC880 ASUS model
2746 *
2747 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2748 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2749 * Mic = 0x18, Line = 0x1a
2750 */
2751
2752#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2753#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2754
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002755static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002756 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002757 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002758 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002759 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002760 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002764 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2765 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2766 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2767 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2769 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002770 {
2771 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2772 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002773 .info = alc_ch_mode_info,
2774 .get = alc_ch_mode_get,
2775 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002776 },
2777 { } /* end */
2778};
2779
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002780/*
2781 * ALC880 ASUS W1V model
2782 *
2783 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2784 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2785 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2786 */
2787
2788/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002789static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002790 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2791 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002792 { } /* end */
2793};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002794
Kailang Yangdf694da2005-12-05 19:42:22 +01002795/* TCL S700 */
2796static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2797 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2798 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2799 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2800 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2801 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2804 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2805 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002806 { } /* end */
2807};
2808
Kailang Yangccc656c2006-10-17 12:32:26 +02002809/* Uniwill */
2810static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002811 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2812 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2813 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2814 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002815 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2816 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2817 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2818 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2821 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2822 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2825 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2826 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002827 {
2828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2829 .name = "Channel Mode",
2830 .info = alc_ch_mode_info,
2831 .get = alc_ch_mode_get,
2832 .put = alc_ch_mode_put,
2833 },
2834 { } /* end */
2835};
2836
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002837static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2839 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2840 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2841 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2844 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2845 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2846 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2847 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2848 { } /* end */
2849};
2850
Kailang Yangccc656c2006-10-17 12:32:26 +02002851static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002852 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2853 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2854 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2855 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2858 { } /* end */
2859};
2860
Linus Torvalds1da177e2005-04-16 15:20:36 -07002861/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002862 * virtual master controls
2863 */
2864
2865/*
2866 * slave controls for virtual master
2867 */
2868static const char *alc_slave_vols[] = {
2869 "Front Playback Volume",
2870 "Surround Playback Volume",
2871 "Center Playback Volume",
2872 "LFE Playback Volume",
2873 "Side Playback Volume",
2874 "Headphone Playback Volume",
2875 "Speaker Playback Volume",
2876 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002877 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002878 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002879 NULL,
2880};
2881
2882static const char *alc_slave_sws[] = {
2883 "Front Playback Switch",
2884 "Surround Playback Switch",
2885 "Center Playback Switch",
2886 "LFE Playback Switch",
2887 "Side Playback Switch",
2888 "Headphone Playback Switch",
2889 "Speaker Playback Switch",
2890 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002891 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002892 "Line-Out Playback Switch",
2893 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002894 NULL,
2895};
2896
2897/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002899 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002900
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002901#define NID_MAPPING (-1)
2902
2903#define SUBDEV_SPEAKER_ (0 << 6)
2904#define SUBDEV_HP_ (1 << 6)
2905#define SUBDEV_LINE_ (2 << 6)
2906#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2907#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2908#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2909
Takashi Iwai603c4012008-07-30 15:01:44 +02002910static void alc_free_kctls(struct hda_codec *codec);
2911
Takashi Iwai67d634c2009-11-16 15:35:59 +01002912#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002913/* additional beep mixers; the actual parameters are overwritten at build */
2914static struct snd_kcontrol_new alc_beep_mixer[] = {
2915 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002916 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002917 { } /* end */
2918};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002919#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002920
Linus Torvalds1da177e2005-04-16 15:20:36 -07002921static int alc_build_controls(struct hda_codec *codec)
2922{
2923 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002924 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002925 struct snd_kcontrol_new *knew;
2926 int i, j, err;
2927 unsigned int u;
2928 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002929
2930 for (i = 0; i < spec->num_mixers; i++) {
2931 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2932 if (err < 0)
2933 return err;
2934 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002935 if (spec->cap_mixer) {
2936 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2937 if (err < 0)
2938 return err;
2939 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002940 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002941 err = snd_hda_create_spdif_out_ctls(codec,
2942 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943 if (err < 0)
2944 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002945 if (!spec->no_analog) {
2946 err = snd_hda_create_spdif_share_sw(codec,
2947 &spec->multiout);
2948 if (err < 0)
2949 return err;
2950 spec->multiout.share_spdif = 1;
2951 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952 }
2953 if (spec->dig_in_nid) {
2954 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2955 if (err < 0)
2956 return err;
2957 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002958
Takashi Iwai67d634c2009-11-16 15:35:59 +01002959#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002960 /* create beep controls if needed */
2961 if (spec->beep_amp) {
2962 struct snd_kcontrol_new *knew;
2963 for (knew = alc_beep_mixer; knew->name; knew++) {
2964 struct snd_kcontrol *kctl;
2965 kctl = snd_ctl_new1(knew, codec);
2966 if (!kctl)
2967 return -ENOMEM;
2968 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002969 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002970 if (err < 0)
2971 return err;
2972 }
2973 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002974#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002975
Takashi Iwai2134ea42008-01-10 16:53:55 +01002976 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002977 if (!spec->no_analog &&
2978 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002979 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002980 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002981 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002982 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002983 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002984 if (err < 0)
2985 return err;
2986 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002987 if (!spec->no_analog &&
2988 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002989 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2990 NULL, alc_slave_sws);
2991 if (err < 0)
2992 return err;
2993 }
2994
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002995 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002996 if (spec->capsrc_nids || spec->adc_nids) {
2997 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2998 if (!kctl)
2999 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3000 for (i = 0; kctl && i < kctl->count; i++) {
3001 hda_nid_t *nids = spec->capsrc_nids;
3002 if (!nids)
3003 nids = spec->adc_nids;
3004 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3005 if (err < 0)
3006 return err;
3007 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003008 }
3009 if (spec->cap_mixer) {
3010 const char *kname = kctl ? kctl->id.name : NULL;
3011 for (knew = spec->cap_mixer; knew->name; knew++) {
3012 if (kname && strcmp(knew->name, kname) == 0)
3013 continue;
3014 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3015 for (i = 0; kctl && i < kctl->count; i++) {
3016 err = snd_hda_add_nid(codec, kctl, i,
3017 spec->adc_nids[i]);
3018 if (err < 0)
3019 return err;
3020 }
3021 }
3022 }
3023
3024 /* other nid->control mapping */
3025 for (i = 0; i < spec->num_mixers; i++) {
3026 for (knew = spec->mixers[i]; knew->name; knew++) {
3027 if (knew->iface != NID_MAPPING)
3028 continue;
3029 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3030 if (kctl == NULL)
3031 continue;
3032 u = knew->subdevice;
3033 for (j = 0; j < 4; j++, u >>= 8) {
3034 nid = u & 0x3f;
3035 if (nid == 0)
3036 continue;
3037 switch (u & 0xc0) {
3038 case SUBDEV_SPEAKER_:
3039 nid = spec->autocfg.speaker_pins[nid];
3040 break;
3041 case SUBDEV_LINE_:
3042 nid = spec->autocfg.line_out_pins[nid];
3043 break;
3044 case SUBDEV_HP_:
3045 nid = spec->autocfg.hp_pins[nid];
3046 break;
3047 default:
3048 continue;
3049 }
3050 err = snd_hda_add_nid(codec, kctl, 0, nid);
3051 if (err < 0)
3052 return err;
3053 }
3054 u = knew->private_value;
3055 for (j = 0; j < 4; j++, u >>= 8) {
3056 nid = u & 0xff;
3057 if (nid == 0)
3058 continue;
3059 err = snd_hda_add_nid(codec, kctl, 0, nid);
3060 if (err < 0)
3061 return err;
3062 }
3063 }
3064 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003065
3066 alc_free_kctls(codec); /* no longer needed */
3067
Linus Torvalds1da177e2005-04-16 15:20:36 -07003068 return 0;
3069}
3070
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003071
Linus Torvalds1da177e2005-04-16 15:20:36 -07003072/*
3073 * initialize the codec volumes, etc
3074 */
3075
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076/*
3077 * generic initialization of ADC, input mixers and output mixers
3078 */
3079static struct hda_verb alc880_volume_init_verbs[] = {
3080 /*
3081 * Unmute ADC0-2 and set the default input to mic-in
3082 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003083 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003085 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003087 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003089
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003090 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3091 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003092 * Note: PASD motherboards uses the Line In 2 as the input for front
3093 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003094 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003095 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003103
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104 /*
3105 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003106 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 /* set vol=0 to output mixers */
3108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3111 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3112 /* set up input amps for analog loopback */
3113 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003120 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003122
3123 { }
3124};
3125
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126/*
3127 * 3-stack pin configuration:
3128 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3129 */
3130static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3131 /*
3132 * preset connection lists of input pins
3133 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3134 */
3135 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3136 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3137 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3138
3139 /*
3140 * Set pin mode and muting
3141 */
3142 /* set front pin widgets 0x14 for output */
3143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3144 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3145 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3146 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3147 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3148 /* Mic2 (as headphone out) for HP output */
3149 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3150 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3151 /* Line In pin widget for input */
3152 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3153 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3154 /* Line2 (as front mic) pin widget for input and vref at 80% */
3155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3156 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3157 /* CD pin widget for input */
3158 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3159
3160 { }
3161};
3162
3163/*
3164 * 5-stack pin configuration:
3165 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3166 * line-in/side = 0x1a, f-mic = 0x1b
3167 */
3168static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3169 /*
3170 * preset connection lists of input pins
3171 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3172 */
3173 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3174 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3175
3176 /*
3177 * Set pin mode and muting
3178 */
3179 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3182 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3183 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003184 /* unmute pins for output (no gain on this amp) */
3185 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189
Linus Torvalds1da177e2005-04-16 15:20:36 -07003190 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003191 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003192 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3193 /* Mic2 (as headphone out) for HP output */
3194 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003195 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003196 /* Line In pin widget for input */
3197 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3198 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3199 /* Line2 (as front mic) pin widget for input and vref at 80% */
3200 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3201 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3202 /* CD pin widget for input */
3203 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003204
3205 { }
3206};
3207
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003208/*
3209 * W810 pin configuration:
3210 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3211 */
3212static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003213 /* hphone/speaker input selector: front DAC */
3214 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3215
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003216 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3217 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3220 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3221 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3222
3223 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003224 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003225
Linus Torvalds1da177e2005-04-16 15:20:36 -07003226 { }
3227};
3228
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003229/*
3230 * Z71V pin configuration:
3231 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3232 */
3233static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003238
Takashi Iwai16ded522005-06-10 19:58:24 +02003239 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003240 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003241 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003243
3244 { }
3245};
3246
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247/*
3248 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003249 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3250 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 */
3252static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3253 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3254
Takashi Iwai16ded522005-06-10 19:58:24 +02003255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003257 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003259 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003260 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003261 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3263
Takashi Iwai16ded522005-06-10 19:58:24 +02003264 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003266 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003268 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003272 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003273
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 { }
3275};
Takashi Iwai16ded522005-06-10 19:58:24 +02003276
Kailang Yangccc656c2006-10-17 12:32:26 +02003277/*
3278 * Uniwill pin configuration:
3279 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3280 * line = 0x1a
3281 */
3282static struct hda_verb alc880_uniwill_init_verbs[] = {
3283 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3284
3285 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3289 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3290 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3291 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3292 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3299
3300 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3301 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3302 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3303 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3305 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3306 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3307 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3308 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3309
3310 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3311 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3312
3313 { }
3314};
3315
3316/*
3317* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003318* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003319 */
3320static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3321 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3322
3323 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3324 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3327 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3328 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3335
3336 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3338 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3340 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3341 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3342
3343 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3344 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3345
3346 { }
3347};
3348
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003349static struct hda_verb alc880_beep_init_verbs[] = {
3350 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3351 { }
3352};
3353
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003354/* auto-toggle front mic */
3355static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3356{
3357 unsigned int present;
3358 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003359
Wu Fengguang864f92b2009-11-18 12:38:02 +08003360 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003361 bits = present ? HDA_AMP_MUTE : 0;
3362 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003363}
3364
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003365static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003366{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003367 struct alc_spec *spec = codec->spec;
3368
3369 spec->autocfg.hp_pins[0] = 0x14;
3370 spec->autocfg.speaker_pins[0] = 0x15;
3371 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003372}
3373
3374static void alc880_uniwill_init_hook(struct hda_codec *codec)
3375{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003376 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003377 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003378}
3379
3380static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3381 unsigned int res)
3382{
3383 /* Looks like the unsol event is incompatible with the standard
3384 * definition. 4bit tag is placed at 28 bit!
3385 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003386 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003387 case ALC880_MIC_EVENT:
3388 alc880_uniwill_mic_automute(codec);
3389 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003390 default:
3391 alc_automute_amp_unsol_event(codec, res);
3392 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003393 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003394}
3395
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003396static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003398 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003400 spec->autocfg.hp_pins[0] = 0x14;
3401 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003402}
3403
3404static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3405{
3406 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003407
Kailang Yangccc656c2006-10-17 12:32:26 +02003408 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003409 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3410 present &= HDA_AMP_VOLMASK;
3411 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3412 HDA_AMP_VOLMASK, present);
3413 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3414 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003415}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003416
Kailang Yangccc656c2006-10-17 12:32:26 +02003417static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3418 unsigned int res)
3419{
3420 /* Looks like the unsol event is incompatible with the standard
3421 * definition. 4bit tag is placed at 28 bit!
3422 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003423 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003424 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003425 else
3426 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003427}
3428
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003429/*
3430 * F1734 pin configuration:
3431 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3432 */
3433static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003434 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003435 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3436 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3437 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3438 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3439
3440 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3441 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3443 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3444
3445 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3446 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003447 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003448 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3449 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3450 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3451 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3452 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3453 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003454
Takashi Iwai937b4162008-02-11 14:52:36 +01003455 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3456 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3457
Takashi Iwai16ded522005-06-10 19:58:24 +02003458 { }
3459};
3460
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003461/*
3462 * ASUS pin configuration:
3463 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3464 */
3465static struct hda_verb alc880_pin_asus_init_verbs[] = {
3466 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3467 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3468 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3469 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3470
3471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3474 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3475 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3477 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3479
3480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3484 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3485 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3486 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3488 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003489
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003490 { }
3491};
3492
3493/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003494#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3495#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003496#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003497
Kailang Yangdf694da2005-12-05 19:42:22 +01003498/* Clevo m520g init */
3499static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3500 /* headphone output */
3501 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3502 /* line-out */
3503 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3505 /* Line-in */
3506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3508 /* CD */
3509 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3510 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3511 /* Mic1 (rear panel) */
3512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3514 /* Mic2 (front panel) */
3515 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3516 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3517 /* headphone */
3518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3519 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3520 /* change to EAPD mode */
3521 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3522 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3523
3524 { }
3525};
3526
3527static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003528 /* change to EAPD mode */
3529 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3530 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3531
Kailang Yangdf694da2005-12-05 19:42:22 +01003532 /* Headphone output */
3533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3534 /* Front output*/
3535 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3536 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3537
3538 /* Line In pin widget for input */
3539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3540 /* CD pin widget for input */
3541 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3542 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3544
3545 /* change to EAPD mode */
3546 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3547 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3548
3549 { }
3550};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003551
3552/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003553 * LG m1 express dual
3554 *
3555 * Pin assignment:
3556 * Rear Line-In/Out (blue): 0x14
3557 * Build-in Mic-In: 0x15
3558 * Speaker-out: 0x17
3559 * HP-Out (green): 0x1b
3560 * Mic-In/Out (red): 0x19
3561 * SPDIF-Out: 0x1e
3562 */
3563
3564/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3565static hda_nid_t alc880_lg_dac_nids[3] = {
3566 0x05, 0x02, 0x03
3567};
3568
3569/* seems analog CD is not working */
3570static struct hda_input_mux alc880_lg_capture_source = {
3571 .num_items = 3,
3572 .items = {
3573 { "Mic", 0x1 },
3574 { "Line", 0x5 },
3575 { "Internal Mic", 0x6 },
3576 },
3577};
3578
3579/* 2,4,6 channel modes */
3580static struct hda_verb alc880_lg_ch2_init[] = {
3581 /* set line-in and mic-in to input */
3582 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3583 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3584 { }
3585};
3586
3587static struct hda_verb alc880_lg_ch4_init[] = {
3588 /* set line-in to out and mic-in to input */
3589 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3590 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3591 { }
3592};
3593
3594static struct hda_verb alc880_lg_ch6_init[] = {
3595 /* set line-in and mic-in to output */
3596 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3597 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3598 { }
3599};
3600
3601static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3602 { 2, alc880_lg_ch2_init },
3603 { 4, alc880_lg_ch4_init },
3604 { 6, alc880_lg_ch6_init },
3605};
3606
3607static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003608 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3609 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003610 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3611 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3612 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3613 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3614 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3615 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3618 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3619 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3620 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3621 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3622 {
3623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3624 .name = "Channel Mode",
3625 .info = alc_ch_mode_info,
3626 .get = alc_ch_mode_get,
3627 .put = alc_ch_mode_put,
3628 },
3629 { } /* end */
3630};
3631
3632static struct hda_verb alc880_lg_init_verbs[] = {
3633 /* set capture source to mic-in */
3634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3635 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3637 /* mute all amp mixer inputs */
3638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003641 /* line-in to input */
3642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3644 /* built-in mic */
3645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3647 /* speaker-out */
3648 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3649 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3650 /* mic-in to input */
3651 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3652 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3653 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3654 /* HP-out */
3655 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3656 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3657 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3658 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003659 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003660 { }
3661};
3662
3663/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003664static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003665{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003666 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003667
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003668 spec->autocfg.hp_pins[0] = 0x1b;
3669 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003670}
3671
3672/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003673 * LG LW20
3674 *
3675 * Pin assignment:
3676 * Speaker-out: 0x14
3677 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003678 * Built-in Mic-In: 0x19
3679 * Line-In: 0x1b
3680 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003681 * SPDIF-Out: 0x1e
3682 */
3683
Takashi Iwaid6815182006-03-23 16:06:23 +01003684static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003685 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003686 .items = {
3687 { "Mic", 0x0 },
3688 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003689 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003690 },
3691};
3692
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003693#define alc880_lg_lw_modes alc880_threestack_modes
3694
Takashi Iwaid6815182006-03-23 16:06:23 +01003695static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003696 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3697 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3698 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3699 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3700 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3701 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3702 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3703 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3704 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3705 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3708 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3709 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003710 {
3711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3712 .name = "Channel Mode",
3713 .info = alc_ch_mode_info,
3714 .get = alc_ch_mode_get,
3715 .put = alc_ch_mode_put,
3716 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003717 { } /* end */
3718};
3719
3720static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003721 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3722 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3723 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3724
Takashi Iwaid6815182006-03-23 16:06:23 +01003725 /* set capture source to mic-in */
3726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3727 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3728 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003730 /* speaker-out */
3731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3732 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3733 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003734 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3735 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3736 /* mic-in to input */
3737 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3738 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3739 /* built-in mic */
3740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3742 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003743 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003744 { }
3745};
3746
3747/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003748static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003749{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003750 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003751
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003752 spec->autocfg.hp_pins[0] = 0x1b;
3753 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003754}
3755
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003756static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3757 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3758 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3761 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3762 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3763 { } /* end */
3764};
3765
3766static struct hda_input_mux alc880_medion_rim_capture_source = {
3767 .num_items = 2,
3768 .items = {
3769 { "Mic", 0x0 },
3770 { "Internal Mic", 0x1 },
3771 },
3772};
3773
3774static struct hda_verb alc880_medion_rim_init_verbs[] = {
3775 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3776
3777 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3778 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3779
3780 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3781 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3782 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3783 /* Mic2 (as headphone out) for HP output */
3784 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3785 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3786 /* Internal Speaker */
3787 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3788 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3789
3790 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3791 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3792
3793 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3794 { }
3795};
3796
3797/* toggle speaker-output according to the hp-jack state */
3798static void alc880_medion_rim_automute(struct hda_codec *codec)
3799{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003800 struct alc_spec *spec = codec->spec;
3801 alc_automute_amp(codec);
3802 /* toggle EAPD */
3803 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003804 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3805 else
3806 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3807}
3808
3809static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3810 unsigned int res)
3811{
3812 /* Looks like the unsol event is incompatible with the standard
3813 * definition. 4bit tag is placed at 28 bit!
3814 */
3815 if ((res >> 28) == ALC880_HP_EVENT)
3816 alc880_medion_rim_automute(codec);
3817}
3818
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003819static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003820{
3821 struct alc_spec *spec = codec->spec;
3822
3823 spec->autocfg.hp_pins[0] = 0x14;
3824 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003825}
3826
Takashi Iwaicb53c622007-08-10 17:21:45 +02003827#ifdef CONFIG_SND_HDA_POWER_SAVE
3828static struct hda_amp_list alc880_loopbacks[] = {
3829 { 0x0b, HDA_INPUT, 0 },
3830 { 0x0b, HDA_INPUT, 1 },
3831 { 0x0b, HDA_INPUT, 2 },
3832 { 0x0b, HDA_INPUT, 3 },
3833 { 0x0b, HDA_INPUT, 4 },
3834 { } /* end */
3835};
3836
3837static struct hda_amp_list alc880_lg_loopbacks[] = {
3838 { 0x0b, HDA_INPUT, 1 },
3839 { 0x0b, HDA_INPUT, 6 },
3840 { 0x0b, HDA_INPUT, 7 },
3841 { } /* end */
3842};
3843#endif
3844
Takashi Iwaid6815182006-03-23 16:06:23 +01003845/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003846 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003847 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003848
Linus Torvalds1da177e2005-04-16 15:20:36 -07003849static int alc_init(struct hda_codec *codec)
3850{
3851 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003852 unsigned int i;
3853
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003854 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003855 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003856
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003857 for (i = 0; i < spec->num_init_verbs; i++)
3858 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003859
3860 if (spec->init_hook)
3861 spec->init_hook(codec);
3862
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003863 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003864 return 0;
3865}
3866
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003867static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3868{
3869 struct alc_spec *spec = codec->spec;
3870
3871 if (spec->unsol_event)
3872 spec->unsol_event(codec, res);
3873}
3874
Takashi Iwaicb53c622007-08-10 17:21:45 +02003875#ifdef CONFIG_SND_HDA_POWER_SAVE
3876static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3877{
3878 struct alc_spec *spec = codec->spec;
3879 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3880}
3881#endif
3882
Linus Torvalds1da177e2005-04-16 15:20:36 -07003883/*
3884 * Analog playback callbacks
3885 */
3886static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3887 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003888 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003889{
3890 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003891 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3892 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003893}
3894
3895static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3896 struct hda_codec *codec,
3897 unsigned int stream_tag,
3898 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003899 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003900{
3901 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003902 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3903 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003904}
3905
3906static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3907 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003908 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003909{
3910 struct alc_spec *spec = codec->spec;
3911 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3912}
3913
3914/*
3915 * Digital out
3916 */
3917static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3918 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003919 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003920{
3921 struct alc_spec *spec = codec->spec;
3922 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3923}
3924
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003925static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3926 struct hda_codec *codec,
3927 unsigned int stream_tag,
3928 unsigned int format,
3929 struct snd_pcm_substream *substream)
3930{
3931 struct alc_spec *spec = codec->spec;
3932 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3933 stream_tag, format, substream);
3934}
3935
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003936static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3937 struct hda_codec *codec,
3938 struct snd_pcm_substream *substream)
3939{
3940 struct alc_spec *spec = codec->spec;
3941 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3942}
3943
Linus Torvalds1da177e2005-04-16 15:20:36 -07003944static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3945 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003946 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003947{
3948 struct alc_spec *spec = codec->spec;
3949 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3950}
3951
3952/*
3953 * Analog capture
3954 */
Takashi Iwai63300792008-01-24 15:31:36 +01003955static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003956 struct hda_codec *codec,
3957 unsigned int stream_tag,
3958 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003959 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003960{
3961 struct alc_spec *spec = codec->spec;
3962
Takashi Iwai63300792008-01-24 15:31:36 +01003963 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003964 stream_tag, 0, format);
3965 return 0;
3966}
3967
Takashi Iwai63300792008-01-24 15:31:36 +01003968static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003969 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003970 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003971{
3972 struct alc_spec *spec = codec->spec;
3973
Takashi Iwai888afa12008-03-18 09:57:50 +01003974 snd_hda_codec_cleanup_stream(codec,
3975 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003976 return 0;
3977}
3978
Takashi Iwai840b64c2010-07-13 22:49:01 +02003979/* analog capture with dynamic dual-adc changes */
3980static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3981 struct hda_codec *codec,
3982 unsigned int stream_tag,
3983 unsigned int format,
3984 struct snd_pcm_substream *substream)
3985{
3986 struct alc_spec *spec = codec->spec;
3987 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3988 spec->cur_adc_stream_tag = stream_tag;
3989 spec->cur_adc_format = format;
3990 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3991 return 0;
3992}
3993
3994static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3995 struct hda_codec *codec,
3996 struct snd_pcm_substream *substream)
3997{
3998 struct alc_spec *spec = codec->spec;
3999 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4000 spec->cur_adc = 0;
4001 return 0;
4002}
4003
4004static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4005 .substreams = 1,
4006 .channels_min = 2,
4007 .channels_max = 2,
4008 .nid = 0, /* fill later */
4009 .ops = {
4010 .prepare = dualmic_capture_pcm_prepare,
4011 .cleanup = dualmic_capture_pcm_cleanup
4012 },
4013};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004014
4015/*
4016 */
4017static struct hda_pcm_stream alc880_pcm_analog_playback = {
4018 .substreams = 1,
4019 .channels_min = 2,
4020 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004021 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004022 .ops = {
4023 .open = alc880_playback_pcm_open,
4024 .prepare = alc880_playback_pcm_prepare,
4025 .cleanup = alc880_playback_pcm_cleanup
4026 },
4027};
4028
4029static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004030 .substreams = 1,
4031 .channels_min = 2,
4032 .channels_max = 2,
4033 /* NID is set in alc_build_pcms */
4034};
4035
4036static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4037 .substreams = 1,
4038 .channels_min = 2,
4039 .channels_max = 2,
4040 /* NID is set in alc_build_pcms */
4041};
4042
4043static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4044 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004045 .channels_min = 2,
4046 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004047 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004049 .prepare = alc880_alt_capture_pcm_prepare,
4050 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004051 },
4052};
4053
4054static struct hda_pcm_stream alc880_pcm_digital_playback = {
4055 .substreams = 1,
4056 .channels_min = 2,
4057 .channels_max = 2,
4058 /* NID is set in alc_build_pcms */
4059 .ops = {
4060 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004061 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004062 .prepare = alc880_dig_playback_pcm_prepare,
4063 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004064 },
4065};
4066
4067static struct hda_pcm_stream alc880_pcm_digital_capture = {
4068 .substreams = 1,
4069 .channels_min = 2,
4070 .channels_max = 2,
4071 /* NID is set in alc_build_pcms */
4072};
4073
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004074/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004075static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004076 .substreams = 0,
4077 .channels_min = 0,
4078 .channels_max = 0,
4079};
4080
Linus Torvalds1da177e2005-04-16 15:20:36 -07004081static int alc_build_pcms(struct hda_codec *codec)
4082{
4083 struct alc_spec *spec = codec->spec;
4084 struct hda_pcm *info = spec->pcm_rec;
4085 int i;
4086
4087 codec->num_pcms = 1;
4088 codec->pcm_info = info;
4089
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004090 if (spec->no_analog)
4091 goto skip_analog;
4092
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004093 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4094 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004095 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004096
Takashi Iwai4a471b72005-12-07 13:56:29 +01004097 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004098 if (snd_BUG_ON(!spec->multiout.dac_nids))
4099 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004100 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4101 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4102 }
4103 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004104 if (snd_BUG_ON(!spec->adc_nids))
4105 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004106 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4107 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4108 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004109
Takashi Iwai4a471b72005-12-07 13:56:29 +01004110 if (spec->channel_mode) {
4111 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4112 for (i = 0; i < spec->num_channel_mode; i++) {
4113 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4114 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4115 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004116 }
4117 }
4118
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004119 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004120 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004121 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004122 snprintf(spec->stream_name_digital,
4123 sizeof(spec->stream_name_digital),
4124 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004125 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004126 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004127 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004128 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004129 if (spec->dig_out_type)
4130 info->pcm_type = spec->dig_out_type;
4131 else
4132 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004133 if (spec->multiout.dig_out_nid &&
4134 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004135 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4136 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4137 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004138 if (spec->dig_in_nid &&
4139 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004140 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4141 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4142 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004143 /* FIXME: do we need this for all Realtek codec models? */
4144 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004145 }
4146
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004147 if (spec->no_analog)
4148 return 0;
4149
Takashi Iwaie08a0072006-09-07 17:52:14 +02004150 /* If the use of more than one ADC is requested for the current
4151 * model, configure a second analog capture-only PCM.
4152 */
4153 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004154 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4155 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004156 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004157 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004158 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004159 if (spec->alt_dac_nid) {
4160 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4161 *spec->stream_analog_alt_playback;
4162 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4163 spec->alt_dac_nid;
4164 } else {
4165 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4166 alc_pcm_null_stream;
4167 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4168 }
4169 if (spec->num_adc_nids > 1) {
4170 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4171 *spec->stream_analog_alt_capture;
4172 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4173 spec->adc_nids[1];
4174 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4175 spec->num_adc_nids - 1;
4176 } else {
4177 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4178 alc_pcm_null_stream;
4179 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004180 }
4181 }
4182
Linus Torvalds1da177e2005-04-16 15:20:36 -07004183 return 0;
4184}
4185
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004186static inline void alc_shutup(struct hda_codec *codec)
4187{
4188 snd_hda_shutup_pins(codec);
4189}
4190
Takashi Iwai603c4012008-07-30 15:01:44 +02004191static void alc_free_kctls(struct hda_codec *codec)
4192{
4193 struct alc_spec *spec = codec->spec;
4194
4195 if (spec->kctls.list) {
4196 struct snd_kcontrol_new *kctl = spec->kctls.list;
4197 int i;
4198 for (i = 0; i < spec->kctls.used; i++)
4199 kfree(kctl[i].name);
4200 }
4201 snd_array_free(&spec->kctls);
4202}
4203
Linus Torvalds1da177e2005-04-16 15:20:36 -07004204static void alc_free(struct hda_codec *codec)
4205{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004206 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004207
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004208 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004209 return;
4210
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004211 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004212 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004213 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004214 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004215}
4216
Hector Martinf5de24b2009-12-20 22:51:31 +01004217#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004218static void alc_power_eapd(struct hda_codec *codec)
4219{
4220 /* We currently only handle front, HP */
4221 switch (codec->vendor_id) {
4222 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004223 set_eapd(codec, 0x0f, 0);
4224 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004225 break;
4226 case 0x10ec0262:
4227 case 0x10ec0267:
4228 case 0x10ec0268:
4229 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004230 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004231 case 0x10ec0272:
4232 case 0x10ec0660:
4233 case 0x10ec0662:
4234 case 0x10ec0663:
4235 case 0x10ec0862:
4236 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004237 set_eapd(codec, 0x14, 0);
4238 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004239 break;
4240 }
4241}
4242
Hector Martinf5de24b2009-12-20 22:51:31 +01004243static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4244{
4245 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004246 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004247 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004248 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004249 return 0;
4250}
4251#endif
4252
Takashi Iwaie044c392008-10-27 16:56:24 +01004253#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004254static int alc_resume(struct hda_codec *codec)
4255{
Takashi Iwaie044c392008-10-27 16:56:24 +01004256 codec->patch_ops.init(codec);
4257 snd_hda_codec_resume_amp(codec);
4258 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004259 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004260 return 0;
4261}
Takashi Iwaie044c392008-10-27 16:56:24 +01004262#endif
4263
Linus Torvalds1da177e2005-04-16 15:20:36 -07004264/*
4265 */
4266static struct hda_codec_ops alc_patch_ops = {
4267 .build_controls = alc_build_controls,
4268 .build_pcms = alc_build_pcms,
4269 .init = alc_init,
4270 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004271 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004272#ifdef SND_HDA_NEEDS_RESUME
4273 .resume = alc_resume,
4274#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004275#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004276 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004277 .check_power_status = alc_check_power_status,
4278#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004279 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004280};
4281
Kailang Yangc027ddc2010-03-19 11:33:06 +01004282/* replace the codec chip_name with the given string */
4283static int alc_codec_rename(struct hda_codec *codec, const char *name)
4284{
4285 kfree(codec->chip_name);
4286 codec->chip_name = kstrdup(name, GFP_KERNEL);
4287 if (!codec->chip_name) {
4288 alc_free(codec);
4289 return -ENOMEM;
4290 }
4291 return 0;
4292}
4293
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004294/*
4295 * Test configuration for debugging
4296 *
4297 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4298 * enum controls.
4299 */
4300#ifdef CONFIG_SND_DEBUG
4301static hda_nid_t alc880_test_dac_nids[4] = {
4302 0x02, 0x03, 0x04, 0x05
4303};
4304
4305static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004306 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004307 .items = {
4308 { "In-1", 0x0 },
4309 { "In-2", 0x1 },
4310 { "In-3", 0x2 },
4311 { "In-4", 0x3 },
4312 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004313 { "Front", 0x5 },
4314 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004315 },
4316};
4317
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004318static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004319 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004320 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004321 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004322 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004323};
4324
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004325static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4326 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004327{
4328 static char *texts[] = {
4329 "N/A", "Line Out", "HP Out",
4330 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4331 };
4332 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4333 uinfo->count = 1;
4334 uinfo->value.enumerated.items = 8;
4335 if (uinfo->value.enumerated.item >= 8)
4336 uinfo->value.enumerated.item = 7;
4337 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4338 return 0;
4339}
4340
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004341static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4342 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004343{
4344 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4345 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4346 unsigned int pin_ctl, item = 0;
4347
4348 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4349 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4350 if (pin_ctl & AC_PINCTL_OUT_EN) {
4351 if (pin_ctl & AC_PINCTL_HP_EN)
4352 item = 2;
4353 else
4354 item = 1;
4355 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4356 switch (pin_ctl & AC_PINCTL_VREFEN) {
4357 case AC_PINCTL_VREF_HIZ: item = 3; break;
4358 case AC_PINCTL_VREF_50: item = 4; break;
4359 case AC_PINCTL_VREF_GRD: item = 5; break;
4360 case AC_PINCTL_VREF_80: item = 6; break;
4361 case AC_PINCTL_VREF_100: item = 7; break;
4362 }
4363 }
4364 ucontrol->value.enumerated.item[0] = item;
4365 return 0;
4366}
4367
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004368static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4369 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004370{
4371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4372 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4373 static unsigned int ctls[] = {
4374 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4375 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4376 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4377 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4378 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4379 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4380 };
4381 unsigned int old_ctl, new_ctl;
4382
4383 old_ctl = snd_hda_codec_read(codec, nid, 0,
4384 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4385 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4386 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004387 int val;
4388 snd_hda_codec_write_cache(codec, nid, 0,
4389 AC_VERB_SET_PIN_WIDGET_CONTROL,
4390 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004391 val = ucontrol->value.enumerated.item[0] >= 3 ?
4392 HDA_AMP_MUTE : 0;
4393 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4394 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004395 return 1;
4396 }
4397 return 0;
4398}
4399
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004400static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4401 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004402{
4403 static char *texts[] = {
4404 "Front", "Surround", "CLFE", "Side"
4405 };
4406 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4407 uinfo->count = 1;
4408 uinfo->value.enumerated.items = 4;
4409 if (uinfo->value.enumerated.item >= 4)
4410 uinfo->value.enumerated.item = 3;
4411 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4412 return 0;
4413}
4414
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004415static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4416 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004417{
4418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4419 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4420 unsigned int sel;
4421
4422 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4423 ucontrol->value.enumerated.item[0] = sel & 3;
4424 return 0;
4425}
4426
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004427static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4428 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004429{
4430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4431 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4432 unsigned int sel;
4433
4434 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4435 if (ucontrol->value.enumerated.item[0] != sel) {
4436 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004437 snd_hda_codec_write_cache(codec, nid, 0,
4438 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004439 return 1;
4440 }
4441 return 0;
4442}
4443
4444#define PIN_CTL_TEST(xname,nid) { \
4445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4446 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004447 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004448 .info = alc_test_pin_ctl_info, \
4449 .get = alc_test_pin_ctl_get, \
4450 .put = alc_test_pin_ctl_put, \
4451 .private_value = nid \
4452 }
4453
4454#define PIN_SRC_TEST(xname,nid) { \
4455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4456 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004457 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004458 .info = alc_test_pin_src_info, \
4459 .get = alc_test_pin_src_get, \
4460 .put = alc_test_pin_src_put, \
4461 .private_value = nid \
4462 }
4463
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004464static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4466 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4467 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4468 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004469 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4470 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4471 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4472 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004473 PIN_CTL_TEST("Front Pin Mode", 0x14),
4474 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4475 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4476 PIN_CTL_TEST("Side Pin Mode", 0x17),
4477 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4478 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4479 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4480 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4481 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4482 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4483 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4484 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4485 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4486 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4487 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4488 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4489 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4490 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4491 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4492 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4493 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4494 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004495 {
4496 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4497 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004498 .info = alc_ch_mode_info,
4499 .get = alc_ch_mode_get,
4500 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004501 },
4502 { } /* end */
4503};
4504
4505static struct hda_verb alc880_test_init_verbs[] = {
4506 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004507 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4508 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4509 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4510 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4511 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4512 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4513 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004515 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4519 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004520 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4524 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004525 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4528 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4529 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004530 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004531 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004533 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4535 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004536 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4539 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4540 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004541 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004543 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004544 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004545 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004547 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004548 /* Analog input/passthru */
4549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004554 { }
4555};
4556#endif
4557
Linus Torvalds1da177e2005-04-16 15:20:36 -07004558/*
4559 */
4560
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004561static const char *alc880_models[ALC880_MODEL_LAST] = {
4562 [ALC880_3ST] = "3stack",
4563 [ALC880_TCL_S700] = "tcl",
4564 [ALC880_3ST_DIG] = "3stack-digout",
4565 [ALC880_CLEVO] = "clevo",
4566 [ALC880_5ST] = "5stack",
4567 [ALC880_5ST_DIG] = "5stack-digout",
4568 [ALC880_W810] = "w810",
4569 [ALC880_Z71V] = "z71v",
4570 [ALC880_6ST] = "6stack",
4571 [ALC880_6ST_DIG] = "6stack-digout",
4572 [ALC880_ASUS] = "asus",
4573 [ALC880_ASUS_W1V] = "asus-w1v",
4574 [ALC880_ASUS_DIG] = "asus-dig",
4575 [ALC880_ASUS_DIG2] = "asus-dig2",
4576 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004577 [ALC880_UNIWILL_P53] = "uniwill-p53",
4578 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004579 [ALC880_F1734] = "F1734",
4580 [ALC880_LG] = "lg",
4581 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004582 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004583#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004584 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004585#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004586 [ALC880_AUTO] = "auto",
4587};
4588
4589static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004590 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004591 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4592 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4593 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4594 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4595 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4596 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4597 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4598 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004599 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4600 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004601 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4602 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4603 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4604 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4605 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4606 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4607 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4608 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4609 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4610 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004611 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004612 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4613 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4614 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004615 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004616 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004617 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4618 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004619 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4620 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004621 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4622 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4623 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4624 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004625 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4626 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004627 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004628 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004629 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004630 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004631 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4632 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004633 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004634 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004635 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004636 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004637 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004638 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004639 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004640 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004641 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004642 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004643 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004644 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004645 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004646 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4647 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4648 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4649 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004650 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4651 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004652 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004653 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004654 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4655 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004656 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4657 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4658 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004659 /* default Intel */
4660 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004661 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4662 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004663 {}
4664};
4665
Takashi Iwai16ded522005-06-10 19:58:24 +02004666/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004667 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004668 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004669static struct alc_config_preset alc880_presets[] = {
4670 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004671 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004672 .init_verbs = { alc880_volume_init_verbs,
4673 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004674 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004675 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004676 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4677 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004678 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004679 .input_mux = &alc880_capture_source,
4680 },
4681 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004683 .init_verbs = { alc880_volume_init_verbs,
4684 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004685 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004686 .dac_nids = alc880_dac_nids,
4687 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004688 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4689 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004690 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004691 .input_mux = &alc880_capture_source,
4692 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004693 [ALC880_TCL_S700] = {
4694 .mixers = { alc880_tcl_s700_mixer },
4695 .init_verbs = { alc880_volume_init_verbs,
4696 alc880_pin_tcl_S700_init_verbs,
4697 alc880_gpio2_init_verbs },
4698 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4699 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004700 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4701 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004702 .hp_nid = 0x03,
4703 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4704 .channel_mode = alc880_2_jack_modes,
4705 .input_mux = &alc880_capture_source,
4706 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004707 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004708 .mixers = { alc880_three_stack_mixer,
4709 alc880_five_stack_mixer},
4710 .init_verbs = { alc880_volume_init_verbs,
4711 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004712 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4713 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004714 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4715 .channel_mode = alc880_fivestack_modes,
4716 .input_mux = &alc880_capture_source,
4717 },
4718 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004719 .mixers = { alc880_three_stack_mixer,
4720 alc880_five_stack_mixer },
4721 .init_verbs = { alc880_volume_init_verbs,
4722 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004723 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4724 .dac_nids = alc880_dac_nids,
4725 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004726 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4727 .channel_mode = alc880_fivestack_modes,
4728 .input_mux = &alc880_capture_source,
4729 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004730 [ALC880_6ST] = {
4731 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004732 .init_verbs = { alc880_volume_init_verbs,
4733 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004734 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4735 .dac_nids = alc880_6st_dac_nids,
4736 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4737 .channel_mode = alc880_sixstack_modes,
4738 .input_mux = &alc880_6stack_capture_source,
4739 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004740 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004741 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742 .init_verbs = { alc880_volume_init_verbs,
4743 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004744 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4745 .dac_nids = alc880_6st_dac_nids,
4746 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004747 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4748 .channel_mode = alc880_sixstack_modes,
4749 .input_mux = &alc880_6stack_capture_source,
4750 },
4751 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004752 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004753 .init_verbs = { alc880_volume_init_verbs,
4754 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004755 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004756 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4757 .dac_nids = alc880_w810_dac_nids,
4758 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004759 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4760 .channel_mode = alc880_w810_modes,
4761 .input_mux = &alc880_capture_source,
4762 },
4763 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004764 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004765 .init_verbs = { alc880_volume_init_verbs,
4766 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004767 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4768 .dac_nids = alc880_z71v_dac_nids,
4769 .dig_out_nid = ALC880_DIGOUT_NID,
4770 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004771 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4772 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004773 .input_mux = &alc880_capture_source,
4774 },
4775 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004776 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004777 .init_verbs = { alc880_volume_init_verbs,
4778 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004779 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4780 .dac_nids = alc880_f1734_dac_nids,
4781 .hp_nid = 0x02,
4782 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4783 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004784 .input_mux = &alc880_f1734_capture_source,
4785 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004786 .setup = alc880_uniwill_p53_setup,
4787 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004788 },
4789 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004790 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004791 .init_verbs = { alc880_volume_init_verbs,
4792 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004793 alc880_gpio1_init_verbs },
4794 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4795 .dac_nids = alc880_asus_dac_nids,
4796 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4797 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004798 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004799 .input_mux = &alc880_capture_source,
4800 },
4801 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004802 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004803 .init_verbs = { alc880_volume_init_verbs,
4804 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004805 alc880_gpio1_init_verbs },
4806 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4807 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004808 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004809 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4810 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004811 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004812 .input_mux = &alc880_capture_source,
4813 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004814 [ALC880_ASUS_DIG2] = {
4815 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004816 .init_verbs = { alc880_volume_init_verbs,
4817 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004818 alc880_gpio2_init_verbs }, /* use GPIO2 */
4819 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4820 .dac_nids = alc880_asus_dac_nids,
4821 .dig_out_nid = ALC880_DIGOUT_NID,
4822 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4823 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004824 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004825 .input_mux = &alc880_capture_source,
4826 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004827 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004828 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004829 .init_verbs = { alc880_volume_init_verbs,
4830 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004831 alc880_gpio1_init_verbs },
4832 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4833 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004834 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4836 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004837 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004838 .input_mux = &alc880_capture_source,
4839 },
4840 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004841 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004842 .init_verbs = { alc880_volume_init_verbs,
4843 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004844 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4845 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004846 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004847 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4848 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004849 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004850 .input_mux = &alc880_capture_source,
4851 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004852 [ALC880_UNIWILL] = {
4853 .mixers = { alc880_uniwill_mixer },
4854 .init_verbs = { alc880_volume_init_verbs,
4855 alc880_uniwill_init_verbs },
4856 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4857 .dac_nids = alc880_asus_dac_nids,
4858 .dig_out_nid = ALC880_DIGOUT_NID,
4859 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4860 .channel_mode = alc880_threestack_modes,
4861 .need_dac_fix = 1,
4862 .input_mux = &alc880_capture_source,
4863 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004864 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004865 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004866 },
4867 [ALC880_UNIWILL_P53] = {
4868 .mixers = { alc880_uniwill_p53_mixer },
4869 .init_verbs = { alc880_volume_init_verbs,
4870 alc880_uniwill_p53_init_verbs },
4871 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4872 .dac_nids = alc880_asus_dac_nids,
4873 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004874 .channel_mode = alc880_threestack_modes,
4875 .input_mux = &alc880_capture_source,
4876 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004877 .setup = alc880_uniwill_p53_setup,
4878 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004879 },
4880 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004881 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004882 .init_verbs = { alc880_volume_init_verbs,
4883 alc880_uniwill_p53_init_verbs,
4884 alc880_beep_init_verbs },
4885 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4886 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004887 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004888 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4889 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004890 .input_mux = &alc880_capture_source,
4891 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004892 .setup = alc880_uniwill_p53_setup,
4893 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004894 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004895 [ALC880_CLEVO] = {
4896 .mixers = { alc880_three_stack_mixer },
4897 .init_verbs = { alc880_volume_init_verbs,
4898 alc880_pin_clevo_init_verbs },
4899 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4900 .dac_nids = alc880_dac_nids,
4901 .hp_nid = 0x03,
4902 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4903 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004904 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004905 .input_mux = &alc880_capture_source,
4906 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004907 [ALC880_LG] = {
4908 .mixers = { alc880_lg_mixer },
4909 .init_verbs = { alc880_volume_init_verbs,
4910 alc880_lg_init_verbs },
4911 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4912 .dac_nids = alc880_lg_dac_nids,
4913 .dig_out_nid = ALC880_DIGOUT_NID,
4914 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4915 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004916 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004917 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004918 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004919 .setup = alc880_lg_setup,
4920 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004921#ifdef CONFIG_SND_HDA_POWER_SAVE
4922 .loopbacks = alc880_lg_loopbacks,
4923#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004924 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004925 [ALC880_LG_LW] = {
4926 .mixers = { alc880_lg_lw_mixer },
4927 .init_verbs = { alc880_volume_init_verbs,
4928 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004929 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004930 .dac_nids = alc880_dac_nids,
4931 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004932 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4933 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004934 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004935 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004936 .setup = alc880_lg_lw_setup,
4937 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004938 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004939 [ALC880_MEDION_RIM] = {
4940 .mixers = { alc880_medion_rim_mixer },
4941 .init_verbs = { alc880_volume_init_verbs,
4942 alc880_medion_rim_init_verbs,
4943 alc_gpio2_init_verbs },
4944 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4945 .dac_nids = alc880_dac_nids,
4946 .dig_out_nid = ALC880_DIGOUT_NID,
4947 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4948 .channel_mode = alc880_2_jack_modes,
4949 .input_mux = &alc880_medion_rim_capture_source,
4950 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004951 .setup = alc880_medion_rim_setup,
4952 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004953 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004954#ifdef CONFIG_SND_DEBUG
4955 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004956 .mixers = { alc880_test_mixer },
4957 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004958 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4959 .dac_nids = alc880_test_dac_nids,
4960 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004961 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4962 .channel_mode = alc880_test_modes,
4963 .input_mux = &alc880_test_capture_source,
4964 },
4965#endif
4966};
4967
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004968/*
4969 * Automatic parse of I/O pins from the BIOS configuration
4970 */
4971
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004972enum {
4973 ALC_CTL_WIDGET_VOL,
4974 ALC_CTL_WIDGET_MUTE,
4975 ALC_CTL_BIND_MUTE,
4976};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004977static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004978 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4979 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004980 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004981};
4982
4983/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004984static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004985 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004986{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004987 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004988
Takashi Iwai603c4012008-07-30 15:01:44 +02004989 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4990 knew = snd_array_new(&spec->kctls);
4991 if (!knew)
4992 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004993 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004994 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004995 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004997 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004998 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004999 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005001 return 0;
5002}
5003
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005004static int add_control_with_pfx(struct alc_spec *spec, int type,
5005 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005006 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005007{
5008 char name[32];
5009 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005010 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005011}
5012
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005013#define add_pb_vol_ctrl(spec, type, pfx, val) \
5014 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5015#define add_pb_sw_ctrl(spec, type, pfx, val) \
5016 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5017#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5018 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5019#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5020 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005021
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005022#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5023#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5024#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5025#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005026#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5027#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5028#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5029#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5030#define ALC880_PIN_CD_NID 0x1c
5031
5032/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005033static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5034 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005035{
5036 hda_nid_t nid;
5037 int assigned[4];
5038 int i, j;
5039
5040 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005041 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005042
5043 /* check the pins hardwired to audio widget */
5044 for (i = 0; i < cfg->line_outs; i++) {
5045 nid = cfg->line_out_pins[i];
5046 if (alc880_is_fixed_pin(nid)) {
5047 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005048 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005049 assigned[idx] = 1;
5050 }
5051 }
5052 /* left pins can be connect to any audio widget */
5053 for (i = 0; i < cfg->line_outs; i++) {
5054 nid = cfg->line_out_pins[i];
5055 if (alc880_is_fixed_pin(nid))
5056 continue;
5057 /* search for an empty channel */
5058 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005059 if (!assigned[j]) {
5060 spec->multiout.dac_nids[i] =
5061 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005062 assigned[j] = 1;
5063 break;
5064 }
5065 }
5066 }
5067 spec->multiout.num_dacs = cfg->line_outs;
5068 return 0;
5069}
5070
5071/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005072static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5073 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005074{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005075 static const char *chname[4] = {
5076 "Front", "Surround", NULL /*CLFE*/, "Side"
5077 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005078 hda_nid_t nid;
5079 int i, err;
5080
5081 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005082 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005083 continue;
5084 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
5085 if (i == 2) {
5086 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005087 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5088 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005089 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5090 HDA_OUTPUT));
5091 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005092 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005093 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5094 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005095 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5096 HDA_OUTPUT));
5097 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005098 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005099 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5100 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005101 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5102 HDA_INPUT));
5103 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005104 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005105 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5106 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005107 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5108 HDA_INPUT));
5109 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110 return err;
5111 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02005112 const char *pfx;
5113 if (cfg->line_outs == 1 &&
5114 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
5115 pfx = "Speaker";
5116 else
5117 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005118 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005119 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5120 HDA_OUTPUT));
5121 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005122 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005123 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005124 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5125 HDA_INPUT));
5126 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005127 return err;
5128 }
5129 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005130 return 0;
5131}
5132
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005133/* add playback controls for speaker and HP outputs */
5134static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5135 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005136{
5137 hda_nid_t nid;
5138 int err;
5139
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005140 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005141 return 0;
5142
5143 if (alc880_is_fixed_pin(pin)) {
5144 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005145 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005146 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005147 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005148 else
5149 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005150 /* control HP volume/switch on the output mixer amp */
5151 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005152 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005153 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5154 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005155 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005156 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005157 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5158 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005159 return err;
5160 } else if (alc880_is_multi_pin(pin)) {
5161 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005162 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005163 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005164 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5165 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005166 return err;
5167 }
5168 return 0;
5169}
5170
5171/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005172static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005173 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005174 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005175{
Kailang Yangdf694da2005-12-05 19:42:22 +01005176 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005177
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005178 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005179 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5180 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005181 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005182 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005183 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5184 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005185 return err;
5186 return 0;
5187}
5188
Takashi Iwai05f5f472009-08-25 13:10:18 +02005189static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005190{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005191 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5192 return (pincap & AC_PINCAP_IN) != 0;
5193}
5194
5195/* create playback/capture controls for input pins */
5196static int alc_auto_create_input_ctls(struct hda_codec *codec,
5197 const struct auto_pin_cfg *cfg,
5198 hda_nid_t mixer,
5199 hda_nid_t cap1, hda_nid_t cap2)
5200{
5201 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005202 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005203 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005204
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005205 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005206 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005207 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005208
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005209 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005210 if (!alc_is_input_pin(codec, pin))
5211 continue;
5212
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005213 type = cfg->inputs[i].type;
5214 if (i > 0 && type == cfg->inputs[i - 1].type)
5215 type_idx++;
5216 else
5217 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005218 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005219 if (mixer) {
5220 idx = get_connection_index(codec, mixer, pin);
5221 if (idx >= 0) {
5222 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005223 label, type_idx,
5224 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005225 if (err < 0)
5226 return err;
5227 }
5228 }
5229
5230 if (!cap1)
5231 continue;
5232 idx = get_connection_index(codec, cap1, pin);
5233 if (idx < 0 && cap2)
5234 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005235 if (idx >= 0)
5236 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005237 }
5238 return 0;
5239}
5240
Takashi Iwai05f5f472009-08-25 13:10:18 +02005241static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5242 const struct auto_pin_cfg *cfg)
5243{
5244 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5245}
5246
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005247static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5248 unsigned int pin_type)
5249{
5250 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5251 pin_type);
5252 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005253 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5254 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005255}
5256
Kailang Yangdf694da2005-12-05 19:42:22 +01005257static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5258 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005259 int dac_idx)
5260{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005261 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005262 /* need the manual connection? */
5263 if (alc880_is_multi_pin(nid)) {
5264 struct alc_spec *spec = codec->spec;
5265 int idx = alc880_multi_pin_idx(nid);
5266 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5267 AC_VERB_SET_CONNECT_SEL,
5268 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5269 }
5270}
5271
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005272static int get_pin_type(int line_out_type)
5273{
5274 if (line_out_type == AUTO_PIN_HP_OUT)
5275 return PIN_HP;
5276 else
5277 return PIN_OUT;
5278}
5279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005280static void alc880_auto_init_multi_out(struct hda_codec *codec)
5281{
5282 struct alc_spec *spec = codec->spec;
5283 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005284
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005285 for (i = 0; i < spec->autocfg.line_outs; i++) {
5286 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005287 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5288 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005289 }
5290}
5291
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005292static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005293{
5294 struct alc_spec *spec = codec->spec;
5295 hda_nid_t pin;
5296
Takashi Iwai82bc9552006-03-21 11:24:42 +01005297 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005298 if (pin) /* connect to front */
5299 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005300 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005301 if (pin) /* connect to front */
5302 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5303}
5304
5305static void alc880_auto_init_analog_input(struct hda_codec *codec)
5306{
5307 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005308 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005309 int i;
5310
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005311 for (i = 0; i < cfg->num_inputs; i++) {
5312 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005313 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005314 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005315 if (nid != ALC880_PIN_CD_NID &&
5316 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005317 snd_hda_codec_write(codec, nid, 0,
5318 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005319 AMP_OUT_MUTE);
5320 }
5321 }
5322}
5323
Takashi Iwai7f311a42010-04-09 17:32:23 +02005324static void alc880_auto_init_input_src(struct hda_codec *codec)
5325{
5326 struct alc_spec *spec = codec->spec;
5327 int c;
5328
5329 for (c = 0; c < spec->num_adc_nids; c++) {
5330 unsigned int mux_idx;
5331 const struct hda_input_mux *imux;
5332 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5333 imux = &spec->input_mux[mux_idx];
5334 if (!imux->num_items && mux_idx > 0)
5335 imux = &spec->input_mux[0];
5336 if (imux)
5337 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5338 AC_VERB_SET_CONNECT_SEL,
5339 imux->items[0].index);
5340 }
5341}
5342
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005343/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005344/* return 1 if successful, 0 if the proper config is not found,
5345 * or a negative error code
5346 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005347static int alc880_parse_auto_config(struct hda_codec *codec)
5348{
5349 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005350 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005351 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005352
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005353 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5354 alc880_ignore);
5355 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005356 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005357 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005358 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005359
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005360 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5361 if (err < 0)
5362 return err;
5363 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5364 if (err < 0)
5365 return err;
5366 err = alc880_auto_create_extra_out(spec,
5367 spec->autocfg.speaker_pins[0],
5368 "Speaker");
5369 if (err < 0)
5370 return err;
5371 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5372 "Headphone");
5373 if (err < 0)
5374 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005375 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005376 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005377 return err;
5378
5379 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5380
Takashi Iwai757899a2010-07-30 10:48:14 +02005381 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005382
Takashi Iwai603c4012008-07-30 15:01:44 +02005383 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005384 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005385
Takashi Iwaid88897e2008-10-31 15:01:37 +01005386 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005387
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005388 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005389 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005390
Kailang Yang6227cdc2010-02-25 08:36:52 +01005391 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005392
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005393 return 1;
5394}
5395
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005396/* additional initialization for auto-configuration model */
5397static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005398{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005399 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005400 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005401 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005402 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005403 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005404 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005405 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005406 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005407}
5408
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005409/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5410 * one of two digital mic pins, e.g. on ALC272
5411 */
5412static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005413{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005414 struct alc_spec *spec = codec->spec;
5415 int i;
5416
5417 for (i = 0; i < spec->num_adc_nids; i++) {
5418 hda_nid_t cap = spec->capsrc_nids ?
5419 spec->capsrc_nids[i] : spec->adc_nids[i];
5420 int iidx, eidx;
5421
5422 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5423 if (iidx < 0)
5424 continue;
5425 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5426 if (eidx < 0)
5427 continue;
5428 spec->int_mic.mux_idx = iidx;
5429 spec->ext_mic.mux_idx = eidx;
5430 if (spec->capsrc_nids)
5431 spec->capsrc_nids += i;
5432 spec->adc_nids += i;
5433 spec->num_adc_nids = 1;
5434 return;
5435 }
5436 snd_printd(KERN_INFO "hda_codec: %s: "
5437 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5438 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5439 spec->auto_mic = 0; /* disable auto-mic to be sure */
5440}
5441
Takashi Iwai748cce42010-08-04 07:37:39 +02005442/* select or unmute the given capsrc route */
5443static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5444 int idx)
5445{
5446 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5447 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5448 HDA_AMP_MUTE, 0);
5449 } else {
5450 snd_hda_codec_write_cache(codec, cap, 0,
5451 AC_VERB_SET_CONNECT_SEL, idx);
5452 }
5453}
5454
Takashi Iwai840b64c2010-07-13 22:49:01 +02005455/* set the default connection to that pin */
5456static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5457{
5458 struct alc_spec *spec = codec->spec;
5459 int i;
5460
5461 for (i = 0; i < spec->num_adc_nids; i++) {
5462 hda_nid_t cap = spec->capsrc_nids ?
5463 spec->capsrc_nids[i] : spec->adc_nids[i];
5464 int idx;
5465
5466 idx = get_connection_index(codec, cap, pin);
5467 if (idx < 0)
5468 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005469 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005470 return i; /* return the found index */
5471 }
5472 return -1; /* not found */
5473}
5474
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005475/* choose the ADC/MUX containing the input pin and initialize the setup */
5476static void fixup_single_adc(struct hda_codec *codec)
5477{
5478 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005479 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005480 int i;
5481
5482 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005483 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005484 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005485 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005486 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005487 /* use only this ADC */
5488 if (spec->capsrc_nids)
5489 spec->capsrc_nids += i;
5490 spec->adc_nids += i;
5491 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005492 }
5493}
5494
Takashi Iwai840b64c2010-07-13 22:49:01 +02005495/* initialize dual adcs */
5496static void fixup_dual_adc_switch(struct hda_codec *codec)
5497{
5498 struct alc_spec *spec = codec->spec;
5499 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5500 init_capsrc_for_pin(codec, spec->int_mic.pin);
5501}
5502
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005503static void set_capture_mixer(struct hda_codec *codec)
5504{
5505 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005506 static struct snd_kcontrol_new *caps[2][3] = {
5507 { alc_capture_mixer_nosrc1,
5508 alc_capture_mixer_nosrc2,
5509 alc_capture_mixer_nosrc3 },
5510 { alc_capture_mixer1,
5511 alc_capture_mixer2,
5512 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005513 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005514 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005515 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005516 int num_adcs = spec->num_adc_nids;
5517 if (spec->dual_adc_switch)
5518 fixup_dual_adc_switch(codec);
5519 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005520 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005521 else if (spec->input_mux) {
5522 if (spec->input_mux->num_items > 1)
5523 mux = 1;
5524 else if (spec->input_mux->num_items == 1)
5525 fixup_single_adc(codec);
5526 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005527 if (spec->dual_adc_switch)
5528 num_adcs = 1;
5529 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005530 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005531}
5532
Takashi Iwai66946352010-03-29 17:21:45 +02005533/* fill adc_nids (and capsrc_nids) containing all active input pins */
5534static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5535 int num_nids)
5536{
5537 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005538 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005539 int n;
5540 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5541
5542 for (n = 0; n < num_nids; n++) {
5543 hda_nid_t adc, cap;
5544 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5545 int nconns, i, j;
5546
5547 adc = nids[n];
5548 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5549 continue;
5550 cap = adc;
5551 nconns = snd_hda_get_connections(codec, cap, conn,
5552 ARRAY_SIZE(conn));
5553 if (nconns == 1) {
5554 cap = conn[0];
5555 nconns = snd_hda_get_connections(codec, cap, conn,
5556 ARRAY_SIZE(conn));
5557 }
5558 if (nconns <= 0)
5559 continue;
5560 if (!fallback_adc) {
5561 fallback_adc = adc;
5562 fallback_cap = cap;
5563 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005564 for (i = 0; i < cfg->num_inputs; i++) {
5565 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005566 for (j = 0; j < nconns; j++) {
5567 if (conn[j] == nid)
5568 break;
5569 }
5570 if (j >= nconns)
5571 break;
5572 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005573 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005574 int num_adcs = spec->num_adc_nids;
5575 spec->private_adc_nids[num_adcs] = adc;
5576 spec->private_capsrc_nids[num_adcs] = cap;
5577 spec->num_adc_nids++;
5578 spec->adc_nids = spec->private_adc_nids;
5579 if (adc != cap)
5580 spec->capsrc_nids = spec->private_capsrc_nids;
5581 }
5582 }
5583 if (!spec->num_adc_nids) {
5584 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005585 " using fallback 0x%x\n",
5586 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005587 spec->private_adc_nids[0] = fallback_adc;
5588 spec->adc_nids = spec->private_adc_nids;
5589 if (fallback_adc != fallback_cap) {
5590 spec->private_capsrc_nids[0] = fallback_cap;
5591 spec->capsrc_nids = spec->private_adc_nids;
5592 }
5593 }
5594}
5595
Takashi Iwai67d634c2009-11-16 15:35:59 +01005596#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005597#define set_beep_amp(spec, nid, idx, dir) \
5598 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005599
5600static struct snd_pci_quirk beep_white_list[] = {
5601 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005602 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005603 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005604 {}
5605};
5606
5607static inline int has_cdefine_beep(struct hda_codec *codec)
5608{
5609 struct alc_spec *spec = codec->spec;
5610 const struct snd_pci_quirk *q;
5611 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5612 if (q)
5613 return q->value;
5614 return spec->cdefine.enable_pcbeep;
5615}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005616#else
5617#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005618#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005619#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005620
5621/*
5622 * OK, here we have finally the patch for ALC880
5623 */
5624
Linus Torvalds1da177e2005-04-16 15:20:36 -07005625static int patch_alc880(struct hda_codec *codec)
5626{
5627 struct alc_spec *spec;
5628 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005629 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005630
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005631 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005632 if (spec == NULL)
5633 return -ENOMEM;
5634
5635 codec->spec = spec;
5636
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005637 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5638 alc880_models,
5639 alc880_cfg_tbl);
5640 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005641 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5642 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005643 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005644 }
5645
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005646 if (board_config == ALC880_AUTO) {
5647 /* automatic parse from the BIOS config */
5648 err = alc880_parse_auto_config(codec);
5649 if (err < 0) {
5650 alc_free(codec);
5651 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005652 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005653 printk(KERN_INFO
5654 "hda_codec: Cannot set up configuration "
5655 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005656 board_config = ALC880_3ST;
5657 }
5658 }
5659
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005660 err = snd_hda_attach_beep_device(codec, 0x1);
5661 if (err < 0) {
5662 alc_free(codec);
5663 return err;
5664 }
5665
Kailang Yangdf694da2005-12-05 19:42:22 +01005666 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005667 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005668
Linus Torvalds1da177e2005-04-16 15:20:36 -07005669 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5670 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005671 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005672
Linus Torvalds1da177e2005-04-16 15:20:36 -07005673 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5674 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5675
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005676 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005677 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005678 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005679 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005680 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005681 if (wcap != AC_WID_AUD_IN) {
5682 spec->adc_nids = alc880_adc_nids_alt;
5683 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005684 } else {
5685 spec->adc_nids = alc880_adc_nids;
5686 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005687 }
5688 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005689 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005690 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005691
Takashi Iwai2134ea42008-01-10 16:53:55 +01005692 spec->vmaster_nid = 0x0c;
5693
Linus Torvalds1da177e2005-04-16 15:20:36 -07005694 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005695 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005696 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005697#ifdef CONFIG_SND_HDA_POWER_SAVE
5698 if (!spec->loopback.amplist)
5699 spec->loopback.amplist = alc880_loopbacks;
5700#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005701
5702 return 0;
5703}
5704
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005705
Linus Torvalds1da177e2005-04-16 15:20:36 -07005706/*
5707 * ALC260 support
5708 */
5709
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005710static hda_nid_t alc260_dac_nids[1] = {
5711 /* front */
5712 0x02,
5713};
5714
5715static hda_nid_t alc260_adc_nids[1] = {
5716 /* ADC0 */
5717 0x04,
5718};
5719
Kailang Yangdf694da2005-12-05 19:42:22 +01005720static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005721 /* ADC1 */
5722 0x05,
5723};
5724
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005725/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5726 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5727 */
5728static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005729 /* ADC0, ADC1 */
5730 0x04, 0x05
5731};
5732
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005733#define ALC260_DIGOUT_NID 0x03
5734#define ALC260_DIGIN_NID 0x06
5735
5736static struct hda_input_mux alc260_capture_source = {
5737 .num_items = 4,
5738 .items = {
5739 { "Mic", 0x0 },
5740 { "Front Mic", 0x1 },
5741 { "Line", 0x2 },
5742 { "CD", 0x4 },
5743 },
5744};
5745
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005746/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005747 * headphone jack and the internal CD lines since these are the only pins at
5748 * which audio can appear. For flexibility, also allow the option of
5749 * recording the mixer output on the second ADC (ADC0 doesn't have a
5750 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005751 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005752static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5753 {
5754 .num_items = 3,
5755 .items = {
5756 { "Mic/Line", 0x0 },
5757 { "CD", 0x4 },
5758 { "Headphone", 0x2 },
5759 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005760 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005761 {
5762 .num_items = 4,
5763 .items = {
5764 { "Mic/Line", 0x0 },
5765 { "CD", 0x4 },
5766 { "Headphone", 0x2 },
5767 { "Mixer", 0x5 },
5768 },
5769 },
5770
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005771};
5772
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005773/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5774 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005775 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005776static struct hda_input_mux alc260_acer_capture_sources[2] = {
5777 {
5778 .num_items = 4,
5779 .items = {
5780 { "Mic", 0x0 },
5781 { "Line", 0x2 },
5782 { "CD", 0x4 },
5783 { "Headphone", 0x5 },
5784 },
5785 },
5786 {
5787 .num_items = 5,
5788 .items = {
5789 { "Mic", 0x0 },
5790 { "Line", 0x2 },
5791 { "CD", 0x4 },
5792 { "Headphone", 0x6 },
5793 { "Mixer", 0x5 },
5794 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005795 },
5796};
Michael Schwingencc959482009-02-22 18:58:45 +01005797
5798/* Maxdata Favorit 100XS */
5799static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5800 {
5801 .num_items = 2,
5802 .items = {
5803 { "Line/Mic", 0x0 },
5804 { "CD", 0x4 },
5805 },
5806 },
5807 {
5808 .num_items = 3,
5809 .items = {
5810 { "Line/Mic", 0x0 },
5811 { "CD", 0x4 },
5812 { "Mixer", 0x5 },
5813 },
5814 },
5815};
5816
Linus Torvalds1da177e2005-04-16 15:20:36 -07005817/*
5818 * This is just place-holder, so there's something for alc_build_pcms to look
5819 * at when it calculates the maximum number of channels. ALC260 has no mixer
5820 * element which allows changing the channel mode, so the verb list is
5821 * never used.
5822 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005823static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005824 { 2, NULL },
5825};
5826
Kailang Yangdf694da2005-12-05 19:42:22 +01005827
5828/* Mixer combinations
5829 *
5830 * basic: base_output + input + pc_beep + capture
5831 * HP: base_output + input + capture_alt
5832 * HP_3013: hp_3013 + input + capture
5833 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005834 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005835 */
5836
5837static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005838 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005839 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005840 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5841 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5842 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5843 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5844 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005845};
Kailang Yangdf694da2005-12-05 19:42:22 +01005846
5847static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005848 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5849 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5850 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5851 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5853 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5854 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5855 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005856 { } /* end */
5857};
5858
Takashi Iwaibec15c32008-01-28 18:16:30 +01005859/* update HP, line and mono out pins according to the master switch */
5860static void alc260_hp_master_update(struct hda_codec *codec,
5861 hda_nid_t hp, hda_nid_t line,
5862 hda_nid_t mono)
5863{
5864 struct alc_spec *spec = codec->spec;
5865 unsigned int val = spec->master_sw ? PIN_HP : 0;
5866 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005867 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005868 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005869 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005870 val);
5871 /* mono (speaker) depending on the HP jack sense */
5872 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005873 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005874 val);
5875}
5876
5877static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5878 struct snd_ctl_elem_value *ucontrol)
5879{
5880 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5881 struct alc_spec *spec = codec->spec;
5882 *ucontrol->value.integer.value = spec->master_sw;
5883 return 0;
5884}
5885
5886static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5887 struct snd_ctl_elem_value *ucontrol)
5888{
5889 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5890 struct alc_spec *spec = codec->spec;
5891 int val = !!*ucontrol->value.integer.value;
5892 hda_nid_t hp, line, mono;
5893
5894 if (val == spec->master_sw)
5895 return 0;
5896 spec->master_sw = val;
5897 hp = (kcontrol->private_value >> 16) & 0xff;
5898 line = (kcontrol->private_value >> 8) & 0xff;
5899 mono = kcontrol->private_value & 0xff;
5900 alc260_hp_master_update(codec, hp, line, mono);
5901 return 1;
5902}
5903
5904static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5905 {
5906 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5907 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005908 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005909 .info = snd_ctl_boolean_mono_info,
5910 .get = alc260_hp_master_sw_get,
5911 .put = alc260_hp_master_sw_put,
5912 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5913 },
5914 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5915 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5916 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5917 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5918 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5919 HDA_OUTPUT),
5920 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5921 { } /* end */
5922};
5923
5924static struct hda_verb alc260_hp_unsol_verbs[] = {
5925 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5926 {},
5927};
5928
5929static void alc260_hp_automute(struct hda_codec *codec)
5930{
5931 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005932
Wu Fengguang864f92b2009-11-18 12:38:02 +08005933 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005934 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5935}
5936
5937static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5938{
5939 if ((res >> 26) == ALC880_HP_EVENT)
5940 alc260_hp_automute(codec);
5941}
5942
Kailang Yangdf694da2005-12-05 19:42:22 +01005943static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005944 {
5945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5946 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005947 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005948 .info = snd_ctl_boolean_mono_info,
5949 .get = alc260_hp_master_sw_get,
5950 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005951 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005952 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005953 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5954 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5955 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5956 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5957 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5958 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005959 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5960 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005961 { } /* end */
5962};
5963
Kailang Yang3f878302008-08-26 13:02:23 +02005964static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5965 .ops = &snd_hda_bind_vol,
5966 .values = {
5967 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5968 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5969 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5970 0
5971 },
5972};
5973
5974static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5975 .ops = &snd_hda_bind_sw,
5976 .values = {
5977 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5978 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5979 0
5980 },
5981};
5982
5983static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5984 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5985 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5986 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5988 { } /* end */
5989};
5990
Takashi Iwaibec15c32008-01-28 18:16:30 +01005991static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5992 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5993 {},
5994};
5995
5996static void alc260_hp_3013_automute(struct hda_codec *codec)
5997{
5998 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005999
Wu Fengguang864f92b2009-11-18 12:38:02 +08006000 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006001 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006002}
6003
6004static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6005 unsigned int res)
6006{
6007 if ((res >> 26) == ALC880_HP_EVENT)
6008 alc260_hp_3013_automute(codec);
6009}
6010
Kailang Yang3f878302008-08-26 13:02:23 +02006011static void alc260_hp_3012_automute(struct hda_codec *codec)
6012{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006013 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006014
Kailang Yang3f878302008-08-26 13:02:23 +02006015 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6016 bits);
6017 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6018 bits);
6019 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6020 bits);
6021}
6022
6023static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6024 unsigned int res)
6025{
6026 if ((res >> 26) == ALC880_HP_EVENT)
6027 alc260_hp_3012_automute(codec);
6028}
6029
6030/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006031 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6032 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006033static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006034 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006035 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006036 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006037 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6038 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6039 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6040 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006041 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006042 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6043 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006044 { } /* end */
6045};
6046
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006047/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6048 * versions of the ALC260 don't act on requests to enable mic bias from NID
6049 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6050 * datasheet doesn't mention this restriction. At this stage it's not clear
6051 * whether this behaviour is intentional or is a hardware bug in chip
6052 * revisions available in early 2006. Therefore for now allow the
6053 * "Headphone Jack Mode" control to span all choices, but if it turns out
6054 * that the lack of mic bias for this NID is intentional we could change the
6055 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6056 *
6057 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6058 * don't appear to make the mic bias available from the "line" jack, even
6059 * though the NID used for this jack (0x14) can supply it. The theory is
6060 * that perhaps Acer have included blocking capacitors between the ALC260
6061 * and the output jack. If this turns out to be the case for all such
6062 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6063 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006064 *
6065 * The C20x Tablet series have a mono internal speaker which is controlled
6066 * via the chip's Mono sum widget and pin complex, so include the necessary
6067 * controls for such models. On models without a "mono speaker" the control
6068 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006069 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006070static struct snd_kcontrol_new alc260_acer_mixer[] = {
6071 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6072 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006073 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006074 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006075 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006076 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006077 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006078 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6079 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6081 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6082 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6083 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6084 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6085 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006086 { } /* end */
6087};
6088
Michael Schwingencc959482009-02-22 18:58:45 +01006089/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6090 */
6091static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6092 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6093 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6094 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6095 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6096 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6097 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6098 { } /* end */
6099};
6100
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006101/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6102 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6103 */
6104static struct snd_kcontrol_new alc260_will_mixer[] = {
6105 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6106 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6108 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6109 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6110 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6111 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6112 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6113 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6114 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006115 { } /* end */
6116};
6117
6118/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6119 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6120 */
6121static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6122 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6123 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6125 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6126 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6127 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6128 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6129 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6130 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6131 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6132 { } /* end */
6133};
6134
Kailang Yangdf694da2005-12-05 19:42:22 +01006135/*
6136 * initialization verbs
6137 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006138static struct hda_verb alc260_init_verbs[] = {
6139 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006141 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006142 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006143 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006144 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006145 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006146 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006147 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006148 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006149 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006150 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006151 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006152 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006153 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006154 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006155 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006156 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6157 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006158 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006159 /* set connection select to line in (default select for this ADC) */
6160 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006161 /* mute capture amp left and right */
6162 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6163 /* set connection select to line in (default select for this ADC) */
6164 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006165 /* set vol=0 Line-Out mixer amp left and right */
6166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6167 /* unmute pin widget amp left and right (no gain on this amp) */
6168 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6169 /* set vol=0 HP mixer amp left and right */
6170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6171 /* unmute pin widget amp left and right (no gain on this amp) */
6172 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6173 /* set vol=0 Mono mixer amp left and right */
6174 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6175 /* unmute pin widget amp left and right (no gain on this amp) */
6176 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6177 /* unmute LINE-2 out pin */
6178 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006179 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6180 * Line In 2 = 0x03
6181 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006182 /* mute analog inputs */
6183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006188 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006189 /* mute Front out path */
6190 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6192 /* mute Headphone out path */
6193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6194 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6195 /* mute Mono out path */
6196 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6197 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 { }
6199};
6200
Takashi Iwai474167d2006-05-17 17:17:43 +02006201#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006202static struct hda_verb alc260_hp_init_verbs[] = {
6203 /* Headphone and output */
6204 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6205 /* mono output */
6206 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6207 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6208 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6209 /* Mic2 (front panel) pin widget for input and vref at 80% */
6210 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6211 /* Line In pin widget for input */
6212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6213 /* Line-2 pin widget for output */
6214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6215 /* CD pin widget for input */
6216 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6217 /* unmute amp left and right */
6218 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6219 /* set connection select to line in (default select for this ADC) */
6220 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6221 /* unmute Line-Out mixer amp left and right (volume = 0) */
6222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6223 /* mute pin widget amp left and right (no gain on this amp) */
6224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6225 /* unmute HP mixer amp left and right (volume = 0) */
6226 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6227 /* mute pin widget amp left and right (no gain on this amp) */
6228 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006229 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6230 * Line In 2 = 0x03
6231 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006232 /* mute analog inputs */
6233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006238 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6239 /* Unmute Front out path */
6240 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6241 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6242 /* Unmute Headphone out path */
6243 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6245 /* Unmute Mono out path */
6246 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6247 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6248 { }
6249};
Takashi Iwai474167d2006-05-17 17:17:43 +02006250#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006251
6252static struct hda_verb alc260_hp_3013_init_verbs[] = {
6253 /* Line out and output */
6254 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6255 /* mono output */
6256 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6257 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6258 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6259 /* Mic2 (front panel) pin widget for input and vref at 80% */
6260 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6261 /* Line In pin widget for input */
6262 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6263 /* Headphone pin widget for output */
6264 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6265 /* CD pin widget for input */
6266 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6267 /* unmute amp left and right */
6268 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6269 /* set connection select to line in (default select for this ADC) */
6270 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6271 /* unmute Line-Out mixer amp left and right (volume = 0) */
6272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6273 /* mute pin widget amp left and right (no gain on this amp) */
6274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6275 /* unmute HP mixer amp left and right (volume = 0) */
6276 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6277 /* mute pin widget amp left and right (no gain on this amp) */
6278 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006279 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6280 * Line In 2 = 0x03
6281 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006282 /* mute analog inputs */
6283 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6284 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006288 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6289 /* Unmute Front out path */
6290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6292 /* Unmute Headphone out path */
6293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6295 /* Unmute Mono out path */
6296 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6298 { }
6299};
6300
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006301/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006302 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6303 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006304 */
6305static struct hda_verb alc260_fujitsu_init_verbs[] = {
6306 /* Disable all GPIOs */
6307 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6308 /* Internal speaker is connected to headphone pin */
6309 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6310 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006312 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6313 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6314 /* Ensure all other unused pins are disabled and muted. */
6315 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6316 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006317 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006318 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006319 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006320 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006323
Jonathan Woithef7ace402006-02-28 11:46:14 +01006324 /* Disable digital (SPDIF) pins */
6325 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6326 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006327
Kailang Yangea1fb292008-08-26 12:58:38 +02006328 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006329 * when acting as an output.
6330 */
6331 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6332
6333 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6340 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006343
Jonathan Woithef7ace402006-02-28 11:46:14 +01006344 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6345 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6346 /* Unmute Line1 pin widget output buffer since it starts as an output.
6347 * If the pin mode is changed by the user the pin mode control will
6348 * take care of enabling the pin's input/output buffers as needed.
6349 * Therefore there's no need to enable the input buffer at this
6350 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006351 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006353 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006354 * mixer ctrl)
6355 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006356 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006357
Jonathan Woithef7ace402006-02-28 11:46:14 +01006358 /* Mute capture amp left and right */
6359 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006360 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006361 * in (on mic1 pin)
6362 */
6363 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006364
Jonathan Woithef7ace402006-02-28 11:46:14 +01006365 /* Do the same for the second ADC: mute capture input amp and
6366 * set ADC connection to line in (on mic1 pin)
6367 */
6368 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6369 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006370
Jonathan Woithef7ace402006-02-28 11:46:14 +01006371 /* Mute all inputs to mixer widget (even unconnected ones) */
6372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006380
6381 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006382};
6383
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006384/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6385 * similar laptops (adapted from Fujitsu init verbs).
6386 */
6387static struct hda_verb alc260_acer_init_verbs[] = {
6388 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6389 * the headphone jack. Turn this on and rely on the standard mute
6390 * methods whenever the user wants to turn these outputs off.
6391 */
6392 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6393 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6394 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6395 /* Internal speaker/Headphone jack is connected to Line-out pin */
6396 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6397 /* Internal microphone/Mic jack is connected to Mic1 pin */
6398 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6399 /* Line In jack is connected to Line1 pin */
6400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006401 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6402 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006403 /* Ensure all other unused pins are disabled and muted. */
6404 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6405 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006406 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6407 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6410 /* Disable digital (SPDIF) pins */
6411 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6412 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6413
Kailang Yangea1fb292008-08-26 12:58:38 +02006414 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006415 * bus when acting as outputs.
6416 */
6417 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6418 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6419
6420 /* Start with output sum widgets muted and their output gains at min */
6421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6423 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6426 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6427 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6428 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6429 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6430
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006431 /* Unmute Line-out pin widget amp left and right
6432 * (no equiv mixer ctrl)
6433 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006434 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006435 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6436 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006437 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6438 * inputs. If the pin mode is changed by the user the pin mode control
6439 * will take care of enabling the pin's input/output buffers as needed.
6440 * Therefore there's no need to enable the input buffer at this
6441 * stage.
6442 */
6443 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6445
6446 /* Mute capture amp left and right */
6447 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6448 /* Set ADC connection select to match default mixer setting - mic
6449 * (on mic1 pin)
6450 */
6451 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6452
6453 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006454 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006455 */
6456 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006457 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006458
6459 /* Mute all inputs to mixer widget (even unconnected ones) */
6460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6468
6469 { }
6470};
6471
Michael Schwingencc959482009-02-22 18:58:45 +01006472/* Initialisation sequence for Maxdata Favorit 100XS
6473 * (adapted from Acer init verbs).
6474 */
6475static struct hda_verb alc260_favorit100_init_verbs[] = {
6476 /* GPIO 0 enables the output jack.
6477 * Turn this on and rely on the standard mute
6478 * methods whenever the user wants to turn these outputs off.
6479 */
6480 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6481 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6482 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6483 /* Line/Mic input jack is connected to Mic1 pin */
6484 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6485 /* Ensure all other unused pins are disabled and muted. */
6486 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6487 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6488 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6489 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6490 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6491 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6496 /* Disable digital (SPDIF) pins */
6497 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6498 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6499
6500 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6501 * bus when acting as outputs.
6502 */
6503 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6504 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6505
6506 /* Start with output sum widgets muted and their output gains at min */
6507 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6512 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6513 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6514 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6515 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6516
6517 /* Unmute Line-out pin widget amp left and right
6518 * (no equiv mixer ctrl)
6519 */
6520 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6521 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6522 * inputs. If the pin mode is changed by the user the pin mode control
6523 * will take care of enabling the pin's input/output buffers as needed.
6524 * Therefore there's no need to enable the input buffer at this
6525 * stage.
6526 */
6527 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6528
6529 /* Mute capture amp left and right */
6530 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6531 /* Set ADC connection select to match default mixer setting - mic
6532 * (on mic1 pin)
6533 */
6534 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6535
6536 /* Do similar with the second ADC: mute capture input amp and
6537 * set ADC connection to mic to match ALSA's default state.
6538 */
6539 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6540 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6541
6542 /* Mute all inputs to mixer widget (even unconnected ones) */
6543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6551
6552 { }
6553};
6554
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006555static struct hda_verb alc260_will_verbs[] = {
6556 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6557 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6558 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6559 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6560 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6561 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6562 {}
6563};
6564
6565static struct hda_verb alc260_replacer_672v_verbs[] = {
6566 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6567 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6568 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6569
6570 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6571 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6572 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6573
6574 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6575 {}
6576};
6577
6578/* toggle speaker-output according to the hp-jack state */
6579static void alc260_replacer_672v_automute(struct hda_codec *codec)
6580{
6581 unsigned int present;
6582
6583 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006584 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006585 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006586 snd_hda_codec_write_cache(codec, 0x01, 0,
6587 AC_VERB_SET_GPIO_DATA, 1);
6588 snd_hda_codec_write_cache(codec, 0x0f, 0,
6589 AC_VERB_SET_PIN_WIDGET_CONTROL,
6590 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006591 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006592 snd_hda_codec_write_cache(codec, 0x01, 0,
6593 AC_VERB_SET_GPIO_DATA, 0);
6594 snd_hda_codec_write_cache(codec, 0x0f, 0,
6595 AC_VERB_SET_PIN_WIDGET_CONTROL,
6596 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006597 }
6598}
6599
6600static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6601 unsigned int res)
6602{
6603 if ((res >> 26) == ALC880_HP_EVENT)
6604 alc260_replacer_672v_automute(codec);
6605}
6606
Kailang Yang3f878302008-08-26 13:02:23 +02006607static struct hda_verb alc260_hp_dc7600_verbs[] = {
6608 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6610 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6611 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6612 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6614 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6615 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6616 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6617 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6618 {}
6619};
6620
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006621/* Test configuration for debugging, modelled after the ALC880 test
6622 * configuration.
6623 */
6624#ifdef CONFIG_SND_DEBUG
6625static hda_nid_t alc260_test_dac_nids[1] = {
6626 0x02,
6627};
6628static hda_nid_t alc260_test_adc_nids[2] = {
6629 0x04, 0x05,
6630};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006631/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006632 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006633 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006634 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006635static struct hda_input_mux alc260_test_capture_sources[2] = {
6636 {
6637 .num_items = 7,
6638 .items = {
6639 { "MIC1 pin", 0x0 },
6640 { "MIC2 pin", 0x1 },
6641 { "LINE1 pin", 0x2 },
6642 { "LINE2 pin", 0x3 },
6643 { "CD pin", 0x4 },
6644 { "LINE-OUT pin", 0x5 },
6645 { "HP-OUT pin", 0x6 },
6646 },
6647 },
6648 {
6649 .num_items = 8,
6650 .items = {
6651 { "MIC1 pin", 0x0 },
6652 { "MIC2 pin", 0x1 },
6653 { "LINE1 pin", 0x2 },
6654 { "LINE2 pin", 0x3 },
6655 { "CD pin", 0x4 },
6656 { "Mixer", 0x5 },
6657 { "LINE-OUT pin", 0x6 },
6658 { "HP-OUT pin", 0x7 },
6659 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006660 },
6661};
6662static struct snd_kcontrol_new alc260_test_mixer[] = {
6663 /* Output driver widgets */
6664 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6665 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6666 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6667 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6668 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6669 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6670
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006671 /* Modes for retasking pin widgets
6672 * Note: the ALC260 doesn't seem to act on requests to enable mic
6673 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6674 * mention this restriction. At this stage it's not clear whether
6675 * this behaviour is intentional or is a hardware bug in chip
6676 * revisions available at least up until early 2006. Therefore for
6677 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6678 * choices, but if it turns out that the lack of mic bias for these
6679 * NIDs is intentional we could change their modes from
6680 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6681 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006682 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6683 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6684 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6685 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6686 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6687 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6688
6689 /* Loopback mixer controls */
6690 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6691 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6692 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6693 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6694 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6695 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6696 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6697 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6698 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6699 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006700 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6701 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6702 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6703 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006704
6705 /* Controls for GPIO pins, assuming they are configured as outputs */
6706 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6707 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6708 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6709 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6710
Jonathan Woithe92621f12006-02-28 11:47:47 +01006711 /* Switches to allow the digital IO pins to be enabled. The datasheet
6712 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006713 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006714 */
6715 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6716 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6717
Jonathan Woithef8225f62008-01-08 12:16:54 +01006718 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6719 * this output to turn on an external amplifier.
6720 */
6721 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6722 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6723
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006724 { } /* end */
6725};
6726static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006727 /* Enable all GPIOs as outputs with an initial value of 0 */
6728 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6729 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6730 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6731
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006732 /* Enable retasking pins as output, initially without power amp */
6733 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6734 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6737 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6738 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6739
Jonathan Woithe92621f12006-02-28 11:47:47 +01006740 /* Disable digital (SPDIF) pins initially, but users can enable
6741 * them via a mixer switch. In the case of SPDIF-out, this initverb
6742 * payload also sets the generation to 0, output to be in "consumer"
6743 * PCM format, copyright asserted, no pre-emphasis and no validity
6744 * control.
6745 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006746 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6747 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6748
Kailang Yangea1fb292008-08-26 12:58:38 +02006749 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006750 * OUT1 sum bus when acting as an output.
6751 */
6752 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6753 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6754 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6755 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6756
6757 /* Start with output sum widgets muted and their output gains at min */
6758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6759 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6760 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6762 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6763 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6764 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6765 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6766 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6767
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006768 /* Unmute retasking pin widget output buffers since the default
6769 * state appears to be output. As the pin mode is changed by the
6770 * user the pin mode control will take care of enabling the pin's
6771 * input/output buffers as needed.
6772 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006773 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6774 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6776 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6777 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6778 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6779 /* Also unmute the mono-out pin widget */
6780 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6781
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006782 /* Mute capture amp left and right */
6783 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006784 /* Set ADC connection select to match default mixer setting (mic1
6785 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006786 */
6787 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6788
6789 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006790 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006791 */
6792 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6793 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6794
6795 /* Mute all inputs to mixer widget (even unconnected ones) */
6796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6802 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6804
6805 { }
6806};
6807#endif
6808
Takashi Iwai63300792008-01-24 15:31:36 +01006809#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6810#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006811
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006812#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6813#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6814
Kailang Yangdf694da2005-12-05 19:42:22 +01006815/*
6816 * for BIOS auto-configuration
6817 */
6818
6819static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006820 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006821{
6822 hda_nid_t nid_vol;
6823 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006824 int err;
6825
6826 if (nid >= 0x0f && nid < 0x11) {
6827 nid_vol = nid - 0x7;
6828 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6829 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6830 } else if (nid == 0x11) {
6831 nid_vol = nid - 0x7;
6832 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6833 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6834 } else if (nid >= 0x12 && nid <= 0x15) {
6835 nid_vol = 0x08;
6836 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6837 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6838 } else
6839 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006840
Takashi Iwai863b4512008-10-21 17:01:47 +02006841 if (!(*vol_bits & (1 << nid_vol))) {
6842 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006843 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006844 if (err < 0)
6845 return err;
6846 *vol_bits |= (1 << nid_vol);
6847 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006848 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006849 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006850 return err;
6851 return 1;
6852}
6853
6854/* add playback controls from the parsed DAC table */
6855static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6856 const struct auto_pin_cfg *cfg)
6857{
6858 hda_nid_t nid;
6859 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006860 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006861
6862 spec->multiout.num_dacs = 1;
6863 spec->multiout.dac_nids = spec->private_dac_nids;
6864 spec->multiout.dac_nids[0] = 0x02;
6865
6866 nid = cfg->line_out_pins[0];
6867 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006868 const char *pfx;
6869 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6870 pfx = "Master";
6871 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6872 pfx = "Speaker";
6873 else
6874 pfx = "Front";
6875 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006876 if (err < 0)
6877 return err;
6878 }
6879
Takashi Iwai82bc9552006-03-21 11:24:42 +01006880 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006881 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006882 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006883 if (err < 0)
6884 return err;
6885 }
6886
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006887 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006888 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006889 err = alc260_add_playback_controls(spec, nid, "Headphone",
6890 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006891 if (err < 0)
6892 return err;
6893 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006894 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006895}
6896
6897/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006898static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006899 const struct auto_pin_cfg *cfg)
6900{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006901 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006902}
6903
6904static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6905 hda_nid_t nid, int pin_type,
6906 int sel_idx)
6907{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006908 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006909 /* need the manual connection? */
6910 if (nid >= 0x12) {
6911 int idx = nid - 0x12;
6912 snd_hda_codec_write(codec, idx + 0x0b, 0,
6913 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006914 }
6915}
6916
6917static void alc260_auto_init_multi_out(struct hda_codec *codec)
6918{
6919 struct alc_spec *spec = codec->spec;
6920 hda_nid_t nid;
6921
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006922 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006923 if (nid) {
6924 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6925 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6926 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006927
Takashi Iwai82bc9552006-03-21 11:24:42 +01006928 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006929 if (nid)
6930 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6931
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006932 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006934 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006935}
Kailang Yangdf694da2005-12-05 19:42:22 +01006936
6937#define ALC260_PIN_CD_NID 0x16
6938static void alc260_auto_init_analog_input(struct hda_codec *codec)
6939{
6940 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006941 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006942 int i;
6943
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006944 for (i = 0; i < cfg->num_inputs; i++) {
6945 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006946 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006947 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006948 if (nid != ALC260_PIN_CD_NID &&
6949 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006950 snd_hda_codec_write(codec, nid, 0,
6951 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006952 AMP_OUT_MUTE);
6953 }
6954 }
6955}
6956
Takashi Iwai7f311a42010-04-09 17:32:23 +02006957#define alc260_auto_init_input_src alc880_auto_init_input_src
6958
Kailang Yangdf694da2005-12-05 19:42:22 +01006959/*
6960 * generic initialization of ADC, input mixers and output mixers
6961 */
6962static struct hda_verb alc260_volume_init_verbs[] = {
6963 /*
6964 * Unmute ADC0-1 and set the default input to mic-in
6965 */
6966 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6967 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6968 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6969 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006970
Kailang Yangdf694da2005-12-05 19:42:22 +01006971 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6972 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006973 * Note: PASD motherboards uses the Line In 2 as the input for
6974 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006975 */
6976 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006977 /* mute analog inputs */
6978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6979 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006983
6984 /*
6985 * Set up output mixers (0x08 - 0x0a)
6986 */
6987 /* set vol=0 to output mixers */
6988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6990 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6991 /* set up input amps for analog loopback */
6992 /* Amp Indices: DAC = 0, mixer = 1 */
6993 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6994 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6995 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6996 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6997 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6998 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006999
Kailang Yangdf694da2005-12-05 19:42:22 +01007000 { }
7001};
7002
7003static int alc260_parse_auto_config(struct hda_codec *codec)
7004{
7005 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007006 int err;
7007 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7008
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007009 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7010 alc260_ignore);
7011 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007012 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007013 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7014 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007015 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007016 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007017 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007018 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007019 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007020 return err;
7021
7022 spec->multiout.max_channels = 2;
7023
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007024 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007026 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007027 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007028
Takashi Iwaid88897e2008-10-31 15:01:37 +01007029 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007030
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007031 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007032 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007033
Kailang Yang6227cdc2010-02-25 08:36:52 +01007034 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007035
Kailang Yangdf694da2005-12-05 19:42:22 +01007036 return 1;
7037}
7038
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007039/* additional initialization for auto-configuration model */
7040static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007041{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007042 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007043 alc260_auto_init_multi_out(codec);
7044 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007045 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007046 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007047 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007048 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007049}
7050
Takashi Iwaicb53c622007-08-10 17:21:45 +02007051#ifdef CONFIG_SND_HDA_POWER_SAVE
7052static struct hda_amp_list alc260_loopbacks[] = {
7053 { 0x07, HDA_INPUT, 0 },
7054 { 0x07, HDA_INPUT, 1 },
7055 { 0x07, HDA_INPUT, 2 },
7056 { 0x07, HDA_INPUT, 3 },
7057 { 0x07, HDA_INPUT, 4 },
7058 { } /* end */
7059};
7060#endif
7061
Kailang Yangdf694da2005-12-05 19:42:22 +01007062/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007063 * Pin config fixes
7064 */
7065enum {
7066 PINFIX_HP_DC5750,
7067};
7068
Takashi Iwaifc091762010-08-04 23:53:36 +02007069static const struct alc_fixup alc260_fixups[] = {
7070 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02007071 .pins = (const struct alc_pincfg[]) {
7072 { 0x11, 0x90130110 }, /* speaker */
7073 { }
7074 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007075 },
7076};
7077
7078static struct snd_pci_quirk alc260_fixup_tbl[] = {
7079 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7080 {}
7081};
7082
7083/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007084 * ALC260 configurations
7085 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007086static const char *alc260_models[ALC260_MODEL_LAST] = {
7087 [ALC260_BASIC] = "basic",
7088 [ALC260_HP] = "hp",
7089 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007090 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007091 [ALC260_FUJITSU_S702X] = "fujitsu",
7092 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007093 [ALC260_WILL] = "will",
7094 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007095 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007096#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007097 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007098#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007099 [ALC260_AUTO] = "auto",
7100};
7101
7102static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007103 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007104 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007105 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007106 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007107 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007108 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007109 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007110 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007111 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007112 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7113 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7114 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7115 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7116 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7117 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7118 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7119 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7120 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007121 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007122 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007123 {}
7124};
7125
Kailang Yangdf694da2005-12-05 19:42:22 +01007126static struct alc_config_preset alc260_presets[] = {
7127 [ALC260_BASIC] = {
7128 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007129 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007130 .init_verbs = { alc260_init_verbs },
7131 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7132 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007133 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007134 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007135 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7136 .channel_mode = alc260_modes,
7137 .input_mux = &alc260_capture_source,
7138 },
7139 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007140 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007141 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007142 .init_verbs = { alc260_init_verbs,
7143 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007144 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7145 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007146 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7147 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007148 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7149 .channel_mode = alc260_modes,
7150 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007151 .unsol_event = alc260_hp_unsol_event,
7152 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007153 },
Kailang Yang3f878302008-08-26 13:02:23 +02007154 [ALC260_HP_DC7600] = {
7155 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007156 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007157 .init_verbs = { alc260_init_verbs,
7158 alc260_hp_dc7600_verbs },
7159 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7160 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007161 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7162 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007163 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7164 .channel_mode = alc260_modes,
7165 .input_mux = &alc260_capture_source,
7166 .unsol_event = alc260_hp_3012_unsol_event,
7167 .init_hook = alc260_hp_3012_automute,
7168 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007169 [ALC260_HP_3013] = {
7170 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007171 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007172 .init_verbs = { alc260_hp_3013_init_verbs,
7173 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007174 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7175 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007176 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7177 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007178 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7179 .channel_mode = alc260_modes,
7180 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007181 .unsol_event = alc260_hp_3013_unsol_event,
7182 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007183 },
7184 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007185 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007186 .init_verbs = { alc260_fujitsu_init_verbs },
7187 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7188 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007189 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7190 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007191 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7192 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007193 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7194 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007195 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007196 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007197 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007198 .init_verbs = { alc260_acer_init_verbs },
7199 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7200 .dac_nids = alc260_dac_nids,
7201 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7202 .adc_nids = alc260_dual_adc_nids,
7203 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7204 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007205 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7206 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007207 },
Michael Schwingencc959482009-02-22 18:58:45 +01007208 [ALC260_FAVORIT100] = {
7209 .mixers = { alc260_favorit100_mixer },
7210 .init_verbs = { alc260_favorit100_init_verbs },
7211 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7212 .dac_nids = alc260_dac_nids,
7213 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7214 .adc_nids = alc260_dual_adc_nids,
7215 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7216 .channel_mode = alc260_modes,
7217 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7218 .input_mux = alc260_favorit100_capture_sources,
7219 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007220 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007221 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007222 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7223 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7224 .dac_nids = alc260_dac_nids,
7225 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7226 .adc_nids = alc260_adc_nids,
7227 .dig_out_nid = ALC260_DIGOUT_NID,
7228 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7229 .channel_mode = alc260_modes,
7230 .input_mux = &alc260_capture_source,
7231 },
7232 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007233 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007234 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7235 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7236 .dac_nids = alc260_dac_nids,
7237 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7238 .adc_nids = alc260_adc_nids,
7239 .dig_out_nid = ALC260_DIGOUT_NID,
7240 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7241 .channel_mode = alc260_modes,
7242 .input_mux = &alc260_capture_source,
7243 .unsol_event = alc260_replacer_672v_unsol_event,
7244 .init_hook = alc260_replacer_672v_automute,
7245 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007246#ifdef CONFIG_SND_DEBUG
7247 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007248 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007249 .init_verbs = { alc260_test_init_verbs },
7250 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7251 .dac_nids = alc260_test_dac_nids,
7252 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7253 .adc_nids = alc260_test_adc_nids,
7254 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7255 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007256 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7257 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007258 },
7259#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007260};
7261
Linus Torvalds1da177e2005-04-16 15:20:36 -07007262static int patch_alc260(struct hda_codec *codec)
7263{
7264 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007265 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007266
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007267 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007268 if (spec == NULL)
7269 return -ENOMEM;
7270
7271 codec->spec = spec;
7272
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007273 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7274 alc260_models,
7275 alc260_cfg_tbl);
7276 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007277 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007278 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007279 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007280 }
7281
Takashi Iwaifc091762010-08-04 23:53:36 +02007282 if (board_config == ALC260_AUTO)
7283 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7284
Kailang Yangdf694da2005-12-05 19:42:22 +01007285 if (board_config == ALC260_AUTO) {
7286 /* automatic parse from the BIOS config */
7287 err = alc260_parse_auto_config(codec);
7288 if (err < 0) {
7289 alc_free(codec);
7290 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007291 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007292 printk(KERN_INFO
7293 "hda_codec: Cannot set up configuration "
7294 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007295 board_config = ALC260_BASIC;
7296 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007297 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007298
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007299 err = snd_hda_attach_beep_device(codec, 0x1);
7300 if (err < 0) {
7301 alc_free(codec);
7302 return err;
7303 }
7304
Kailang Yangdf694da2005-12-05 19:42:22 +01007305 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007306 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007307
Linus Torvalds1da177e2005-04-16 15:20:36 -07007308 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7309 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307310 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007311
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007312 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7313 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7314
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007315 if (!spec->adc_nids && spec->input_mux) {
7316 /* check whether NID 0x04 is valid */
7317 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007318 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007319 /* get type */
7320 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7321 spec->adc_nids = alc260_adc_nids_alt;
7322 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7323 } else {
7324 spec->adc_nids = alc260_adc_nids;
7325 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7326 }
7327 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007328 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007329 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007330
Takashi Iwaifc091762010-08-04 23:53:36 +02007331 if (board_config == ALC260_AUTO)
7332 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7333
Takashi Iwai2134ea42008-01-10 16:53:55 +01007334 spec->vmaster_nid = 0x08;
7335
Linus Torvalds1da177e2005-04-16 15:20:36 -07007336 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007337 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007338 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007339#ifdef CONFIG_SND_HDA_POWER_SAVE
7340 if (!spec->loopback.amplist)
7341 spec->loopback.amplist = alc260_loopbacks;
7342#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007343
7344 return 0;
7345}
7346
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007347
Linus Torvalds1da177e2005-04-16 15:20:36 -07007348/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007349 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007350 *
7351 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7352 * configuration. Each pin widget can choose any input DACs and a mixer.
7353 * Each ADC is connected from a mixer of all inputs. This makes possible
7354 * 6-channel independent captures.
7355 *
7356 * In addition, an independent DAC for the multi-playback (not used in this
7357 * driver yet).
7358 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007359#define ALC882_DIGOUT_NID 0x06
7360#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007361#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7362#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7363#define ALC1200_DIGOUT_NID 0x10
7364
Linus Torvalds1da177e2005-04-16 15:20:36 -07007365
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007366static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007367 { 8, NULL }
7368};
7369
Takashi Iwai4953550a2009-06-30 15:28:30 +02007370/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007371static hda_nid_t alc882_dac_nids[4] = {
7372 /* front, rear, clfe, rear_surr */
7373 0x02, 0x03, 0x04, 0x05
7374};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007375#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007376
Takashi Iwai4953550a2009-06-30 15:28:30 +02007377/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007378#define alc882_adc_nids alc880_adc_nids
7379#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007380#define alc883_adc_nids alc882_adc_nids_alt
7381static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7382static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7383#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007384
Takashi Iwaie1406342008-02-11 18:32:32 +01007385static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7386static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007387#define alc883_capsrc_nids alc882_capsrc_nids_alt
7388static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7389#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007390
Linus Torvalds1da177e2005-04-16 15:20:36 -07007391/* input MUX */
7392/* FIXME: should be a matrix-type input source selection */
7393
7394static struct hda_input_mux alc882_capture_source = {
7395 .num_items = 4,
7396 .items = {
7397 { "Mic", 0x0 },
7398 { "Front Mic", 0x1 },
7399 { "Line", 0x2 },
7400 { "CD", 0x4 },
7401 },
7402};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007403
Takashi Iwai4953550a2009-06-30 15:28:30 +02007404#define alc883_capture_source alc882_capture_source
7405
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007406static struct hda_input_mux alc889_capture_source = {
7407 .num_items = 3,
7408 .items = {
7409 { "Front Mic", 0x0 },
7410 { "Mic", 0x3 },
7411 { "Line", 0x2 },
7412 },
7413};
7414
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007415static struct hda_input_mux mb5_capture_source = {
7416 .num_items = 3,
7417 .items = {
7418 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307419 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007420 { "CD", 0x4 },
7421 },
7422};
7423
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007424static struct hda_input_mux macmini3_capture_source = {
7425 .num_items = 2,
7426 .items = {
7427 { "Line", 0x2 },
7428 { "CD", 0x4 },
7429 },
7430};
7431
Takashi Iwai4953550a2009-06-30 15:28:30 +02007432static struct hda_input_mux alc883_3stack_6ch_intel = {
7433 .num_items = 4,
7434 .items = {
7435 { "Mic", 0x1 },
7436 { "Front Mic", 0x0 },
7437 { "Line", 0x2 },
7438 { "CD", 0x4 },
7439 },
7440};
7441
7442static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7443 .num_items = 2,
7444 .items = {
7445 { "Mic", 0x1 },
7446 { "Line", 0x2 },
7447 },
7448};
7449
7450static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7451 .num_items = 4,
7452 .items = {
7453 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007454 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007455 { "Line", 0x2 },
7456 { "CD", 0x4 },
7457 },
7458};
7459
7460static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7461 .num_items = 2,
7462 .items = {
7463 { "Mic", 0x0 },
7464 { "Int Mic", 0x1 },
7465 },
7466};
7467
7468static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7469 .num_items = 3,
7470 .items = {
7471 { "Mic", 0x0 },
7472 { "Front Mic", 0x1 },
7473 { "Line", 0x4 },
7474 },
7475};
7476
7477static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7478 .num_items = 2,
7479 .items = {
7480 { "Mic", 0x0 },
7481 { "Line", 0x2 },
7482 },
7483};
7484
7485static struct hda_input_mux alc889A_mb31_capture_source = {
7486 .num_items = 2,
7487 .items = {
7488 { "Mic", 0x0 },
7489 /* Front Mic (0x01) unused */
7490 { "Line", 0x2 },
7491 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007492 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007493 },
7494};
7495
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007496static struct hda_input_mux alc889A_imac91_capture_source = {
7497 .num_items = 2,
7498 .items = {
7499 { "Mic", 0x01 },
7500 { "Line", 0x2 }, /* Not sure! */
7501 },
7502};
7503
Takashi Iwai4953550a2009-06-30 15:28:30 +02007504/*
7505 * 2ch mode
7506 */
7507static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7508 { 2, NULL }
7509};
7510
Kailang Yangdf694da2005-12-05 19:42:22 +01007511/*
Kailang Yang272a5272007-05-14 11:00:38 +02007512 * 2ch mode
7513 */
7514static struct hda_verb alc882_3ST_ch2_init[] = {
7515 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7516 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7517 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7518 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7519 { } /* end */
7520};
7521
7522/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007523 * 4ch mode
7524 */
7525static struct hda_verb alc882_3ST_ch4_init[] = {
7526 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7527 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7528 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7529 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7530 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7531 { } /* end */
7532};
7533
7534/*
Kailang Yang272a5272007-05-14 11:00:38 +02007535 * 6ch mode
7536 */
7537static struct hda_verb alc882_3ST_ch6_init[] = {
7538 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7539 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7540 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7541 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7542 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7543 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7544 { } /* end */
7545};
7546
Takashi Iwai4953550a2009-06-30 15:28:30 +02007547static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007548 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007549 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007550 { 6, alc882_3ST_ch6_init },
7551};
7552
Takashi Iwai4953550a2009-06-30 15:28:30 +02007553#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7554
Kailang Yang272a5272007-05-14 11:00:38 +02007555/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307556 * 2ch mode
7557 */
7558static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7559 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7560 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7561 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7562 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7563 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7564 { } /* end */
7565};
7566
7567/*
7568 * 4ch mode
7569 */
7570static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7571 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7572 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7573 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7574 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7575 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7576 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7577 { } /* end */
7578};
7579
7580/*
7581 * 6ch mode
7582 */
7583static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7584 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7585 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7586 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7587 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7588 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7589 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7590 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7591 { } /* end */
7592};
7593
7594static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7595 { 2, alc883_3ST_ch2_clevo_init },
7596 { 4, alc883_3ST_ch4_clevo_init },
7597 { 6, alc883_3ST_ch6_clevo_init },
7598};
7599
7600
7601/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007602 * 6ch mode
7603 */
7604static struct hda_verb alc882_sixstack_ch6_init[] = {
7605 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7606 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7607 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7608 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7609 { } /* end */
7610};
7611
7612/*
7613 * 8ch mode
7614 */
7615static struct hda_verb alc882_sixstack_ch8_init[] = {
7616 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7617 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7618 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7619 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7620 { } /* end */
7621};
7622
7623static struct hda_channel_mode alc882_sixstack_modes[2] = {
7624 { 6, alc882_sixstack_ch6_init },
7625 { 8, alc882_sixstack_ch8_init },
7626};
7627
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007628
7629/* Macbook Air 2,1 */
7630
7631static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7632 { 2, NULL },
7633};
7634
Takashi Iwai87350ad2007-08-16 18:19:38 +02007635/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007636 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007637 */
7638
7639/*
7640 * 2ch mode
7641 */
7642static struct hda_verb alc885_mbp_ch2_init[] = {
7643 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7644 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7645 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7646 { } /* end */
7647};
7648
7649/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007650 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007651 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007652static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007653 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7654 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7655 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7656 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7657 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7658 { } /* end */
7659};
7660
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007661static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007662 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007663 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007664};
7665
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007666/*
7667 * 2ch
7668 * Speakers/Woofer/HP = Front
7669 * LineIn = Input
7670 */
7671static struct hda_verb alc885_mb5_ch2_init[] = {
7672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7674 { } /* end */
7675};
7676
7677/*
7678 * 6ch mode
7679 * Speakers/HP = Front
7680 * Woofer = LFE
7681 * LineIn = Surround
7682 */
7683static struct hda_verb alc885_mb5_ch6_init[] = {
7684 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7686 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7687 { } /* end */
7688};
7689
7690static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7691 { 2, alc885_mb5_ch2_init },
7692 { 6, alc885_mb5_ch6_init },
7693};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007694
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007695#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007696
7697/*
7698 * 2ch mode
7699 */
7700static struct hda_verb alc883_4ST_ch2_init[] = {
7701 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7702 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7703 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7704 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7705 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7706 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7707 { } /* end */
7708};
7709
7710/*
7711 * 4ch mode
7712 */
7713static struct hda_verb alc883_4ST_ch4_init[] = {
7714 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7715 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7716 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7717 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7718 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7719 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7720 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7721 { } /* end */
7722};
7723
7724/*
7725 * 6ch mode
7726 */
7727static struct hda_verb alc883_4ST_ch6_init[] = {
7728 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7729 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7730 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7731 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7732 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7733 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7734 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7735 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7736 { } /* end */
7737};
7738
7739/*
7740 * 8ch mode
7741 */
7742static struct hda_verb alc883_4ST_ch8_init[] = {
7743 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7744 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7745 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7746 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7747 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7748 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7749 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7750 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7751 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7752 { } /* end */
7753};
7754
7755static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7756 { 2, alc883_4ST_ch2_init },
7757 { 4, alc883_4ST_ch4_init },
7758 { 6, alc883_4ST_ch6_init },
7759 { 8, alc883_4ST_ch8_init },
7760};
7761
7762
7763/*
7764 * 2ch mode
7765 */
7766static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7767 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7768 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7769 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7770 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7771 { } /* end */
7772};
7773
7774/*
7775 * 4ch mode
7776 */
7777static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7778 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7779 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7780 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7781 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7782 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7783 { } /* end */
7784};
7785
7786/*
7787 * 6ch mode
7788 */
7789static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7790 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7791 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7792 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7793 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7794 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7795 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7796 { } /* end */
7797};
7798
7799static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7800 { 2, alc883_3ST_ch2_intel_init },
7801 { 4, alc883_3ST_ch4_intel_init },
7802 { 6, alc883_3ST_ch6_intel_init },
7803};
7804
7805/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007806 * 2ch mode
7807 */
7808static struct hda_verb alc889_ch2_intel_init[] = {
7809 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7810 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7811 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7812 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7813 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7814 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7815 { } /* end */
7816};
7817
7818/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007819 * 6ch mode
7820 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007821static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007822 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7823 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7824 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7825 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7826 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007827 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7828 { } /* end */
7829};
7830
7831/*
7832 * 8ch mode
7833 */
7834static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007835 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7836 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7837 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7838 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7839 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007842 { } /* end */
7843};
7844
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007845static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7846 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007847 { 6, alc889_ch6_intel_init },
7848 { 8, alc889_ch8_intel_init },
7849};
7850
7851/*
7852 * 6ch mode
7853 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007854static struct hda_verb alc883_sixstack_ch6_init[] = {
7855 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7856 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7857 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7858 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7859 { } /* end */
7860};
7861
7862/*
7863 * 8ch mode
7864 */
7865static struct hda_verb alc883_sixstack_ch8_init[] = {
7866 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7867 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7868 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7869 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7870 { } /* end */
7871};
7872
7873static struct hda_channel_mode alc883_sixstack_modes[2] = {
7874 { 6, alc883_sixstack_ch6_init },
7875 { 8, alc883_sixstack_ch8_init },
7876};
7877
7878
Linus Torvalds1da177e2005-04-16 15:20:36 -07007879/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7880 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7881 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007882static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007883 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007884 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007885 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007886 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007887 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7888 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007889 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7890 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007891 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007892 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7894 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7895 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7896 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7897 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007899 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7901 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007902 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007903 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007904 { } /* end */
7905};
7906
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007907/* Macbook Air 2,1 same control for HP and internal Speaker */
7908
7909static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7910 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7911 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7912 { }
7913};
7914
7915
Takashi Iwai87350ad2007-08-16 18:19:38 +02007916static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007917 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7918 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7919 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7920 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7921 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007922 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7923 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7925 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007926 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007927 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7928 { } /* end */
7929};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007930
7931static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007932 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7933 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7934 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7935 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7936 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7937 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307938 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7939 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7941 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7943 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7944 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7945 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7946 { } /* end */
7947};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007948
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007949static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7950 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7951 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7952 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7953 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7954 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7955 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7956 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7957 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7959 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7960 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7961 { } /* end */
7962};
7963
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007964static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007965 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7966 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007967 { } /* end */
7968};
7969
7970
Kailang Yangbdd148a2007-05-08 15:19:08 +02007971static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7973 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7974 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7975 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7977 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7978 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007981 { } /* end */
7982};
7983
Kailang Yang272a5272007-05-14 11:00:38 +02007984static struct snd_kcontrol_new alc882_targa_mixer[] = {
7985 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7986 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007997 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007998 { } /* end */
7999};
8000
8001/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8002 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8003 */
8004static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8006 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8008 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8009 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8010 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8011 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8012 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8013 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8014 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8016 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02008017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008018 { } /* end */
8019};
8020
Takashi Iwai914759b2007-09-06 14:52:04 +02008021static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8022 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8023 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8024 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8025 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8026 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8030 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008032 { } /* end */
8033};
8034
Kailang Yangdf694da2005-12-05 19:42:22 +01008035static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8036 {
8037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8038 .name = "Channel Mode",
8039 .info = alc_ch_mode_info,
8040 .get = alc_ch_mode_get,
8041 .put = alc_ch_mode_put,
8042 },
8043 { } /* end */
8044};
8045
Takashi Iwai4953550a2009-06-30 15:28:30 +02008046static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008047 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008050 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008053 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008056 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8058 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008059
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008060 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008063 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008064 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008068 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008069 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008071 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008072 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008073 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008074 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008075 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008076 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008077 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008078 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8079 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8082 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008083 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008084 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8085 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8086 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8087 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8088 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008089 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008090 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008091
8092 /* FIXME: use matrix-type input source selection */
8093 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008094 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008096 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008098 /* ADC2: mute amp left and right */
8099 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008100 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008101 /* ADC3: mute amp left and right */
8102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008104
8105 { }
8106};
8107
Takashi Iwai4953550a2009-06-30 15:28:30 +02008108static struct hda_verb alc882_adc1_init_verbs[] = {
8109 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8110 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8111 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8114 /* ADC1: mute amp left and right */
8115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8116 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8117 { }
8118};
8119
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008120static struct hda_verb alc882_eapd_verbs[] = {
8121 /* change to EAPD mode */
8122 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008123 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008124 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008125};
8126
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008127static struct hda_verb alc889_eapd_verbs[] = {
8128 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8129 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8130 { }
8131};
8132
Wu Fengguang6732bd02009-07-30 09:19:14 +02008133static struct hda_verb alc_hp15_unsol_verbs[] = {
8134 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8136 {}
8137};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008138
8139static struct hda_verb alc885_init_verbs[] = {
8140 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8142 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008143 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008144 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008146 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008149 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8151 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008152
8153 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8156 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8157 /* Front Pin: output 0 (0x0c) */
8158 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8159 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8160 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8161 /* Rear Pin: output 1 (0x0d) */
8162 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8164 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8165 /* CLFE Pin: output 2 (0x0e) */
8166 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8167 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8168 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8169 /* Side Pin: output 3 (0x0f) */
8170 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8171 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8172 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8173 /* Mic (rear) pin: input vref at 80% */
8174 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8175 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8176 /* Front Mic pin: input vref at 80% */
8177 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8179 /* Line In pin: input */
8180 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8181 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8182
8183 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8184 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008185 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008186 /* Input mixer2 */
8187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008188 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008190 /* ADC2: mute amp left and right */
8191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8192 /* ADC3: mute amp left and right */
8193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8194
8195 { }
8196};
8197
8198static struct hda_verb alc885_init_input_verbs[] = {
8199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8202 { }
8203};
8204
8205
8206/* Unmute Selector 24h and set the default input to front mic */
8207static struct hda_verb alc889_init_input_verbs[] = {
8208 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8210 { }
8211};
8212
8213
Takashi Iwai4953550a2009-06-30 15:28:30 +02008214#define alc883_init_verbs alc882_base_init_verbs
8215
Tobin Davis9102cd12006-12-15 10:02:12 +01008216/* Mac Pro test */
8217static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8218 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8219 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8220 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8221 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8222 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008223 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008224 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8225 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008226 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008227 { } /* end */
8228};
8229
8230static struct hda_verb alc882_macpro_init_verbs[] = {
8231 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8232 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8233 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8234 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8235 /* Front Pin: output 0 (0x0c) */
8236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8239 /* Front Mic pin: input vref at 80% */
8240 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8241 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8242 /* Speaker: output */
8243 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8245 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8246 /* Headphone output (output 0 - 0x0c) */
8247 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8248 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8249 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8250
8251 /* FIXME: use matrix-type input source selection */
8252 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8253 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8257 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8258 /* Input mixer2 */
8259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8262 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8263 /* Input mixer3 */
8264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8268 /* ADC1: mute amp left and right */
8269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8270 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8271 /* ADC2: mute amp left and right */
8272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8273 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8274 /* ADC3: mute amp left and right */
8275 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8276 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8277
8278 { }
8279};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008280
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008281/* Macbook 5,1 */
8282static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008283 /* DACs */
8284 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8285 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8286 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8287 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008288 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008292 /* Surround mixer */
8293 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8294 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8296 /* LFE mixer */
8297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8300 /* HP mixer */
8301 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8304 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008305 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008307 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8308 /* LFE Pin (0x0e) */
8309 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8311 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8312 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008315 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308316 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008317 /* Front Mic pin: input vref at 80% */
8318 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8319 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8320 /* Line In pin */
8321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8323
Alex Murrayb8f171e2010-06-14 12:08:43 +09308324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008327 { }
8328};
8329
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008330/* Macmini 3,1 */
8331static struct hda_verb alc885_macmini3_init_verbs[] = {
8332 /* DACs */
8333 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8334 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8335 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8336 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8337 /* Front mixer */
8338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8341 /* Surround mixer */
8342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8345 /* LFE mixer */
8346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8349 /* HP mixer */
8350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8353 /* Front Pin (0x0c) */
8354 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8356 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8357 /* LFE Pin (0x0e) */
8358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8360 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8361 /* HP Pin (0x0f) */
8362 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8363 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8364 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8365 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8366 /* Line In pin */
8367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8369
8370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8374 { }
8375};
8376
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008377
8378static struct hda_verb alc885_mba21_init_verbs[] = {
8379 /*Internal and HP Speaker Mixer*/
8380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8383 /*Internal Speaker Pin (0x0c)*/
8384 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8385 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8386 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8387 /* HP Pin: output 0 (0x0e) */
8388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8389 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8390 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8391 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8392 /* Line in (is hp when jack connected)*/
8393 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8395
8396 { }
8397 };
8398
8399
Takashi Iwai87350ad2007-08-16 18:19:38 +02008400/* Macbook Pro rev3 */
8401static struct hda_verb alc885_mbp3_init_verbs[] = {
8402 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8406 /* Rear mixer */
8407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008410 /* HP mixer */
8411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008414 /* Front Pin: output 0 (0x0c) */
8415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8416 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8417 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008418 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008419 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008420 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8421 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008422 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8423 /* Mic (rear) pin: input vref at 80% */
8424 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8425 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8426 /* Front Mic pin: input vref at 80% */
8427 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8428 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8429 /* Line In pin: use output 1 when in LineOut mode */
8430 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8431 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8432 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8433
8434 /* FIXME: use matrix-type input source selection */
8435 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8436 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8441 /* Input mixer2 */
8442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8443 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8444 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8445 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8446 /* Input mixer3 */
8447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8451 /* ADC1: mute amp left and right */
8452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8453 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8454 /* ADC2: mute amp left and right */
8455 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8456 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8457 /* ADC3: mute amp left and right */
8458 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8459 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8460
8461 { }
8462};
8463
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008464/* iMac 9,1 */
8465static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008466 /* Internal Speaker Pin (0x0c) */
8467 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8468 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8469 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8470 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8471 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8472 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8473 /* HP Pin: Rear */
8474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8476 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8477 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8478 /* Line in Rear */
8479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8480 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8481 /* Front Mic pin: input vref at 80% */
8482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008484 /* Rear mixer */
8485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8486 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008488 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8492 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008497 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008502 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8504 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008507 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8509 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008510 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008511 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8512 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008513 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8515 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008516 { }
8517};
8518
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008519/* iMac 24 mixer. */
8520static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8521 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8522 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8523 { } /* end */
8524};
8525
8526/* iMac 24 init verbs. */
8527static struct hda_verb alc885_imac24_init_verbs[] = {
8528 /* Internal speakers: output 0 (0x0c) */
8529 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8530 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8531 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8532 /* Internal speakers: output 0 (0x0c) */
8533 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8534 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8535 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8536 /* Headphone: output 0 (0x0c) */
8537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8539 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8540 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8541 /* Front Mic: input vref at 80% */
8542 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8543 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8544 { }
8545};
8546
8547/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008548static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008549{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008550 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008551
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008552 spec->autocfg.hp_pins[0] = 0x14;
8553 spec->autocfg.speaker_pins[0] = 0x18;
8554 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008555}
8556
Takashi Iwai9d54f082010-02-22 08:34:40 +01008557#define alc885_mb5_setup alc885_imac24_setup
8558#define alc885_macmini3_setup alc885_imac24_setup
8559
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008560/* Macbook Air 2,1 */
8561static void alc885_mba21_setup(struct hda_codec *codec)
8562{
8563 struct alc_spec *spec = codec->spec;
8564
8565 spec->autocfg.hp_pins[0] = 0x14;
8566 spec->autocfg.speaker_pins[0] = 0x18;
8567}
8568
8569
8570
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008571static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008572{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008573 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008574
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008575 spec->autocfg.hp_pins[0] = 0x15;
8576 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008577}
8578
Takashi Iwai9d54f082010-02-22 08:34:40 +01008579static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308580{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008581 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308582
Takashi Iwai9d54f082010-02-22 08:34:40 +01008583 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008584 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008585 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008586}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008587
Kailang Yang272a5272007-05-14 11:00:38 +02008588static struct hda_verb alc882_targa_verbs[] = {
8589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8591
8592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8593 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008594
Kailang Yang272a5272007-05-14 11:00:38 +02008595 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8596 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8597 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8598
8599 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008600 { } /* end */
8601};
8602
8603/* toggle speaker-output according to the hp-jack state */
8604static void alc882_targa_automute(struct hda_codec *codec)
8605{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008606 struct alc_spec *spec = codec->spec;
8607 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008608 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008609 spec->jack_present ? 1 : 3);
8610}
8611
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008612static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008613{
8614 struct alc_spec *spec = codec->spec;
8615
8616 spec->autocfg.hp_pins[0] = 0x14;
8617 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008618}
8619
8620static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8621{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008622 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008623 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008624}
8625
8626static struct hda_verb alc882_asus_a7j_verbs[] = {
8627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8629
8630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8631 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8632 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008633
Kailang Yang272a5272007-05-14 11:00:38 +02008634 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8635 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8636 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8637
8638 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8639 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8640 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8641 { } /* end */
8642};
8643
Takashi Iwai914759b2007-09-06 14:52:04 +02008644static struct hda_verb alc882_asus_a7m_verbs[] = {
8645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8647
8648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8650 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008651
Takashi Iwai914759b2007-09-06 14:52:04 +02008652 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8653 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8655
8656 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8657 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8658 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8659 { } /* end */
8660};
8661
Tobin Davis9102cd12006-12-15 10:02:12 +01008662static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8663{
8664 unsigned int gpiostate, gpiomask, gpiodir;
8665
8666 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8667 AC_VERB_GET_GPIO_DATA, 0);
8668
8669 if (!muted)
8670 gpiostate |= (1 << pin);
8671 else
8672 gpiostate &= ~(1 << pin);
8673
8674 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8675 AC_VERB_GET_GPIO_MASK, 0);
8676 gpiomask |= (1 << pin);
8677
8678 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8679 AC_VERB_GET_GPIO_DIRECTION, 0);
8680 gpiodir |= (1 << pin);
8681
8682
8683 snd_hda_codec_write(codec, codec->afg, 0,
8684 AC_VERB_SET_GPIO_MASK, gpiomask);
8685 snd_hda_codec_write(codec, codec->afg, 0,
8686 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8687
8688 msleep(1);
8689
8690 snd_hda_codec_write(codec, codec->afg, 0,
8691 AC_VERB_SET_GPIO_DATA, gpiostate);
8692}
8693
Takashi Iwai7debbe52007-08-16 15:01:03 +02008694/* set up GPIO at initialization */
8695static void alc885_macpro_init_hook(struct hda_codec *codec)
8696{
8697 alc882_gpio_mute(codec, 0, 0);
8698 alc882_gpio_mute(codec, 1, 0);
8699}
8700
8701/* set up GPIO and update auto-muting at initialization */
8702static void alc885_imac24_init_hook(struct hda_codec *codec)
8703{
8704 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008705 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008706}
8707
Kailang Yangdf694da2005-12-05 19:42:22 +01008708/*
8709 * generic initialization of ADC, input mixers and output mixers
8710 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008711static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008712 /*
8713 * Unmute ADC0-2 and set the default input to mic-in
8714 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008715 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8717 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8719
Kailang Yangdf694da2005-12-05 19:42:22 +01008720 /*
8721 * Set up output mixers (0x0c - 0x0f)
8722 */
8723 /* set vol=0 to output mixers */
8724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8727 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8728 /* set up input amps for analog loopback */
8729 /* Amp Indices: DAC = 0, mixer = 1 */
8730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8731 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8732 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8733 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8735 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8736 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8737 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8738 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8739 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8740
8741 /* FIXME: use matrix-type input source selection */
8742 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008743 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008744 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008745 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008747 { }
8748};
8749
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008750/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8751static struct hda_verb alc889A_mb31_ch2_init[] = {
8752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8753 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8754 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8755 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8756 { } /* end */
8757};
8758
8759/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8760static struct hda_verb alc889A_mb31_ch4_init[] = {
8761 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8762 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8763 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8765 { } /* end */
8766};
8767
8768/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8769static struct hda_verb alc889A_mb31_ch5_init[] = {
8770 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8771 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8772 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8773 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8774 { } /* end */
8775};
8776
8777/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8778static struct hda_verb alc889A_mb31_ch6_init[] = {
8779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8780 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8781 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8782 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8783 { } /* end */
8784};
8785
8786static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8787 { 2, alc889A_mb31_ch2_init },
8788 { 4, alc889A_mb31_ch4_init },
8789 { 5, alc889A_mb31_ch5_init },
8790 { 6, alc889A_mb31_ch6_init },
8791};
8792
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008793static struct hda_verb alc883_medion_eapd_verbs[] = {
8794 /* eanable EAPD on medion laptop */
8795 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8796 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8797 { }
8798};
8799
Takashi Iwai4953550a2009-06-30 15:28:30 +02008800#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008801
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008802static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8803 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8805 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8806 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8807 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8808 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8809 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8813 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8814 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8815 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008816 { } /* end */
8817};
8818
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008819static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008820 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8821 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8822 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8823 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8825 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8827 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8828 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8829 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008830 { } /* end */
8831};
8832
Jiang zhefb97dc62008-03-06 11:07:11 +01008833static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8834 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8835 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8836 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8837 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8839 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8841 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8842 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8843 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008844 { } /* end */
8845};
8846
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008847static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8848 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8849 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8851 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8852 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8853 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8854 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008856 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008859 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008860 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008861 { } /* end */
8862};
8863
8864static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8865 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8866 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8867 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8868 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8869 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8870 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8871 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8872 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8873 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8874 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8875 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8881 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008882 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008883 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008884 { } /* end */
8885};
8886
Jiang zhe17bba1b2008-06-04 12:11:07 +02008887static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8888 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8889 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8890 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8891 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8892 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8893 HDA_OUTPUT),
8894 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8895 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8896 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8903 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8905 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8906 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8907 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008908 { } /* end */
8909};
8910
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008911static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8913 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8914 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8915 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8916 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8917 HDA_OUTPUT),
8918 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8919 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8920 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8921 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8922 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8927 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8930 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8932 { } /* end */
8933};
8934
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008935static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008936 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008937 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008938 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008939 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008940 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8941 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008942 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8943 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8947 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8948 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8949 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008950 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8952 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008953 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008955 { } /* end */
8956};
8957
Sasha Alexandrc2592492009-06-16 14:52:54 -04008958static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008962 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008963 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8964 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8965 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8966 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8967 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8968 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008976 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008977};
Kailang Yangccc656c2006-10-17 12:32:26 +02008978
Sasha Alexandrc2592492009-06-16 14:52:54 -04008979static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008980 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008981 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008982 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008983 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008987 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008989 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8990 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8991 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008992 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008993};
Kailang Yangccc656c2006-10-17 12:32:26 +02008994
Takashi Iwaib99dba32009-09-17 18:23:00 +02008995static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8996 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8997 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8999 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9000 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9001 { } /* end */
9002};
9003
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009004static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9006 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009007 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9008 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9011 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009013 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009014};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009015
Kailang Yang272a5272007-05-14 11:00:38 +02009016static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9017 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9018 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02009024 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9025 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009026 { } /* end */
9027};
9028
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009029static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9031 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9032 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9033 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9034 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9035 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9036 { } /* end */
9037};
9038
9039static struct hda_verb alc883_medion_wim2160_verbs[] = {
9040 /* Unmute front mixer */
9041 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9043
9044 /* Set speaker pin to front mixer */
9045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9046
9047 /* Init headphone pin */
9048 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9050 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9051 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9052
9053 { } /* end */
9054};
9055
9056/* toggle speaker-output according to the hp-jack state */
9057static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9058{
9059 struct alc_spec *spec = codec->spec;
9060
9061 spec->autocfg.hp_pins[0] = 0x1a;
9062 spec->autocfg.speaker_pins[0] = 0x15;
9063}
9064
Tobin Davis2880a862007-08-07 11:50:26 +02009065static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009066 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9067 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009068 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009069 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9070 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9072 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009074 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009075};
Tobin Davis2880a862007-08-07 11:50:26 +02009076
Tony Vroond2fd4b02009-06-21 00:40:10 +01009077static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9078 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009079 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009080 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9081 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9085 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9086 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9087 { } /* end */
9088};
9089
Kailang Yange2757d52008-08-26 13:17:46 +02009090static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9092 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9093 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9094 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9095 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9096 0x0d, 1, 0x0, HDA_OUTPUT),
9097 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9098 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9099 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9100 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9101 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009102 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9103 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9105 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9107 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9109 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9110 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009112 { } /* end */
9113};
9114
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009115static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9116 /* Output mixers */
9117 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9118 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9119 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9120 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9121 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9122 HDA_OUTPUT),
9123 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9125 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9126 /* Output switches */
9127 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9128 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9129 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9130 /* Boost mixers */
9131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
9132 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
9133 /* Input mixers */
9134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9136 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9137 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9138 { } /* end */
9139};
9140
Guido Günther3e1647c52009-06-05 00:47:26 +02009141static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9142 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9143 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9144 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9146 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9148 { } /* end */
9149};
9150
Kailang Yange2757d52008-08-26 13:17:46 +02009151static struct hda_bind_ctls alc883_bind_cap_vol = {
9152 .ops = &snd_hda_bind_vol,
9153 .values = {
9154 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9155 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9156 0
9157 },
9158};
9159
9160static struct hda_bind_ctls alc883_bind_cap_switch = {
9161 .ops = &snd_hda_bind_sw,
9162 .values = {
9163 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9164 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9165 0
9166 },
9167};
9168
9169static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9170 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9171 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9173 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9174 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9176 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009178 { } /* end */
9179};
9180
9181static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009182 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9183 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9184 {
9185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9186 /* .name = "Capture Source", */
9187 .name = "Input Source",
9188 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009189 .info = alc_mux_enum_info,
9190 .get = alc_mux_enum_get,
9191 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009192 },
9193 { } /* end */
9194};
9195
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009196static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9197 {
9198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9199 .name = "Channel Mode",
9200 .info = alc_ch_mode_info,
9201 .get = alc_ch_mode_get,
9202 .put = alc_ch_mode_put,
9203 },
9204 { } /* end */
9205};
9206
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009207/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009208static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009209{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009210 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009211
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009212 spec->autocfg.hp_pins[0] = 0x15;
9213 spec->autocfg.speaker_pins[0] = 0x14;
9214 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009215}
9216
9217/* auto-toggle front mic */
9218/*
9219static void alc883_mitac_mic_automute(struct hda_codec *codec)
9220{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009221 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009222
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009223 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9224}
9225*/
9226
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009227static struct hda_verb alc883_mitac_verbs[] = {
9228 /* HP */
9229 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9231 /* Subwoofer */
9232 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9233 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9234
9235 /* enable unsolicited event */
9236 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9237 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9238
9239 { } /* end */
9240};
9241
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309242static struct hda_verb alc883_clevo_m540r_verbs[] = {
9243 /* HP */
9244 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9246 /* Int speaker */
9247 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9248
9249 /* enable unsolicited event */
9250 /*
9251 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9252 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9253 */
9254
9255 { } /* end */
9256};
9257
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009258static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009259 /* HP */
9260 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9261 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9262 /* Int speaker */
9263 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9265
9266 /* enable unsolicited event */
9267 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009268 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009269
9270 { } /* end */
9271};
9272
Jiang zhefb97dc62008-03-06 11:07:11 +01009273static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9274 /* HP */
9275 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9277 /* Subwoofer */
9278 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9279 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9280
9281 /* enable unsolicited event */
9282 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9283
9284 { } /* end */
9285};
9286
Sasha Alexandrc2592492009-06-16 14:52:54 -04009287static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9290
9291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9292 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009293
David Heidelberger64a8be72009-06-08 16:15:18 +02009294/* Connect Line-Out side jack (SPDIF) to Side */
9295 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9296 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9297 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9298/* Connect Mic jack to CLFE */
9299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9300 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9301 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9302/* Connect Line-in jack to Surround */
9303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9305 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9306/* Connect HP out jack to Front */
9307 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9309 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009310
9311 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009312
9313 { } /* end */
9314};
9315
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009316static struct hda_verb alc883_lenovo_101e_verbs[] = {
9317 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9318 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9319 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9320 { } /* end */
9321};
9322
Kailang Yang272a5272007-05-14 11:00:38 +02009323static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9324 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9326 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9328 { } /* end */
9329};
9330
9331static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9335 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9337 { } /* end */
9338};
9339
Kailang Yang189609a2007-08-20 11:31:23 +02009340static struct hda_verb alc883_haier_w66_verbs[] = {
9341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9343
9344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9345
9346 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9347 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9348 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9349 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9350 { } /* end */
9351};
9352
Kailang Yange2757d52008-08-26 13:17:46 +02009353static struct hda_verb alc888_lenovo_sky_verbs[] = {
9354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9358 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9360 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9361 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9362 { } /* end */
9363};
9364
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009365static struct hda_verb alc888_6st_dell_verbs[] = {
9366 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9367 { }
9368};
9369
Guido Günther3e1647c52009-06-05 00:47:26 +02009370static struct hda_verb alc883_vaiott_verbs[] = {
9371 /* HP */
9372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9373 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9374
9375 /* enable unsolicited event */
9376 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9377
9378 { } /* end */
9379};
9380
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009381static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009382{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009383 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009384
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009385 spec->autocfg.hp_pins[0] = 0x1b;
9386 spec->autocfg.speaker_pins[0] = 0x14;
9387 spec->autocfg.speaker_pins[1] = 0x16;
9388 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009389}
9390
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009391static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009392 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009393 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9394 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009395 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009396 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009397};
9398
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009399/*
9400 * 2ch mode
9401 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009402static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009403 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9404 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9405 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9406 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009407 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009408};
9409
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009410/*
9411 * 4ch mode
9412 */
9413static struct hda_verb alc888_3st_hp_4ch_init[] = {
9414 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9415 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9416 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9417 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9418 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9419 { } /* end */
9420};
9421
9422/*
9423 * 6ch mode
9424 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009425static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009426 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9427 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009428 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009429 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9430 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009431 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9432 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009433};
9434
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009435static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009436 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009437 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009438 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009439};
9440
Kailang Yang272a5272007-05-14 11:00:38 +02009441/* toggle front-jack and RCA according to the hp-jack state */
9442static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9443{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009444 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009445
Takashi Iwai47fd8302007-08-10 17:11:07 +02009446 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9447 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9448 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9449 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009450}
9451
9452/* toggle RCA according to the front-jack state */
9453static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9454{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009455 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009456
Takashi Iwai47fd8302007-08-10 17:11:07 +02009457 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9458 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009459}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009460
Kailang Yang272a5272007-05-14 11:00:38 +02009461static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9462 unsigned int res)
9463{
9464 if ((res >> 26) == ALC880_HP_EVENT)
9465 alc888_lenovo_ms7195_front_automute(codec);
9466 if ((res >> 26) == ALC880_FRONT_EVENT)
9467 alc888_lenovo_ms7195_rca_automute(codec);
9468}
9469
Kailang Yang272a5272007-05-14 11:00:38 +02009470/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009471static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009472{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009473 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009474
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009475 spec->autocfg.hp_pins[0] = 0x14;
9476 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009477}
9478
Kailang Yangccc656c2006-10-17 12:32:26 +02009479/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009480#define alc883_targa_init_hook alc882_targa_init_hook
9481#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009482
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009483static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9484{
9485 unsigned int present;
9486
Takashi Iwaid56757a2009-11-18 08:00:14 +01009487 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009488 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9489 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9490}
9491
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009492static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009493{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009494 struct alc_spec *spec = codec->spec;
9495
9496 spec->autocfg.hp_pins[0] = 0x15;
9497 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009498}
9499
9500static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9501{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009502 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009503 alc883_clevo_m720_mic_automute(codec);
9504}
9505
9506static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009507 unsigned int res)
9508{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009509 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009510 case ALC880_MIC_EVENT:
9511 alc883_clevo_m720_mic_automute(codec);
9512 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009513 default:
9514 alc_automute_amp_unsol_event(codec, res);
9515 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009516 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009517}
9518
Jiang zhefb97dc62008-03-06 11:07:11 +01009519/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009520static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009521{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009522 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009523
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009524 spec->autocfg.hp_pins[0] = 0x14;
9525 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009526}
9527
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009528static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009529{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009530 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009531
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009532 spec->autocfg.hp_pins[0] = 0x1b;
9533 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009534}
9535
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009536static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9537{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009538 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009539
Takashi Iwai47fd8302007-08-10 17:11:07 +02009540 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9541 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009542}
9543
9544static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9545{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009546 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009547
Takashi Iwai47fd8302007-08-10 17:11:07 +02009548 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9549 HDA_AMP_MUTE, bits);
9550 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9551 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009552}
9553
9554static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9555 unsigned int res)
9556{
9557 if ((res >> 26) == ALC880_HP_EVENT)
9558 alc883_lenovo_101e_all_automute(codec);
9559 if ((res >> 26) == ALC880_FRONT_EVENT)
9560 alc883_lenovo_101e_ispeaker_automute(codec);
9561}
9562
Takashi Iwai676a9b52007-08-16 15:23:35 +02009563/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009564static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009565{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009566 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009567
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009568 spec->autocfg.hp_pins[0] = 0x14;
9569 spec->autocfg.speaker_pins[0] = 0x15;
9570 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009571}
9572
Kailang Yangd1a991a2007-08-15 16:21:59 +02009573static struct hda_verb alc883_acer_eapd_verbs[] = {
9574 /* HP Pin: output 0 (0x0c) */
9575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9577 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9578 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009579 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9580 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009581 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009582 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9583 /* eanable EAPD on medion laptop */
9584 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9585 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009586 /* enable unsolicited event */
9587 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009588 { }
9589};
9590
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009591static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009592{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009593 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009594
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009595 spec->autocfg.hp_pins[0] = 0x1b;
9596 spec->autocfg.speaker_pins[0] = 0x14;
9597 spec->autocfg.speaker_pins[1] = 0x15;
9598 spec->autocfg.speaker_pins[2] = 0x16;
9599 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009600}
9601
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009602static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009603{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009604 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009605
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009606 spec->autocfg.hp_pins[0] = 0x1b;
9607 spec->autocfg.speaker_pins[0] = 0x14;
9608 spec->autocfg.speaker_pins[1] = 0x15;
9609 spec->autocfg.speaker_pins[2] = 0x16;
9610 spec->autocfg.speaker_pins[3] = 0x17;
9611 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009612}
9613
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009614static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02009615{
9616 struct alc_spec *spec = codec->spec;
9617
9618 spec->autocfg.hp_pins[0] = 0x15;
9619 spec->autocfg.speaker_pins[0] = 0x14;
9620 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c52009-06-05 00:47:26 +02009621}
9622
Kailang Yange2757d52008-08-26 13:17:46 +02009623static struct hda_verb alc888_asus_m90v_verbs[] = {
9624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9626 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9627 /* enable unsolicited event */
9628 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9629 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9630 { } /* end */
9631};
9632
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009633static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009634{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009635 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009636
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009637 spec->autocfg.hp_pins[0] = 0x1b;
9638 spec->autocfg.speaker_pins[0] = 0x14;
9639 spec->autocfg.speaker_pins[1] = 0x15;
9640 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009641 spec->ext_mic.pin = 0x18;
9642 spec->int_mic.pin = 0x19;
9643 spec->ext_mic.mux_idx = 0;
9644 spec->int_mic.mux_idx = 1;
9645 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009646}
9647
9648static struct hda_verb alc888_asus_eee1601_verbs[] = {
9649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9654 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9655 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9656 /* enable unsolicited event */
9657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9658 { } /* end */
9659};
9660
Kailang Yange2757d52008-08-26 13:17:46 +02009661static void alc883_eee1601_inithook(struct hda_codec *codec)
9662{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009663 struct alc_spec *spec = codec->spec;
9664
9665 spec->autocfg.hp_pins[0] = 0x14;
9666 spec->autocfg.speaker_pins[0] = 0x1b;
9667 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009668}
9669
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009670static struct hda_verb alc889A_mb31_verbs[] = {
9671 /* Init rear pin (used as headphone output) */
9672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9673 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9674 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9675 /* Init line pin (used as output in 4ch and 6ch mode) */
9676 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9677 /* Init line 2 pin (used as headphone out by default) */
9678 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9680 { } /* end */
9681};
9682
9683/* Mute speakers according to the headphone jack state */
9684static void alc889A_mb31_automute(struct hda_codec *codec)
9685{
9686 unsigned int present;
9687
9688 /* Mute only in 2ch or 4ch mode */
9689 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9690 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009691 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009692 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9693 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9694 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9695 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9696 }
9697}
9698
9699static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9700{
9701 if ((res >> 26) == ALC880_HP_EVENT)
9702 alc889A_mb31_automute(codec);
9703}
9704
Takashi Iwai4953550a2009-06-30 15:28:30 +02009705
Takashi Iwaicb53c622007-08-10 17:21:45 +02009706#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009707#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009708#endif
9709
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009710/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009711#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9712#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9713#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9714#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9715
9716static hda_nid_t alc883_slave_dig_outs[] = {
9717 ALC1200_DIGOUT_NID, 0,
9718};
9719
9720static hda_nid_t alc1200_slave_dig_outs[] = {
9721 ALC883_DIGOUT_NID, 0,
9722};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009723
9724/*
9725 * configuration and preset
9726 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009727static const char *alc882_models[ALC882_MODEL_LAST] = {
9728 [ALC882_3ST_DIG] = "3stack-dig",
9729 [ALC882_6ST_DIG] = "6stack-dig",
9730 [ALC882_ARIMA] = "arima",
9731 [ALC882_W2JC] = "w2jc",
9732 [ALC882_TARGA] = "targa",
9733 [ALC882_ASUS_A7J] = "asus-a7j",
9734 [ALC882_ASUS_A7M] = "asus-a7m",
9735 [ALC885_MACPRO] = "macpro",
9736 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009737 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009738 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009739 [ALC885_MBP3] = "mbp3",
9740 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009741 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009742 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009743 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9744 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009745 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009746 [ALC883_TARGA_DIG] = "targa-dig",
9747 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009748 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009749 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009750 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009751 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009752 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009753 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009754 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009755 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009756 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009757 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009758 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009759 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9760 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009761 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009762 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009763 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009764 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009765 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309766 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009767 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009768 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009769 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009770 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009771 [ALC889A_INTEL] = "intel-alc889a",
9772 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009773 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009774 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02009775 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009776 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009777};
9778
Takashi Iwai4953550a2009-06-30 15:28:30 +02009779static struct snd_pci_quirk alc882_cfg_tbl[] = {
9780 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9781
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009782 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009783 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009784 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009785 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9786 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009787 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009788 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9789 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009790 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009791 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009792 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9793 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009794 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9795 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009796 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9797 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009798 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009799 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009800 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009801 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009802 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9803 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009804 /* default Acer -- disabled as it causes more problems.
9805 * model=auto should work fine now
9806 */
9807 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009808
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009809 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009810
Tobin Davisfebe3372007-06-12 11:27:46 +02009811 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009812 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9813 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009814 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009815 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009816 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009817
9818 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9819 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9820 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009821 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009822 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9823 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9824 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009825 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009826 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009827 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009828 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009829
9830 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009831 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009832 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009833 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009834 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9835 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009836 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009837 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009838 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9839
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009840 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9841 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9842 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009843 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009844 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009845 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009846 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009847 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009848 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9849 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9850 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9851 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9852 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9853 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009854 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009855 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9856 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9857 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009858 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009859 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009860 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9861 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009862 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009863 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009864 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009865 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009866 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009867 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009868 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009869 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009870 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009871
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009872 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009873 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009874 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9875 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309876 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009877 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009878 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009879 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009880 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009881 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009882 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009883 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009884 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009885 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009886 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009887 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9888 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009889 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009890 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009891 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009892 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009893
Jiang zhe17bba1b2008-06-04 12:11:07 +02009894 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9895 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009896 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009897 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9898 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9899 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009900 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009901
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009902 {}
9903};
9904
Takashi Iwai4953550a2009-06-30 15:28:30 +02009905/* codec SSID table for Intel Mac */
9906static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9907 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9908 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9909 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9910 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9911 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9912 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9913 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009914 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009915 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009916 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009917 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009918 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9919 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9920 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009921 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009922 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009923 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009924 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9925 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009926 */
9927 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009928 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009929 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009930 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009931};
9932
Takashi Iwai4953550a2009-06-30 15:28:30 +02009933static struct alc_config_preset alc882_presets[] = {
9934 [ALC882_3ST_DIG] = {
9935 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009936 .init_verbs = { alc882_base_init_verbs,
9937 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009938 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9939 .dac_nids = alc882_dac_nids,
9940 .dig_out_nid = ALC882_DIGOUT_NID,
9941 .dig_in_nid = ALC882_DIGIN_NID,
9942 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9943 .channel_mode = alc882_ch_modes,
9944 .need_dac_fix = 1,
9945 .input_mux = &alc882_capture_source,
9946 },
9947 [ALC882_6ST_DIG] = {
9948 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009949 .init_verbs = { alc882_base_init_verbs,
9950 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009951 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9952 .dac_nids = alc882_dac_nids,
9953 .dig_out_nid = ALC882_DIGOUT_NID,
9954 .dig_in_nid = ALC882_DIGIN_NID,
9955 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9956 .channel_mode = alc882_sixstack_modes,
9957 .input_mux = &alc882_capture_source,
9958 },
9959 [ALC882_ARIMA] = {
9960 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009961 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9962 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009963 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9964 .dac_nids = alc882_dac_nids,
9965 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9966 .channel_mode = alc882_sixstack_modes,
9967 .input_mux = &alc882_capture_source,
9968 },
9969 [ALC882_W2JC] = {
9970 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009971 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9972 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009973 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9974 .dac_nids = alc882_dac_nids,
9975 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9976 .channel_mode = alc880_threestack_modes,
9977 .need_dac_fix = 1,
9978 .input_mux = &alc882_capture_source,
9979 .dig_out_nid = ALC882_DIGOUT_NID,
9980 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009981 [ALC885_MBA21] = {
9982 .mixers = { alc885_mba21_mixer },
9983 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9984 .num_dacs = 2,
9985 .dac_nids = alc882_dac_nids,
9986 .channel_mode = alc885_mba21_ch_modes,
9987 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9988 .input_mux = &alc882_capture_source,
9989 .unsol_event = alc_automute_amp_unsol_event,
9990 .setup = alc885_mba21_setup,
9991 .init_hook = alc_automute_amp,
9992 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009993 [ALC885_MBP3] = {
9994 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9995 .init_verbs = { alc885_mbp3_init_verbs,
9996 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009997 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009998 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009999 .hp_nid = 0x04,
10000 .channel_mode = alc885_mbp_4ch_modes,
10001 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010002 .input_mux = &alc882_capture_source,
10003 .dig_out_nid = ALC882_DIGOUT_NID,
10004 .dig_in_nid = ALC882_DIGIN_NID,
10005 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010006 .setup = alc885_mbp3_setup,
10007 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010008 },
10009 [ALC885_MB5] = {
10010 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10011 .init_verbs = { alc885_mb5_init_verbs,
10012 alc880_gpio1_init_verbs },
10013 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10014 .dac_nids = alc882_dac_nids,
10015 .channel_mode = alc885_mb5_6ch_modes,
10016 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10017 .input_mux = &mb5_capture_source,
10018 .dig_out_nid = ALC882_DIGOUT_NID,
10019 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010020 .unsol_event = alc_automute_amp_unsol_event,
10021 .setup = alc885_mb5_setup,
10022 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010023 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010024 [ALC885_MACMINI3] = {
10025 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10026 .init_verbs = { alc885_macmini3_init_verbs,
10027 alc880_gpio1_init_verbs },
10028 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10029 .dac_nids = alc882_dac_nids,
10030 .channel_mode = alc885_macmini3_6ch_modes,
10031 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10032 .input_mux = &macmini3_capture_source,
10033 .dig_out_nid = ALC882_DIGOUT_NID,
10034 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010035 .unsol_event = alc_automute_amp_unsol_event,
10036 .setup = alc885_macmini3_setup,
10037 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010038 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010039 [ALC885_MACPRO] = {
10040 .mixers = { alc882_macpro_mixer },
10041 .init_verbs = { alc882_macpro_init_verbs },
10042 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10043 .dac_nids = alc882_dac_nids,
10044 .dig_out_nid = ALC882_DIGOUT_NID,
10045 .dig_in_nid = ALC882_DIGIN_NID,
10046 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10047 .channel_mode = alc882_ch_modes,
10048 .input_mux = &alc882_capture_source,
10049 .init_hook = alc885_macpro_init_hook,
10050 },
10051 [ALC885_IMAC24] = {
10052 .mixers = { alc885_imac24_mixer },
10053 .init_verbs = { alc885_imac24_init_verbs },
10054 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10055 .dac_nids = alc882_dac_nids,
10056 .dig_out_nid = ALC882_DIGOUT_NID,
10057 .dig_in_nid = ALC882_DIGIN_NID,
10058 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10059 .channel_mode = alc882_ch_modes,
10060 .input_mux = &alc882_capture_source,
10061 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010062 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010063 .init_hook = alc885_imac24_init_hook,
10064 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010065 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010066 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010067 .init_verbs = { alc885_imac91_init_verbs,
10068 alc880_gpio1_init_verbs },
10069 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10070 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010071 .channel_mode = alc885_mba21_ch_modes,
10072 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10073 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010074 .dig_out_nid = ALC882_DIGOUT_NID,
10075 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010076 .unsol_event = alc_automute_amp_unsol_event,
10077 .setup = alc885_imac91_setup,
10078 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010079 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010080 [ALC882_TARGA] = {
10081 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010082 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010083 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010084 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10085 .dac_nids = alc882_dac_nids,
10086 .dig_out_nid = ALC882_DIGOUT_NID,
10087 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10088 .adc_nids = alc882_adc_nids,
10089 .capsrc_nids = alc882_capsrc_nids,
10090 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10091 .channel_mode = alc882_3ST_6ch_modes,
10092 .need_dac_fix = 1,
10093 .input_mux = &alc882_capture_source,
10094 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010095 .setup = alc882_targa_setup,
10096 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010097 },
10098 [ALC882_ASUS_A7J] = {
10099 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010100 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10101 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010102 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10103 .dac_nids = alc882_dac_nids,
10104 .dig_out_nid = ALC882_DIGOUT_NID,
10105 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10106 .adc_nids = alc882_adc_nids,
10107 .capsrc_nids = alc882_capsrc_nids,
10108 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10109 .channel_mode = alc882_3ST_6ch_modes,
10110 .need_dac_fix = 1,
10111 .input_mux = &alc882_capture_source,
10112 },
10113 [ALC882_ASUS_A7M] = {
10114 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010115 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10116 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010117 alc882_asus_a7m_verbs },
10118 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10119 .dac_nids = alc882_dac_nids,
10120 .dig_out_nid = ALC882_DIGOUT_NID,
10121 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10122 .channel_mode = alc880_threestack_modes,
10123 .need_dac_fix = 1,
10124 .input_mux = &alc882_capture_source,
10125 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010126 [ALC883_3ST_2ch_DIG] = {
10127 .mixers = { alc883_3ST_2ch_mixer },
10128 .init_verbs = { alc883_init_verbs },
10129 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10130 .dac_nids = alc883_dac_nids,
10131 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010132 .dig_in_nid = ALC883_DIGIN_NID,
10133 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10134 .channel_mode = alc883_3ST_2ch_modes,
10135 .input_mux = &alc883_capture_source,
10136 },
10137 [ALC883_3ST_6ch_DIG] = {
10138 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10139 .init_verbs = { alc883_init_verbs },
10140 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10141 .dac_nids = alc883_dac_nids,
10142 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010143 .dig_in_nid = ALC883_DIGIN_NID,
10144 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10145 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010146 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010147 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010148 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010149 [ALC883_3ST_6ch] = {
10150 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10151 .init_verbs = { alc883_init_verbs },
10152 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10153 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010154 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10155 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010156 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010157 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010158 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010159 [ALC883_3ST_6ch_INTEL] = {
10160 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10161 .init_verbs = { alc883_init_verbs },
10162 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10163 .dac_nids = alc883_dac_nids,
10164 .dig_out_nid = ALC883_DIGOUT_NID,
10165 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010166 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010167 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10168 .channel_mode = alc883_3ST_6ch_intel_modes,
10169 .need_dac_fix = 1,
10170 .input_mux = &alc883_3stack_6ch_intel,
10171 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010172 [ALC889A_INTEL] = {
10173 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010174 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10175 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010176 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10177 .dac_nids = alc883_dac_nids,
10178 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10179 .adc_nids = alc889_adc_nids,
10180 .dig_out_nid = ALC883_DIGOUT_NID,
10181 .dig_in_nid = ALC883_DIGIN_NID,
10182 .slave_dig_outs = alc883_slave_dig_outs,
10183 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10184 .channel_mode = alc889_8ch_intel_modes,
10185 .capsrc_nids = alc889_capsrc_nids,
10186 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010187 .setup = alc889_automute_setup,
10188 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010189 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010190 .need_dac_fix = 1,
10191 },
10192 [ALC889_INTEL] = {
10193 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10194 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010195 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010196 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10197 .dac_nids = alc883_dac_nids,
10198 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10199 .adc_nids = alc889_adc_nids,
10200 .dig_out_nid = ALC883_DIGOUT_NID,
10201 .dig_in_nid = ALC883_DIGIN_NID,
10202 .slave_dig_outs = alc883_slave_dig_outs,
10203 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10204 .channel_mode = alc889_8ch_intel_modes,
10205 .capsrc_nids = alc889_capsrc_nids,
10206 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010207 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010208 .init_hook = alc889_intel_init_hook,
10209 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010210 .need_dac_fix = 1,
10211 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010212 [ALC883_6ST_DIG] = {
10213 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10214 .init_verbs = { alc883_init_verbs },
10215 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10216 .dac_nids = alc883_dac_nids,
10217 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010218 .dig_in_nid = ALC883_DIGIN_NID,
10219 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10220 .channel_mode = alc883_sixstack_modes,
10221 .input_mux = &alc883_capture_source,
10222 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010223 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010224 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010225 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10226 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010227 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10228 .dac_nids = alc883_dac_nids,
10229 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010230 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10231 .channel_mode = alc883_3ST_6ch_modes,
10232 .need_dac_fix = 1,
10233 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010234 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010235 .setup = alc882_targa_setup,
10236 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010237 },
10238 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010239 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010240 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10241 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010242 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10243 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010244 .adc_nids = alc883_adc_nids_alt,
10245 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010246 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010247 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010248 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10249 .channel_mode = alc883_3ST_2ch_modes,
10250 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010251 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010252 .setup = alc882_targa_setup,
10253 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010254 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010255 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010256 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10257 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010258 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010259 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010260 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10261 .dac_nids = alc883_dac_nids,
10262 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10263 .adc_nids = alc883_adc_nids_rev,
10264 .capsrc_nids = alc883_capsrc_nids_rev,
10265 .dig_out_nid = ALC883_DIGOUT_NID,
10266 .dig_in_nid = ALC883_DIGIN_NID,
10267 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10268 .channel_mode = alc883_4ST_8ch_modes,
10269 .need_dac_fix = 1,
10270 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010271 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010272 .setup = alc882_targa_setup,
10273 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010274 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010275 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010276 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010277 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10278 * and the headphone jack. Turn this on and rely on the
10279 * standard mute methods whenever the user wants to turn
10280 * these outputs off.
10281 */
10282 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10283 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10284 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010285 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10286 .channel_mode = alc883_3ST_2ch_modes,
10287 .input_mux = &alc883_capture_source,
10288 },
Tobin Davis2880a862007-08-07 11:50:26 +020010289 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010290 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010291 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010292 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10293 .dac_nids = alc883_dac_nids,
10294 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010295 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10296 .channel_mode = alc883_3ST_2ch_modes,
10297 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010298 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010299 .setup = alc883_acer_aspire_setup,
10300 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010301 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010302 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010303 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010304 alc883_chmode_mixer },
10305 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10306 alc888_acer_aspire_4930g_verbs },
10307 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10308 .dac_nids = alc883_dac_nids,
10309 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10310 .adc_nids = alc883_adc_nids_rev,
10311 .capsrc_nids = alc883_capsrc_nids_rev,
10312 .dig_out_nid = ALC883_DIGOUT_NID,
10313 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10314 .channel_mode = alc883_3ST_6ch_modes,
10315 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010316 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010317 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010318 ARRAY_SIZE(alc888_2_capture_sources),
10319 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010320 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010321 .setup = alc888_acer_aspire_4930g_setup,
10322 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010323 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010324 [ALC888_ACER_ASPIRE_6530G] = {
10325 .mixers = { alc888_acer_aspire_6530_mixer },
10326 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10327 alc888_acer_aspire_6530g_verbs },
10328 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10329 .dac_nids = alc883_dac_nids,
10330 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10331 .adc_nids = alc883_adc_nids_rev,
10332 .capsrc_nids = alc883_capsrc_nids_rev,
10333 .dig_out_nid = ALC883_DIGOUT_NID,
10334 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10335 .channel_mode = alc883_3ST_2ch_modes,
10336 .num_mux_defs =
10337 ARRAY_SIZE(alc888_2_capture_sources),
10338 .input_mux = alc888_acer_aspire_6530_sources,
10339 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010340 .setup = alc888_acer_aspire_6530g_setup,
10341 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010342 },
Hector Martin3b315d72009-06-02 10:54:19 +020010343 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010344 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010345 alc883_chmode_mixer },
10346 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010347 alc889_acer_aspire_8930g_verbs,
10348 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010349 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10350 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010351 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10352 .adc_nids = alc889_adc_nids,
10353 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010354 .dig_out_nid = ALC883_DIGOUT_NID,
10355 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10356 .channel_mode = alc883_3ST_6ch_modes,
10357 .need_dac_fix = 1,
10358 .const_channel_count = 6,
10359 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010360 ARRAY_SIZE(alc889_capture_sources),
10361 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010362 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010363 .setup = alc889_acer_aspire_8930g_setup,
10364 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010365#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010366 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010367#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010368 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010369 [ALC888_ACER_ASPIRE_7730G] = {
10370 .mixers = { alc883_3ST_6ch_mixer,
10371 alc883_chmode_mixer },
10372 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10373 alc888_acer_aspire_7730G_verbs },
10374 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10375 .dac_nids = alc883_dac_nids,
10376 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10377 .adc_nids = alc883_adc_nids_rev,
10378 .capsrc_nids = alc883_capsrc_nids_rev,
10379 .dig_out_nid = ALC883_DIGOUT_NID,
10380 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10381 .channel_mode = alc883_3ST_6ch_modes,
10382 .need_dac_fix = 1,
10383 .const_channel_count = 6,
10384 .input_mux = &alc883_capture_source,
10385 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010386 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010387 .init_hook = alc_automute_amp,
10388 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010389 [ALC883_MEDION] = {
10390 .mixers = { alc883_fivestack_mixer,
10391 alc883_chmode_mixer },
10392 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010393 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010394 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10395 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010396 .adc_nids = alc883_adc_nids_alt,
10397 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010398 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010399 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10400 .channel_mode = alc883_sixstack_modes,
10401 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010402 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010403 [ALC883_MEDION_WIM2160] = {
10404 .mixers = { alc883_medion_wim2160_mixer },
10405 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10406 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10407 .dac_nids = alc883_dac_nids,
10408 .dig_out_nid = ALC883_DIGOUT_NID,
10409 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10410 .adc_nids = alc883_adc_nids,
10411 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10412 .channel_mode = alc883_3ST_2ch_modes,
10413 .input_mux = &alc883_capture_source,
10414 .unsol_event = alc_automute_amp_unsol_event,
10415 .setup = alc883_medion_wim2160_setup,
10416 .init_hook = alc_automute_amp,
10417 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010418 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010419 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010420 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10421 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10422 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010423 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10424 .channel_mode = alc883_3ST_2ch_modes,
10425 .input_mux = &alc883_capture_source,
10426 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010427 [ALC883_CLEVO_M540R] = {
10428 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10429 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10431 .dac_nids = alc883_dac_nids,
10432 .dig_out_nid = ALC883_DIGOUT_NID,
10433 .dig_in_nid = ALC883_DIGIN_NID,
10434 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10435 .channel_mode = alc883_3ST_6ch_clevo_modes,
10436 .need_dac_fix = 1,
10437 .input_mux = &alc883_capture_source,
10438 /* This machine has the hardware HP auto-muting, thus
10439 * we need no software mute via unsol event
10440 */
10441 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010442 [ALC883_CLEVO_M720] = {
10443 .mixers = { alc883_clevo_m720_mixer },
10444 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010445 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10446 .dac_nids = alc883_dac_nids,
10447 .dig_out_nid = ALC883_DIGOUT_NID,
10448 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10449 .channel_mode = alc883_3ST_2ch_modes,
10450 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010451 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010452 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010453 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010454 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010455 [ALC883_LENOVO_101E_2ch] = {
10456 .mixers = { alc883_lenovo_101e_2ch_mixer},
10457 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10458 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10459 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010460 .adc_nids = alc883_adc_nids_alt,
10461 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010462 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010463 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10464 .channel_mode = alc883_3ST_2ch_modes,
10465 .input_mux = &alc883_lenovo_101e_capture_source,
10466 .unsol_event = alc883_lenovo_101e_unsol_event,
10467 .init_hook = alc883_lenovo_101e_all_automute,
10468 },
Kailang Yang272a5272007-05-14 11:00:38 +020010469 [ALC883_LENOVO_NB0763] = {
10470 .mixers = { alc883_lenovo_nb0763_mixer },
10471 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10472 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10473 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010474 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10475 .channel_mode = alc883_3ST_2ch_modes,
10476 .need_dac_fix = 1,
10477 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010478 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010479 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010480 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010481 },
10482 [ALC888_LENOVO_MS7195_DIG] = {
10483 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10484 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10485 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10486 .dac_nids = alc883_dac_nids,
10487 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010488 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10489 .channel_mode = alc883_3ST_6ch_modes,
10490 .need_dac_fix = 1,
10491 .input_mux = &alc883_capture_source,
10492 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10493 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010494 },
10495 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010496 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010497 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10499 .dac_nids = alc883_dac_nids,
10500 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010501 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10502 .channel_mode = alc883_3ST_2ch_modes,
10503 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010504 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010505 .setup = alc883_haier_w66_setup,
10506 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010507 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010508 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010509 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010510 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10512 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010513 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10514 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010515 .need_dac_fix = 1,
10516 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010517 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010518 .setup = alc888_3st_hp_setup,
10519 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010520 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010521 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010522 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010523 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10524 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10525 .dac_nids = alc883_dac_nids,
10526 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010527 .dig_in_nid = ALC883_DIGIN_NID,
10528 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10529 .channel_mode = alc883_sixstack_modes,
10530 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010531 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010532 .setup = alc888_6st_dell_setup,
10533 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010534 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010535 [ALC883_MITAC] = {
10536 .mixers = { alc883_mitac_mixer },
10537 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10538 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10539 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010540 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10541 .channel_mode = alc883_3ST_2ch_modes,
10542 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010543 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010544 .setup = alc883_mitac_setup,
10545 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010546 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010547 [ALC883_FUJITSU_PI2515] = {
10548 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10549 .init_verbs = { alc883_init_verbs,
10550 alc883_2ch_fujitsu_pi2515_verbs},
10551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10552 .dac_nids = alc883_dac_nids,
10553 .dig_out_nid = ALC883_DIGOUT_NID,
10554 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10555 .channel_mode = alc883_3ST_2ch_modes,
10556 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010557 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010558 .setup = alc883_2ch_fujitsu_pi2515_setup,
10559 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010560 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010561 [ALC888_FUJITSU_XA3530] = {
10562 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10563 .init_verbs = { alc883_init_verbs,
10564 alc888_fujitsu_xa3530_verbs },
10565 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10566 .dac_nids = alc883_dac_nids,
10567 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10568 .adc_nids = alc883_adc_nids_rev,
10569 .capsrc_nids = alc883_capsrc_nids_rev,
10570 .dig_out_nid = ALC883_DIGOUT_NID,
10571 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10572 .channel_mode = alc888_4ST_8ch_intel_modes,
10573 .num_mux_defs =
10574 ARRAY_SIZE(alc888_2_capture_sources),
10575 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010576 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010577 .setup = alc888_fujitsu_xa3530_setup,
10578 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010579 },
Kailang Yange2757d52008-08-26 13:17:46 +020010580 [ALC888_LENOVO_SKY] = {
10581 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10582 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10583 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10584 .dac_nids = alc883_dac_nids,
10585 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010586 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10587 .channel_mode = alc883_sixstack_modes,
10588 .need_dac_fix = 1,
10589 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010590 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010591 .setup = alc888_lenovo_sky_setup,
10592 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010593 },
10594 [ALC888_ASUS_M90V] = {
10595 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10596 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10597 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10598 .dac_nids = alc883_dac_nids,
10599 .dig_out_nid = ALC883_DIGOUT_NID,
10600 .dig_in_nid = ALC883_DIGIN_NID,
10601 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10602 .channel_mode = alc883_3ST_6ch_modes,
10603 .need_dac_fix = 1,
10604 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010605 .unsol_event = alc_sku_unsol_event,
10606 .setup = alc883_mode2_setup,
10607 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010608 },
10609 [ALC888_ASUS_EEE1601] = {
10610 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010611 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010612 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10613 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10614 .dac_nids = alc883_dac_nids,
10615 .dig_out_nid = ALC883_DIGOUT_NID,
10616 .dig_in_nid = ALC883_DIGIN_NID,
10617 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10618 .channel_mode = alc883_3ST_2ch_modes,
10619 .need_dac_fix = 1,
10620 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010621 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010622 .init_hook = alc883_eee1601_inithook,
10623 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010624 [ALC1200_ASUS_P5Q] = {
10625 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10626 .init_verbs = { alc883_init_verbs },
10627 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10628 .dac_nids = alc883_dac_nids,
10629 .dig_out_nid = ALC1200_DIGOUT_NID,
10630 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010631 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010632 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10633 .channel_mode = alc883_sixstack_modes,
10634 .input_mux = &alc883_capture_source,
10635 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010636 [ALC889A_MB31] = {
10637 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10638 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10639 alc880_gpio1_init_verbs },
10640 .adc_nids = alc883_adc_nids,
10641 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010642 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010643 .dac_nids = alc883_dac_nids,
10644 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10645 .channel_mode = alc889A_mb31_6ch_modes,
10646 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10647 .input_mux = &alc889A_mb31_capture_source,
10648 .dig_out_nid = ALC883_DIGOUT_NID,
10649 .unsol_event = alc889A_mb31_unsol_event,
10650 .init_hook = alc889A_mb31_automute,
10651 },
Guido Günther3e1647c52009-06-05 00:47:26 +020010652 [ALC883_SONY_VAIO_TT] = {
10653 .mixers = { alc883_vaiott_mixer },
10654 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10655 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10656 .dac_nids = alc883_dac_nids,
10657 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10658 .channel_mode = alc883_3ST_2ch_modes,
10659 .input_mux = &alc883_capture_source,
10660 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010661 .setup = alc883_vaiott_setup,
10662 .init_hook = alc_automute_amp,
Guido Günther3e1647c52009-06-05 00:47:26 +020010663 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010664};
10665
10666
10667/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010668 * Pin config fixes
10669 */
10670enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010671 PINFIX_ABIT_AW9D_MAX,
10672 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010673 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010674};
10675
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010676static const struct alc_fixup alc882_fixups[] = {
10677 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010678 .pins = (const struct alc_pincfg[]) {
10679 { 0x15, 0x01080104 }, /* side */
10680 { 0x16, 0x01011012 }, /* rear */
10681 { 0x17, 0x01016011 }, /* clfe */
10682 { }
10683 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010684 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010685 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010686 .verbs = (const struct hda_verb[]) {
10687 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10688 {}
10689 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010690 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010691 [PINFIX_ACER_ASPIRE_7736] = {
10692 .sku = ALC_FIXUP_SKU_IGNORE,
10693 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010694};
10695
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010696static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010697 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010698 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010699 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010700 {}
10701};
10702
10703/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010704 * BIOS auto configuration
10705 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010706static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10707 const struct auto_pin_cfg *cfg)
10708{
10709 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10710}
10711
Takashi Iwai4953550a2009-06-30 15:28:30 +020010712static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010713 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010714 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010715{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010716 int idx;
10717
Takashi Iwai489008c2010-04-07 09:06:00 +020010718 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010719 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010720
Takashi Iwai489008c2010-04-07 09:06:00 +020010721 if (dac == 0x25)
10722 idx = 4;
10723 else if (dac >= 0x02 && dac <= 0x05)
10724 idx = dac - 2;
10725 else
10726 return;
10727 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010728}
10729
Takashi Iwai4953550a2009-06-30 15:28:30 +020010730static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010731{
10732 struct alc_spec *spec = codec->spec;
10733 int i;
10734
10735 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010736 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010737 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010738 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010739 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010740 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010741 }
10742}
10743
Takashi Iwai4953550a2009-06-30 15:28:30 +020010744static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010745{
10746 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010747 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010748 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010749
Takashi Iwai5855fb82010-09-16 18:24:02 +020010750 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10751 pin = spec->autocfg.hp_pins[i];
10752 if (!pin)
10753 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010754 dac = spec->multiout.hp_nid;
10755 if (!dac)
10756 dac = spec->multiout.dac_nids[0]; /* to front */
10757 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10758 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010759 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10760 pin = spec->autocfg.speaker_pins[i];
10761 if (!pin)
10762 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010763 dac = spec->multiout.extra_out_nid[0];
10764 if (!dac)
10765 dac = spec->multiout.dac_nids[0]; /* to front */
10766 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10767 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010768}
10769
Takashi Iwai4953550a2009-06-30 15:28:30 +020010770static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010771{
10772 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010773 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010774 int i;
10775
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010776 for (i = 0; i < cfg->num_inputs; i++) {
10777 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010778 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010779 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10780 snd_hda_codec_write(codec, nid, 0,
10781 AC_VERB_SET_AMP_GAIN_MUTE,
10782 AMP_OUT_MUTE);
10783 }
10784}
10785
10786static void alc882_auto_init_input_src(struct hda_codec *codec)
10787{
10788 struct alc_spec *spec = codec->spec;
10789 int c;
10790
10791 for (c = 0; c < spec->num_adc_nids; c++) {
10792 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10793 hda_nid_t nid = spec->capsrc_nids[c];
10794 unsigned int mux_idx;
10795 const struct hda_input_mux *imux;
10796 int conns, mute, idx, item;
10797
10798 conns = snd_hda_get_connections(codec, nid, conn_list,
10799 ARRAY_SIZE(conn_list));
10800 if (conns < 0)
10801 continue;
10802 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10803 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010804 if (!imux->num_items && mux_idx > 0)
10805 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010806 for (idx = 0; idx < conns; idx++) {
10807 /* if the current connection is the selected one,
10808 * unmute it as default - otherwise mute it
10809 */
10810 mute = AMP_IN_MUTE(idx);
10811 for (item = 0; item < imux->num_items; item++) {
10812 if (imux->items[item].index == idx) {
10813 if (spec->cur_mux[c] == item)
10814 mute = AMP_IN_UNMUTE(idx);
10815 break;
10816 }
10817 }
10818 /* check if we have a selector or mixer
10819 * we could check for the widget type instead, but
10820 * just check for Amp-In presence (in case of mixer
10821 * without amp-in there is something wrong, this
10822 * function shouldn't be used or capsrc nid is wrong)
10823 */
10824 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010825 snd_hda_codec_write(codec, nid, 0,
10826 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010827 mute);
10828 else if (mute != AMP_IN_MUTE(idx))
10829 snd_hda_codec_write(codec, nid, 0,
10830 AC_VERB_SET_CONNECT_SEL,
10831 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010832 }
10833 }
10834}
10835
Takashi Iwai4953550a2009-06-30 15:28:30 +020010836/* add mic boosts if needed */
10837static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010838{
10839 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010840 struct auto_pin_cfg *cfg = &spec->autocfg;
10841 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010842 hda_nid_t nid;
10843
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010844 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010845 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010846 break;
10847 nid = cfg->inputs[i].pin;
10848 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010849 char label[32];
10850 snprintf(label, sizeof(label), "%s Boost",
10851 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010852 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010853 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010854 if (err < 0)
10855 return err;
10856 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010857 }
10858 return 0;
10859}
10860
10861/* almost identical with ALC880 parser... */
10862static int alc882_parse_auto_config(struct hda_codec *codec)
10863{
10864 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010865 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010866 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010867
Takashi Iwai05f5f472009-08-25 13:10:18 +020010868 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10869 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010870 if (err < 0)
10871 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010872 if (!spec->autocfg.line_outs)
10873 return 0; /* can't find valid BIOS pin config */
10874
10875 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10876 if (err < 0)
10877 return err;
10878 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10879 if (err < 0)
10880 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010881 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10882 "Headphone");
10883 if (err < 0)
10884 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010885 err = alc880_auto_create_extra_out(spec,
10886 spec->autocfg.speaker_pins[0],
10887 "Speaker");
10888 if (err < 0)
10889 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010890 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10891 if (err < 0)
10892 return err;
10893
10894 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10895
Takashi Iwai757899a2010-07-30 10:48:14 +020010896 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010897
10898 if (spec->kctls.list)
10899 add_mixer(spec, spec->kctls.list);
10900
10901 add_verb(spec, alc883_auto_init_verbs);
10902 /* if ADC 0x07 is available, initialize it, too */
10903 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10904 add_verb(spec, alc882_adc1_init_verbs);
10905
10906 spec->num_mux_defs = 1;
10907 spec->input_mux = &spec->private_imux[0];
10908
Kailang Yang6227cdc2010-02-25 08:36:52 +010010909 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010910
10911 err = alc_auto_add_mic_boost(codec);
10912 if (err < 0)
10913 return err;
10914
Takashi Iwai776e1842007-08-29 15:07:11 +020010915 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010916}
10917
10918/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010919static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010920{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010921 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010922 alc882_auto_init_multi_out(codec);
10923 alc882_auto_init_hp_out(codec);
10924 alc882_auto_init_analog_input(codec);
10925 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010926 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010927 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010928 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010929}
10930
Takashi Iwai4953550a2009-06-30 15:28:30 +020010931static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010932{
10933 struct alc_spec *spec;
10934 int err, board_config;
10935
10936 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10937 if (spec == NULL)
10938 return -ENOMEM;
10939
10940 codec->spec = spec;
10941
Takashi Iwai4953550a2009-06-30 15:28:30 +020010942 switch (codec->vendor_id) {
10943 case 0x10ec0882:
10944 case 0x10ec0885:
10945 break;
10946 default:
10947 /* ALC883 and variants */
10948 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10949 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010950 }
10951
Takashi Iwai4953550a2009-06-30 15:28:30 +020010952 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10953 alc882_models,
10954 alc882_cfg_tbl);
10955
10956 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10957 board_config = snd_hda_check_board_codec_sid_config(codec,
10958 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10959
10960 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010961 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010962 codec->chip_name);
10963 board_config = ALC882_AUTO;
10964 }
10965
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010966 if (board_config == ALC882_AUTO)
10967 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010968
David Henningsson90622912010-10-14 14:50:18 +020010969 alc_auto_parse_customize_define(codec);
10970
Takashi Iwai4953550a2009-06-30 15:28:30 +020010971 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010972 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010973 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974 if (err < 0) {
10975 alc_free(codec);
10976 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010977 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010978 printk(KERN_INFO
10979 "hda_codec: Cannot set up configuration "
10980 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010981 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010982 }
10983 }
10984
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010985 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010986 err = snd_hda_attach_beep_device(codec, 0x1);
10987 if (err < 0) {
10988 alc_free(codec);
10989 return err;
10990 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010991 }
10992
Takashi Iwai4953550a2009-06-30 15:28:30 +020010993 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010994 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010995
Takashi Iwai4953550a2009-06-30 15:28:30 +020010996 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10997 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10998 /* FIXME: setup DAC5 */
10999 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11000 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11001
11002 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11003 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11004
Takashi Iwai4953550a2009-06-30 15:28:30 +020011005 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011006 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011007 spec->num_adc_nids = 0;
11008 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011009 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011010 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011011 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011012 hda_nid_t nid = alc882_adc_nids[i];
11013 unsigned int wcap = get_wcaps(codec, nid);
11014 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011015 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011016 if (wcap != AC_WID_AUD_IN)
11017 continue;
11018 spec->private_adc_nids[spec->num_adc_nids] = nid;
11019 err = snd_hda_get_connections(codec, nid, &cap, 1);
11020 if (err < 0)
11021 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011022 err = snd_hda_get_connections(codec, cap, items,
11023 ARRAY_SIZE(items));
11024 if (err < 0)
11025 continue;
11026 for (j = 0; j < imux->num_items; j++)
11027 if (imux->items[j].index >= err)
11028 break;
11029 if (j < imux->num_items)
11030 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011031 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11032 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011033 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011034 spec->adc_nids = spec->private_adc_nids;
11035 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011036 }
11037
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011038 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011039
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011040 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011041 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011042
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011043 if (board_config == ALC882_AUTO)
11044 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
11045
Takashi Iwai2134ea42008-01-10 16:53:55 +010011046 spec->vmaster_nid = 0x0c;
11047
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011048 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011049 if (board_config == ALC882_AUTO)
11050 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011051
11052 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011053#ifdef CONFIG_SND_HDA_POWER_SAVE
11054 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011055 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011056#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011057
11058 return 0;
11059}
11060
Takashi Iwai4953550a2009-06-30 15:28:30 +020011061
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011062/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011063 * ALC262 support
11064 */
11065
11066#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11067#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11068
11069#define alc262_dac_nids alc260_dac_nids
11070#define alc262_adc_nids alc882_adc_nids
11071#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011072#define alc262_capsrc_nids alc882_capsrc_nids
11073#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011074
11075#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011076#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011077
Kailang Yang4e555fe2008-08-26 13:05:55 +020011078static hda_nid_t alc262_dmic_adc_nids[1] = {
11079 /* ADC0 */
11080 0x09
11081};
11082
11083static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11084
Kailang Yangdf694da2005-12-05 19:42:22 +010011085static struct snd_kcontrol_new alc262_base_mixer[] = {
11086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11087 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11088 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11089 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11090 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11091 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11092 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011094 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011095 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11096 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011097 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11099 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11100 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11101 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011102 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011103};
11104
Takashi Iwaice875f02008-01-28 18:17:43 +010011105/* update HP, line and mono-out pins according to the master switch */
11106static void alc262_hp_master_update(struct hda_codec *codec)
11107{
11108 struct alc_spec *spec = codec->spec;
11109 int val = spec->master_sw;
11110
11111 /* HP & line-out */
11112 snd_hda_codec_write_cache(codec, 0x1b, 0,
11113 AC_VERB_SET_PIN_WIDGET_CONTROL,
11114 val ? PIN_HP : 0);
11115 snd_hda_codec_write_cache(codec, 0x15, 0,
11116 AC_VERB_SET_PIN_WIDGET_CONTROL,
11117 val ? PIN_HP : 0);
11118 /* mono (speaker) depending on the HP jack sense */
11119 val = val && !spec->jack_present;
11120 snd_hda_codec_write_cache(codec, 0x16, 0,
11121 AC_VERB_SET_PIN_WIDGET_CONTROL,
11122 val ? PIN_OUT : 0);
11123}
11124
11125static void alc262_hp_bpc_automute(struct hda_codec *codec)
11126{
11127 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011128
11129 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011130 alc262_hp_master_update(codec);
11131}
11132
11133static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11134{
11135 if ((res >> 26) != ALC880_HP_EVENT)
11136 return;
11137 alc262_hp_bpc_automute(codec);
11138}
11139
11140static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11141{
11142 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011143
11144 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011145 alc262_hp_master_update(codec);
11146}
11147
11148static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11149 unsigned int res)
11150{
11151 if ((res >> 26) != ALC880_HP_EVENT)
11152 return;
11153 alc262_hp_wildwest_automute(codec);
11154}
11155
Takashi Iwaib72519b2009-05-08 14:31:55 +020011156#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011157
11158static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11159 struct snd_ctl_elem_value *ucontrol)
11160{
11161 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11162 struct alc_spec *spec = codec->spec;
11163 int val = !!*ucontrol->value.integer.value;
11164
11165 if (val == spec->master_sw)
11166 return 0;
11167 spec->master_sw = val;
11168 alc262_hp_master_update(codec);
11169 return 1;
11170}
11171
Takashi Iwaib72519b2009-05-08 14:31:55 +020011172#define ALC262_HP_MASTER_SWITCH \
11173 { \
11174 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11175 .name = "Master Playback Switch", \
11176 .info = snd_ctl_boolean_mono_info, \
11177 .get = alc262_hp_master_sw_get, \
11178 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011179 }, \
11180 { \
11181 .iface = NID_MAPPING, \
11182 .name = "Master Playback Switch", \
11183 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011184 }
11185
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011186
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011187static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011188 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011189 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11190 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011192 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11193 HDA_OUTPUT),
11194 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11195 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011198 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011199 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11200 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011201 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011202 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11203 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11204 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11205 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011206 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11207 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11208 { } /* end */
11209};
11210
Kailang Yangcd7509a2007-01-26 18:33:17 +010011211static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011212 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011213 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11214 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11215 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11216 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011217 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11218 HDA_OUTPUT),
11219 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11220 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011221 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11222 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011223 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11226 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11227 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011228 { } /* end */
11229};
11230
11231static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11232 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11233 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011234 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011235 { } /* end */
11236};
11237
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011238/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011239static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011240{
11241 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011242
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011243 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011244 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011245}
11246
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011247static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011248 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11249 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011250 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11251 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11254 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11255 { } /* end */
11256};
11257
11258static struct hda_verb alc262_hp_t5735_verbs[] = {
11259 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11261
11262 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11263 { }
11264};
11265
Kailang Yang8c427222008-01-10 13:03:59 +010011266static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011267 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11268 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011269 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11270 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011271 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11272 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11273 { } /* end */
11274};
11275
11276static struct hda_verb alc262_hp_rp5700_verbs[] = {
11277 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11278 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11279 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11280 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11281 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11282 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11287 {}
11288};
11289
11290static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11291 .num_items = 1,
11292 .items = {
11293 { "Line", 0x1 },
11294 },
11295};
11296
Takashi Iwai42171c12009-05-08 14:11:43 +020011297/* bind hp and internal speaker mute (with plug check) as master switch */
11298static void alc262_hippo_master_update(struct hda_codec *codec)
11299{
11300 struct alc_spec *spec = codec->spec;
11301 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11302 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11303 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11304 unsigned int mute;
11305
11306 /* HP */
11307 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11308 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11309 HDA_AMP_MUTE, mute);
11310 /* mute internal speaker per jack sense */
11311 if (spec->jack_present)
11312 mute = HDA_AMP_MUTE;
11313 if (line_nid)
11314 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11315 HDA_AMP_MUTE, mute);
11316 if (speaker_nid && speaker_nid != line_nid)
11317 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11318 HDA_AMP_MUTE, mute);
11319}
11320
11321#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11322
11323static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11324 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011325{
11326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011327 struct alc_spec *spec = codec->spec;
11328 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011329
Takashi Iwai42171c12009-05-08 14:11:43 +020011330 if (val == spec->master_sw)
11331 return 0;
11332 spec->master_sw = val;
11333 alc262_hippo_master_update(codec);
11334 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011335}
Takashi Iwai5b319542007-07-26 11:49:22 +020011336
Takashi Iwai42171c12009-05-08 14:11:43 +020011337#define ALC262_HIPPO_MASTER_SWITCH \
11338 { \
11339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11340 .name = "Master Playback Switch", \
11341 .info = snd_ctl_boolean_mono_info, \
11342 .get = alc262_hippo_master_sw_get, \
11343 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011344 }, \
11345 { \
11346 .iface = NID_MAPPING, \
11347 .name = "Master Playback Switch", \
11348 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11349 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011350 }
11351
11352static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11353 ALC262_HIPPO_MASTER_SWITCH,
11354 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11355 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11356 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11357 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11358 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11360 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11362 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11363 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11364 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11365 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11366 { } /* end */
11367};
11368
11369static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11370 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11371 ALC262_HIPPO_MASTER_SWITCH,
11372 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11373 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11374 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11375 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11378 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11379 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11380 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11381 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11382 { } /* end */
11383};
11384
11385/* mute/unmute internal speaker according to the hp jack and mute state */
11386static void alc262_hippo_automute(struct hda_codec *codec)
11387{
11388 struct alc_spec *spec = codec->spec;
11389 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011390
Wu Fengguang864f92b2009-11-18 12:38:02 +080011391 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011392 alc262_hippo_master_update(codec);
11393}
11394
11395static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11396{
11397 if ((res >> 26) != ALC880_HP_EVENT)
11398 return;
11399 alc262_hippo_automute(codec);
11400}
11401
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011402static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011403{
11404 struct alc_spec *spec = codec->spec;
11405
11406 spec->autocfg.hp_pins[0] = 0x15;
11407 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011408}
11409
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011410static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011411{
11412 struct alc_spec *spec = codec->spec;
11413
11414 spec->autocfg.hp_pins[0] = 0x1b;
11415 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011416}
11417
11418
Kailang Yang272a5272007-05-14 11:00:38 +020011419static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011420 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011421 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11424 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11425 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11426 { } /* end */
11427};
11428
Kailang Yang83c34212007-07-05 11:43:05 +020011429static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011430 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11431 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11435 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11436 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11437 { } /* end */
11438};
Kailang Yang272a5272007-05-14 11:00:38 +020011439
Tony Vroonba340e82009-02-02 19:01:30 +000011440static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11441 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11442 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11443 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11444 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11445 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11446 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11448 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11449 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11450 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11451 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11452 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11453 { } /* end */
11454};
11455
11456static struct hda_verb alc262_tyan_verbs[] = {
11457 /* Headphone automute */
11458 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11459 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11460 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11461
11462 /* P11 AUX_IN, white 4-pin connector */
11463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11464 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11465 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11466 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11467
11468 {}
11469};
11470
11471/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011472static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011473{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011474 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011475
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011476 spec->autocfg.hp_pins[0] = 0x1b;
11477 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011478}
11479
Tony Vroonba340e82009-02-02 19:01:30 +000011480
Kailang Yangdf694da2005-12-05 19:42:22 +010011481#define alc262_capture_mixer alc882_capture_mixer
11482#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11483
11484/*
11485 * generic initialization of ADC, input mixers and output mixers
11486 */
11487static struct hda_verb alc262_init_verbs[] = {
11488 /*
11489 * Unmute ADC0-2 and set the default input to mic-in
11490 */
11491 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11495 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11496 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11497
Takashi Iwaicb53c622007-08-10 17:21:45 +020011498 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011499 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011500 * Note: PASD motherboards uses the Line In 2 as the input for
11501 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011502 */
11503 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011509
11510 /*
11511 * Set up output mixers (0x0c - 0x0e)
11512 */
11513 /* set vol=0 to output mixers */
11514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11515 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11517 /* set up input amps for analog loopback */
11518 /* Amp Indices: DAC = 0, mixer = 1 */
11519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11524 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11525
11526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11527 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11528 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11529 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11530 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11531 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11532
11533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11536 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11537 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011538
Kailang Yangdf694da2005-12-05 19:42:22 +010011539 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11540 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011541
Kailang Yangdf694da2005-12-05 19:42:22 +010011542 /* FIXME: use matrix-type input source selection */
11543 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11544 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11545 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11546 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11548 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11549 /* Input mixer2 */
11550 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11551 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11552 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11553 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11554 /* Input mixer3 */
11555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11556 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11557 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011558 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011559
11560 { }
11561};
11562
Kailang Yang4e555fe2008-08-26 13:05:55 +020011563static struct hda_verb alc262_eapd_verbs[] = {
11564 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11565 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11566 { }
11567};
11568
Kailang Yangccc656c2006-10-17 12:32:26 +020011569static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11570 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11571 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11572 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11573
11574 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11575 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11576 {}
11577};
11578
Kailang Yang272a5272007-05-14 11:00:38 +020011579static struct hda_verb alc262_sony_unsol_verbs[] = {
11580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11581 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11582 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11583
11584 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011586 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011587};
11588
Kailang Yang4e555fe2008-08-26 13:05:55 +020011589static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11590 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11591 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11592 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011595 { } /* end */
11596};
11597
11598static struct hda_verb alc262_toshiba_s06_verbs[] = {
11599 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11602 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11603 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11604 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11605 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11606 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11607 {}
11608};
11609
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011610static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011611{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011612 struct alc_spec *spec = codec->spec;
11613
11614 spec->autocfg.hp_pins[0] = 0x15;
11615 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011616 spec->ext_mic.pin = 0x18;
11617 spec->ext_mic.mux_idx = 0;
11618 spec->int_mic.pin = 0x12;
11619 spec->int_mic.mux_idx = 9;
11620 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011621}
11622
Takashi Iwai834be882006-03-01 14:16:17 +010011623/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011624 * nec model
11625 * 0x15 = headphone
11626 * 0x16 = internal speaker
11627 * 0x18 = external mic
11628 */
11629
11630static struct snd_kcontrol_new alc262_nec_mixer[] = {
11631 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11632 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11633
11634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11636 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11637
11638 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11640 { } /* end */
11641};
11642
11643static struct hda_verb alc262_nec_verbs[] = {
11644 /* Unmute Speaker */
11645 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11646
11647 /* Headphone */
11648 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11650
11651 /* External mic to headphone */
11652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11653 /* External mic to speaker */
11654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11655 {}
11656};
11657
11658/*
Takashi Iwai834be882006-03-01 14:16:17 +010011659 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011660 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11661 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011662 */
11663
11664#define ALC_HP_EVENT 0x37
11665
11666static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11667 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011669 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011671 {}
11672};
11673
Jiang zhe0e31daf2008-03-20 12:12:39 +010011674static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11675 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11676 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11677 {}
11678};
11679
Daniel T Chene2595322009-12-19 18:19:02 -050011680static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11681 /* Front Mic pin: input vref at 50% */
11682 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11684 {}
11685};
11686
Takashi Iwai834be882006-03-01 14:16:17 +010011687static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011688 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011689 .items = {
11690 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011691 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011692 { "CD", 0x4 },
11693 },
11694};
11695
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011696static struct hda_input_mux alc262_HP_capture_source = {
11697 .num_items = 5,
11698 .items = {
11699 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011700 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011701 { "Line", 0x2 },
11702 { "CD", 0x4 },
11703 { "AUX IN", 0x6 },
11704 },
11705};
11706
zhejiangaccbe492007-08-31 12:36:05 +020011707static struct hda_input_mux alc262_HP_D7000_capture_source = {
11708 .num_items = 4,
11709 .items = {
11710 { "Mic", 0x0 },
11711 { "Front Mic", 0x2 },
11712 { "Line", 0x1 },
11713 { "CD", 0x4 },
11714 },
11715};
11716
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011717/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011718static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11719{
11720 struct alc_spec *spec = codec->spec;
11721 unsigned int mute;
11722
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011723 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011724 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11725 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011726 spec->sense_updated = 1;
11727 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011728 /* unmute internal speaker only if both HPs are unplugged and
11729 * master switch is on
11730 */
11731 if (spec->jack_present)
11732 mute = HDA_AMP_MUTE;
11733 else
Takashi Iwai834be882006-03-01 14:16:17 +010011734 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011735 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11736 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011737}
11738
11739/* unsolicited event for HP jack sensing */
11740static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11741 unsigned int res)
11742{
11743 if ((res >> 26) != ALC_HP_EVENT)
11744 return;
11745 alc262_fujitsu_automute(codec, 1);
11746}
11747
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011748static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11749{
11750 alc262_fujitsu_automute(codec, 1);
11751}
11752
Takashi Iwai834be882006-03-01 14:16:17 +010011753/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011754static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11755 .ops = &snd_hda_bind_vol,
11756 .values = {
11757 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11758 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11759 0
11760 },
11761};
Takashi Iwai834be882006-03-01 14:16:17 +010011762
Jiang zhe0e31daf2008-03-20 12:12:39 +010011763/* mute/unmute internal speaker according to the hp jack and mute state */
11764static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11765{
11766 struct alc_spec *spec = codec->spec;
11767 unsigned int mute;
11768
11769 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011770 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011771 spec->sense_updated = 1;
11772 }
11773 if (spec->jack_present) {
11774 /* mute internal speaker */
11775 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11776 HDA_AMP_MUTE, HDA_AMP_MUTE);
11777 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11778 HDA_AMP_MUTE, HDA_AMP_MUTE);
11779 } else {
11780 /* unmute internal speaker if necessary */
11781 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11782 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11783 HDA_AMP_MUTE, mute);
11784 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11785 HDA_AMP_MUTE, mute);
11786 }
11787}
11788
11789/* unsolicited event for HP jack sensing */
11790static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11791 unsigned int res)
11792{
11793 if ((res >> 26) != ALC_HP_EVENT)
11794 return;
11795 alc262_lenovo_3000_automute(codec, 1);
11796}
11797
Takashi Iwai8de56b72009-07-24 16:51:47 +020011798static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11799 int dir, int idx, long *valp)
11800{
11801 int i, change = 0;
11802
11803 for (i = 0; i < 2; i++, valp++)
11804 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11805 HDA_AMP_MUTE,
11806 *valp ? 0 : HDA_AMP_MUTE);
11807 return change;
11808}
11809
Takashi Iwai834be882006-03-01 14:16:17 +010011810/* bind hp and internal speaker mute (with plug check) */
11811static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11812 struct snd_ctl_elem_value *ucontrol)
11813{
11814 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11815 long *valp = ucontrol->value.integer.value;
11816 int change;
11817
Takashi Iwai8de56b72009-07-24 16:51:47 +020011818 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11819 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011820 if (change)
11821 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011822 return change;
11823}
11824
11825static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011826 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011827 {
11828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11829 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011830 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011831 .info = snd_hda_mixer_amp_switch_info,
11832 .get = snd_hda_mixer_amp_switch_get,
11833 .put = alc262_fujitsu_master_sw_put,
11834 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11835 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011836 {
11837 .iface = NID_MAPPING,
11838 .name = "Master Playback Switch",
11839 .private_value = 0x1b,
11840 },
Takashi Iwai834be882006-03-01 14:16:17 +010011841 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11842 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011846 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11847 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11848 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011849 { } /* end */
11850};
11851
Jiang zhe0e31daf2008-03-20 12:12:39 +010011852/* bind hp and internal speaker mute (with plug check) */
11853static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11854 struct snd_ctl_elem_value *ucontrol)
11855{
11856 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11857 long *valp = ucontrol->value.integer.value;
11858 int change;
11859
Takashi Iwai8de56b72009-07-24 16:51:47 +020011860 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011861 if (change)
11862 alc262_lenovo_3000_automute(codec, 0);
11863 return change;
11864}
11865
11866static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11867 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11868 {
11869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11870 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011871 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011872 .info = snd_hda_mixer_amp_switch_info,
11873 .get = snd_hda_mixer_amp_switch_get,
11874 .put = alc262_lenovo_3000_master_sw_put,
11875 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11876 },
11877 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11878 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11882 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11883 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11884 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11885 { } /* end */
11886};
11887
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011888static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11889 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011890 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11893 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11896 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11897 { } /* end */
11898};
11899
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011900/* additional init verbs for Benq laptops */
11901static struct hda_verb alc262_EAPD_verbs[] = {
11902 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11903 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11904 {}
11905};
11906
Kailang Yang83c34212007-07-05 11:43:05 +020011907static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11908 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11909 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11910
11911 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11912 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11913 {}
11914};
11915
Tobin Davisf651b502007-10-26 12:40:47 +020011916/* Samsung Q1 Ultra Vista model setup */
11917static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011918 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11919 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11922 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011923 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011924 { } /* end */
11925};
11926
11927static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011928 /* output mixer */
11929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11932 /* speaker */
11933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11934 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11935 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11936 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11937 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11941 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11942 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11943 /* internal mic */
11944 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11946 /* ADC, choose mic */
11947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11948 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11949 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11950 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11951 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11952 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11953 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11954 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11955 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11956 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011957 {}
11958};
11959
Tobin Davisf651b502007-10-26 12:40:47 +020011960/* mute/unmute internal speaker according to the hp jack and mute state */
11961static void alc262_ultra_automute(struct hda_codec *codec)
11962{
11963 struct alc_spec *spec = codec->spec;
11964 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011965
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011966 mute = 0;
11967 /* auto-mute only when HP is used as HP */
11968 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011969 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011970 if (spec->jack_present)
11971 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011972 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011973 /* mute/unmute internal speaker */
11974 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11975 HDA_AMP_MUTE, mute);
11976 /* mute/unmute HP */
11977 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11978 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011979}
11980
11981/* unsolicited event for HP jack sensing */
11982static void alc262_ultra_unsol_event(struct hda_codec *codec,
11983 unsigned int res)
11984{
11985 if ((res >> 26) != ALC880_HP_EVENT)
11986 return;
11987 alc262_ultra_automute(codec);
11988}
11989
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011990static struct hda_input_mux alc262_ultra_capture_source = {
11991 .num_items = 2,
11992 .items = {
11993 { "Mic", 0x1 },
11994 { "Headphone", 0x7 },
11995 },
11996};
11997
11998static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11999 struct snd_ctl_elem_value *ucontrol)
12000{
12001 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12002 struct alc_spec *spec = codec->spec;
12003 int ret;
12004
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012005 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012006 if (!ret)
12007 return 0;
12008 /* reprogram the HP pin as mic or HP according to the input source */
12009 snd_hda_codec_write_cache(codec, 0x15, 0,
12010 AC_VERB_SET_PIN_WIDGET_CONTROL,
12011 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12012 alc262_ultra_automute(codec); /* mute/unmute HP */
12013 return ret;
12014}
12015
12016static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12017 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12018 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12019 {
12020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12021 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012022 .info = alc_mux_enum_info,
12023 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012024 .put = alc262_ultra_mux_enum_put,
12025 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012026 {
12027 .iface = NID_MAPPING,
12028 .name = "Capture Source",
12029 .private_value = 0x15,
12030 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012031 { } /* end */
12032};
12033
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012034/* We use two mixers depending on the output pin; 0x16 is a mono output
12035 * and thus it's bound with a different mixer.
12036 * This function returns which mixer amp should be used.
12037 */
12038static int alc262_check_volbit(hda_nid_t nid)
12039{
12040 if (!nid)
12041 return 0;
12042 else if (nid == 0x16)
12043 return 2;
12044 else
12045 return 1;
12046}
12047
12048static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012049 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012050{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012051 unsigned long val;
12052 int vbit;
12053
12054 vbit = alc262_check_volbit(nid);
12055 if (!vbit)
12056 return 0;
12057 if (*vbits & vbit) /* a volume control for this mixer already there */
12058 return 0;
12059 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012060 if (vbit == 2)
12061 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12062 else
12063 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012064 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012065}
12066
12067static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012068 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012069{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012070 unsigned long val;
12071
12072 if (!nid)
12073 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012074 if (nid == 0x16)
12075 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12076 else
12077 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012078 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012079}
12080
Kailang Yangdf694da2005-12-05 19:42:22 +010012081/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012082static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12083 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012084{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012085 const char *pfx;
12086 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012087 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012088
12089 spec->multiout.num_dacs = 1; /* only use one dac */
12090 spec->multiout.dac_nids = spec->private_dac_nids;
12091 spec->multiout.dac_nids[0] = 2;
12092
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012093 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
12094 pfx = "Master";
12095 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12096 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020012097 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
12098 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012099 else
12100 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012101 for (i = 0; i < 2; i++) {
12102 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12103 if (err < 0)
12104 return err;
12105 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12106 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12107 "Speaker", i);
12108 if (err < 0)
12109 return err;
12110 }
12111 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12112 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12113 "Headphone", i);
12114 if (err < 0)
12115 return err;
12116 }
12117 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012118
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012119 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12120 alc262_check_volbit(cfg->speaker_pins[0]) |
12121 alc262_check_volbit(cfg->hp_pins[0]);
12122 if (vbits == 1 || vbits == 2)
12123 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012124 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012125 for (i = 0; i < 2; i++) {
12126 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12127 &vbits, i);
12128 if (err < 0)
12129 return err;
12130 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12131 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12132 "Speaker", &vbits, i);
12133 if (err < 0)
12134 return err;
12135 }
12136 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12137 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12138 "Headphone", &vbits, i);
12139 if (err < 0)
12140 return err;
12141 }
12142 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012143 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012144}
12145
Takashi Iwai05f5f472009-08-25 13:10:18 +020012146#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012147 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012148
12149/*
12150 * generic initialization of ADC, input mixers and output mixers
12151 */
12152static struct hda_verb alc262_volume_init_verbs[] = {
12153 /*
12154 * Unmute ADC0-2 and set the default input to mic-in
12155 */
12156 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12158 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12160 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12162
Takashi Iwaicb53c622007-08-10 17:21:45 +020012163 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012164 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012165 * Note: PASD motherboards uses the Line In 2 as the input for
12166 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012167 */
12168 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12172 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12173 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012174
12175 /*
12176 * Set up output mixers (0x0c - 0x0f)
12177 */
12178 /* set vol=0 to output mixers */
12179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012182
Kailang Yangdf694da2005-12-05 19:42:22 +010012183 /* set up input amps for analog loopback */
12184 /* Amp Indices: DAC = 0, mixer = 1 */
12185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12187 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12189 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12190 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12191
12192 /* FIXME: use matrix-type input source selection */
12193 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12194 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12199 /* Input mixer2 */
12200 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12201 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12202 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12203 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12204 /* Input mixer3 */
12205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12209
12210 { }
12211};
12212
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012213static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12214 /*
12215 * Unmute ADC0-2 and set the default input to mic-in
12216 */
12217 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12219 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12220 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12221 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12222 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12223
Takashi Iwaicb53c622007-08-10 17:21:45 +020012224 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012225 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012226 * Note: PASD motherboards uses the Line In 2 as the input for
12227 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012228 */
12229 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012230 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012237
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012238 /*
12239 * Set up output mixers (0x0c - 0x0e)
12240 */
12241 /* set vol=0 to output mixers */
12242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12243 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12245
12246 /* set up input amps for analog loopback */
12247 /* Amp Indices: DAC = 0, mixer = 1 */
12248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12254
Takashi Iwaice875f02008-01-28 18:17:43 +010012255 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12257 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12258
12259 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12261
12262 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12263 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12264
12265 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12266 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12268 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12269 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12270
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012272 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12273 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012275 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12276 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12277
12278
12279 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012280 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12281 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12290 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012291 /* Input mixer2 */
12292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12295 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12296 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012301 /* Input mixer3 */
12302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12306 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12307 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012311
Takashi Iwaice875f02008-01-28 18:17:43 +010012312 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12313
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012314 { }
12315};
12316
Kailang Yangcd7509a2007-01-26 18:33:17 +010012317static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12318 /*
12319 * Unmute ADC0-2 and set the default input to mic-in
12320 */
12321 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12322 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12323 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12324 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12325 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12326 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12327
Takashi Iwaicb53c622007-08-10 17:21:45 +020012328 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012329 * mixer widget
12330 * Note: PASD motherboards uses the Line In 2 as the input for front
12331 * panel mic (mic 2)
12332 */
12333 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012334 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012342 /*
12343 * Set up output mixers (0x0c - 0x0e)
12344 */
12345 /* set vol=0 to output mixers */
12346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12349
12350 /* set up input amps for analog loopback */
12351 /* Amp Indices: DAC = 0, mixer = 1 */
12352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12354 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12355 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12356 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12358
12359
12360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12361 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12362 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12363 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12364 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12366 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12367
12368 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12370
12371 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12373
12374 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12375 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12377 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12378 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12379 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12380
12381 /* FIXME: use matrix-type input source selection */
12382 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12383 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12384 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12389 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12391 /* Input mixer2 */
12392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12397 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12399 /* Input mixer3 */
12400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12405 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12407
Takashi Iwaice875f02008-01-28 18:17:43 +010012408 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12409
Kailang Yangcd7509a2007-01-26 18:33:17 +010012410 { }
12411};
12412
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012413static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12414
12415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12416 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12417 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12418
12419 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12420 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12421 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12422 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12423
12424 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12425 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12426 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12427 {}
12428};
12429
Takashi Iwai18675e42010-09-08 15:55:44 +020012430/*
12431 * Pin config fixes
12432 */
12433enum {
12434 PINFIX_FSC_H270,
12435};
12436
12437static const struct alc_fixup alc262_fixups[] = {
12438 [PINFIX_FSC_H270] = {
12439 .pins = (const struct alc_pincfg[]) {
12440 { 0x14, 0x99130110 }, /* speaker */
12441 { 0x15, 0x0221142f }, /* front HP */
12442 { 0x1b, 0x0121141f }, /* rear HP */
12443 { }
12444 }
12445 },
12446 [PINFIX_PB_M5210] = {
12447 .verbs = (const struct hda_verb[]) {
12448 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12449 {}
12450 }
12451 },
12452};
12453
12454static struct snd_pci_quirk alc262_fixup_tbl[] = {
12455 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12456 {}
12457};
12458
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012459
Takashi Iwaicb53c622007-08-10 17:21:45 +020012460#ifdef CONFIG_SND_HDA_POWER_SAVE
12461#define alc262_loopbacks alc880_loopbacks
12462#endif
12463
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012464/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012465#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12466#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12467#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12468#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12469
12470/*
12471 * BIOS auto configuration
12472 */
12473static int alc262_parse_auto_config(struct hda_codec *codec)
12474{
12475 struct alc_spec *spec = codec->spec;
12476 int err;
12477 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12478
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012479 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12480 alc262_ignore);
12481 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012482 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012483 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012484 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012485 spec->multiout.max_channels = 2;
12486 spec->no_analog = 1;
12487 goto dig_only;
12488 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012489 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012490 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012491 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12492 if (err < 0)
12493 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012494 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012495 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012496 return err;
12497
12498 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12499
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012500 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012501 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012502
Takashi Iwai603c4012008-07-30 15:01:44 +020012503 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012504 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012505
Takashi Iwaid88897e2008-10-31 15:01:37 +010012506 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012507 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012508 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012509
Takashi Iwai776e1842007-08-29 15:07:11 +020012510 err = alc_auto_add_mic_boost(codec);
12511 if (err < 0)
12512 return err;
12513
Kailang Yang6227cdc2010-02-25 08:36:52 +010012514 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012515
Kailang Yangdf694da2005-12-05 19:42:22 +010012516 return 1;
12517}
12518
12519#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12520#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12521#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012522#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012523
12524
12525/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012526static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012527{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012528 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012529 alc262_auto_init_multi_out(codec);
12530 alc262_auto_init_hp_out(codec);
12531 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012532 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012533 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012534 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012535 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012536}
12537
12538/*
12539 * configuration and preset
12540 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012541static const char *alc262_models[ALC262_MODEL_LAST] = {
12542 [ALC262_BASIC] = "basic",
12543 [ALC262_HIPPO] = "hippo",
12544 [ALC262_HIPPO_1] = "hippo_1",
12545 [ALC262_FUJITSU] = "fujitsu",
12546 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012547 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012548 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012549 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012550 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012551 [ALC262_BENQ_T31] = "benq-t31",
12552 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012553 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012554 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012555 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012556 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012557 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012558 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012559 [ALC262_AUTO] = "auto",
12560};
12561
12562static struct snd_pci_quirk alc262_cfg_tbl[] = {
12563 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012564 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012565 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12566 ALC262_HP_BPC),
12567 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12568 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012569 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12570 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012571 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012572 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012573 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012574 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012575 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012576 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012577 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012578 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012579 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12580 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12581 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012582 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12583 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012584 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012585 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012586 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012587 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012588 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012589 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012590 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012591 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012592#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012593 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12594 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012595#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012596 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012597 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012598 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012599 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012600 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012601 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012602 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12603 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012604 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012605 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012606 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012607 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012608 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012609 {}
12610};
12611
12612static struct alc_config_preset alc262_presets[] = {
12613 [ALC262_BASIC] = {
12614 .mixers = { alc262_base_mixer },
12615 .init_verbs = { alc262_init_verbs },
12616 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12617 .dac_nids = alc262_dac_nids,
12618 .hp_nid = 0x03,
12619 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12620 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012621 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012622 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012623 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012624 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012625 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012626 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12627 .dac_nids = alc262_dac_nids,
12628 .hp_nid = 0x03,
12629 .dig_out_nid = ALC262_DIGOUT_NID,
12630 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12631 .channel_mode = alc262_modes,
12632 .input_mux = &alc262_capture_source,
12633 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012634 .setup = alc262_hippo_setup,
12635 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012636 },
12637 [ALC262_HIPPO_1] = {
12638 .mixers = { alc262_hippo1_mixer },
12639 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12640 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12641 .dac_nids = alc262_dac_nids,
12642 .hp_nid = 0x02,
12643 .dig_out_nid = ALC262_DIGOUT_NID,
12644 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12645 .channel_mode = alc262_modes,
12646 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012647 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012648 .setup = alc262_hippo1_setup,
12649 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012650 },
Takashi Iwai834be882006-03-01 14:16:17 +010012651 [ALC262_FUJITSU] = {
12652 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012653 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12654 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012655 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12656 .dac_nids = alc262_dac_nids,
12657 .hp_nid = 0x03,
12658 .dig_out_nid = ALC262_DIGOUT_NID,
12659 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12660 .channel_mode = alc262_modes,
12661 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012662 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012663 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012664 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012665 [ALC262_HP_BPC] = {
12666 .mixers = { alc262_HP_BPC_mixer },
12667 .init_verbs = { alc262_HP_BPC_init_verbs },
12668 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12669 .dac_nids = alc262_dac_nids,
12670 .hp_nid = 0x03,
12671 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12672 .channel_mode = alc262_modes,
12673 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012674 .unsol_event = alc262_hp_bpc_unsol_event,
12675 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012676 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012677 [ALC262_HP_BPC_D7000_WF] = {
12678 .mixers = { alc262_HP_BPC_WildWest_mixer },
12679 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12680 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12681 .dac_nids = alc262_dac_nids,
12682 .hp_nid = 0x03,
12683 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12684 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012685 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012686 .unsol_event = alc262_hp_wildwest_unsol_event,
12687 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012688 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012689 [ALC262_HP_BPC_D7000_WL] = {
12690 .mixers = { alc262_HP_BPC_WildWest_mixer,
12691 alc262_HP_BPC_WildWest_option_mixer },
12692 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12693 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12694 .dac_nids = alc262_dac_nids,
12695 .hp_nid = 0x03,
12696 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12697 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012698 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012699 .unsol_event = alc262_hp_wildwest_unsol_event,
12700 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012701 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012702 [ALC262_HP_TC_T5735] = {
12703 .mixers = { alc262_hp_t5735_mixer },
12704 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12705 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12706 .dac_nids = alc262_dac_nids,
12707 .hp_nid = 0x03,
12708 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12709 .channel_mode = alc262_modes,
12710 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012711 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012712 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012713 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012714 },
12715 [ALC262_HP_RP5700] = {
12716 .mixers = { alc262_hp_rp5700_mixer },
12717 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12718 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12719 .dac_nids = alc262_dac_nids,
12720 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12721 .channel_mode = alc262_modes,
12722 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012723 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012724 [ALC262_BENQ_ED8] = {
12725 .mixers = { alc262_base_mixer },
12726 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12727 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12728 .dac_nids = alc262_dac_nids,
12729 .hp_nid = 0x03,
12730 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12731 .channel_mode = alc262_modes,
12732 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012733 },
Kailang Yang272a5272007-05-14 11:00:38 +020012734 [ALC262_SONY_ASSAMD] = {
12735 .mixers = { alc262_sony_mixer },
12736 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12737 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12738 .dac_nids = alc262_dac_nids,
12739 .hp_nid = 0x02,
12740 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12741 .channel_mode = alc262_modes,
12742 .input_mux = &alc262_capture_source,
12743 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012744 .setup = alc262_hippo_setup,
12745 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012746 },
12747 [ALC262_BENQ_T31] = {
12748 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012749 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12750 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012751 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12752 .dac_nids = alc262_dac_nids,
12753 .hp_nid = 0x03,
12754 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12755 .channel_mode = alc262_modes,
12756 .input_mux = &alc262_capture_source,
12757 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012758 .setup = alc262_hippo_setup,
12759 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012760 },
Tobin Davisf651b502007-10-26 12:40:47 +020012761 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012762 .mixers = { alc262_ultra_mixer },
12763 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012764 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012765 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12766 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012767 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12768 .channel_mode = alc262_modes,
12769 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012770 .adc_nids = alc262_adc_nids, /* ADC0 */
12771 .capsrc_nids = alc262_capsrc_nids,
12772 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012773 .unsol_event = alc262_ultra_unsol_event,
12774 .init_hook = alc262_ultra_automute,
12775 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012776 [ALC262_LENOVO_3000] = {
12777 .mixers = { alc262_lenovo_3000_mixer },
12778 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012779 alc262_lenovo_3000_unsol_verbs,
12780 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012781 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12782 .dac_nids = alc262_dac_nids,
12783 .hp_nid = 0x03,
12784 .dig_out_nid = ALC262_DIGOUT_NID,
12785 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12786 .channel_mode = alc262_modes,
12787 .input_mux = &alc262_fujitsu_capture_source,
12788 .unsol_event = alc262_lenovo_3000_unsol_event,
12789 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012790 [ALC262_NEC] = {
12791 .mixers = { alc262_nec_mixer },
12792 .init_verbs = { alc262_nec_verbs },
12793 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12794 .dac_nids = alc262_dac_nids,
12795 .hp_nid = 0x03,
12796 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12797 .channel_mode = alc262_modes,
12798 .input_mux = &alc262_capture_source,
12799 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012800 [ALC262_TOSHIBA_S06] = {
12801 .mixers = { alc262_toshiba_s06_mixer },
12802 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12803 alc262_eapd_verbs },
12804 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12805 .capsrc_nids = alc262_dmic_capsrc_nids,
12806 .dac_nids = alc262_dac_nids,
12807 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012808 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012809 .dig_out_nid = ALC262_DIGOUT_NID,
12810 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12811 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012812 .unsol_event = alc_sku_unsol_event,
12813 .setup = alc262_toshiba_s06_setup,
12814 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012815 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012816 [ALC262_TOSHIBA_RX1] = {
12817 .mixers = { alc262_toshiba_rx1_mixer },
12818 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12819 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12820 .dac_nids = alc262_dac_nids,
12821 .hp_nid = 0x03,
12822 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12823 .channel_mode = alc262_modes,
12824 .input_mux = &alc262_capture_source,
12825 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012826 .setup = alc262_hippo_setup,
12827 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012828 },
Tony Vroonba340e82009-02-02 19:01:30 +000012829 [ALC262_TYAN] = {
12830 .mixers = { alc262_tyan_mixer },
12831 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12832 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12833 .dac_nids = alc262_dac_nids,
12834 .hp_nid = 0x02,
12835 .dig_out_nid = ALC262_DIGOUT_NID,
12836 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12837 .channel_mode = alc262_modes,
12838 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012839 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012840 .setup = alc262_tyan_setup,
12841 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012842 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012843};
12844
12845static int patch_alc262(struct hda_codec *codec)
12846{
12847 struct alc_spec *spec;
12848 int board_config;
12849 int err;
12850
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012851 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012852 if (spec == NULL)
12853 return -ENOMEM;
12854
12855 codec->spec = spec;
12856#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012857 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12858 * under-run
12859 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012860 {
12861 int tmp;
12862 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12863 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12864 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12865 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12866 }
12867#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012868 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012869
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012870 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12871
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012872 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12873 alc262_models,
12874 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012875
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012876 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012877 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12878 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012879 board_config = ALC262_AUTO;
12880 }
12881
Takashi Iwai18675e42010-09-08 15:55:44 +020012882 if (board_config == ALC262_AUTO)
12883 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12884
Kailang Yangdf694da2005-12-05 19:42:22 +010012885 if (board_config == ALC262_AUTO) {
12886 /* automatic parse from the BIOS config */
12887 err = alc262_parse_auto_config(codec);
12888 if (err < 0) {
12889 alc_free(codec);
12890 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012891 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012892 printk(KERN_INFO
12893 "hda_codec: Cannot set up configuration "
12894 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012895 board_config = ALC262_BASIC;
12896 }
12897 }
12898
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012899 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012900 err = snd_hda_attach_beep_device(codec, 0x1);
12901 if (err < 0) {
12902 alc_free(codec);
12903 return err;
12904 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012905 }
12906
Kailang Yangdf694da2005-12-05 19:42:22 +010012907 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012908 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012909
Kailang Yangdf694da2005-12-05 19:42:22 +010012910 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12911 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012912
Kailang Yangdf694da2005-12-05 19:42:22 +010012913 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12914 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12915
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012916 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012917 int i;
12918 /* check whether the digital-mic has to be supported */
12919 for (i = 0; i < spec->input_mux->num_items; i++) {
12920 if (spec->input_mux->items[i].index >= 9)
12921 break;
12922 }
12923 if (i < spec->input_mux->num_items) {
12924 /* use only ADC0 */
12925 spec->adc_nids = alc262_dmic_adc_nids;
12926 spec->num_adc_nids = 1;
12927 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012928 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012929 /* all analog inputs */
12930 /* check whether NID 0x07 is valid */
12931 unsigned int wcap = get_wcaps(codec, 0x07);
12932
12933 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012934 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012935 if (wcap != AC_WID_AUD_IN) {
12936 spec->adc_nids = alc262_adc_nids_alt;
12937 spec->num_adc_nids =
12938 ARRAY_SIZE(alc262_adc_nids_alt);
12939 spec->capsrc_nids = alc262_capsrc_nids_alt;
12940 } else {
12941 spec->adc_nids = alc262_adc_nids;
12942 spec->num_adc_nids =
12943 ARRAY_SIZE(alc262_adc_nids);
12944 spec->capsrc_nids = alc262_capsrc_nids;
12945 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012946 }
12947 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012948 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012949 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012950 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012951 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012952
Takashi Iwai18675e42010-09-08 15:55:44 +020012953 if (board_config == ALC262_AUTO)
12954 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12955
Takashi Iwai2134ea42008-01-10 16:53:55 +010012956 spec->vmaster_nid = 0x0c;
12957
Kailang Yangdf694da2005-12-05 19:42:22 +010012958 codec->patch_ops = alc_patch_ops;
12959 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012960 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012961
12962 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012963#ifdef CONFIG_SND_HDA_POWER_SAVE
12964 if (!spec->loopback.amplist)
12965 spec->loopback.amplist = alc262_loopbacks;
12966#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012967
Kailang Yangdf694da2005-12-05 19:42:22 +010012968 return 0;
12969}
12970
Kailang Yangdf694da2005-12-05 19:42:22 +010012971/*
Kailang Yanga361d842007-06-05 12:30:55 +020012972 * ALC268 channel source setting (2 channel)
12973 */
12974#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12975#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012976
Kailang Yanga361d842007-06-05 12:30:55 +020012977static hda_nid_t alc268_dac_nids[2] = {
12978 /* front, hp */
12979 0x02, 0x03
12980};
12981
12982static hda_nid_t alc268_adc_nids[2] = {
12983 /* ADC0-1 */
12984 0x08, 0x07
12985};
12986
12987static hda_nid_t alc268_adc_nids_alt[1] = {
12988 /* ADC0 */
12989 0x08
12990};
12991
Takashi Iwaie1406342008-02-11 18:32:32 +010012992static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12993
Kailang Yanga361d842007-06-05 12:30:55 +020012994static struct snd_kcontrol_new alc268_base_mixer[] = {
12995 /* output mixer control */
12996 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12997 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12998 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13001 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13002 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013003 { }
13004};
13005
Takashi Iwai42171c12009-05-08 14:11:43 +020013006static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13007 /* output mixer control */
13008 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13009 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13010 ALC262_HIPPO_MASTER_SWITCH,
13011 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13012 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13013 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13014 { }
13015};
13016
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013017/* bind Beep switches of both NID 0x0f and 0x10 */
13018static struct hda_bind_ctls alc268_bind_beep_sw = {
13019 .ops = &snd_hda_bind_sw,
13020 .values = {
13021 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13022 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13023 0
13024 },
13025};
13026
13027static struct snd_kcontrol_new alc268_beep_mixer[] = {
13028 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13029 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13030 { }
13031};
13032
Kailang Yangd1a991a2007-08-15 16:21:59 +020013033static struct hda_verb alc268_eapd_verbs[] = {
13034 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13035 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13036 { }
13037};
13038
Takashi Iwaid2738092007-08-16 14:59:45 +020013039/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013040static struct hda_verb alc268_toshiba_verbs[] = {
13041 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13042 { } /* end */
13043};
13044
13045/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013046/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013047static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13048 .ops = &snd_hda_bind_vol,
13049 .values = {
13050 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13051 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13052 0
13053 },
13054};
13055
Takashi Iwai889c4392007-08-23 18:56:52 +020013056/* mute/unmute internal speaker according to the hp jack and mute state */
13057static void alc268_acer_automute(struct hda_codec *codec, int force)
13058{
13059 struct alc_spec *spec = codec->spec;
13060 unsigned int mute;
13061
13062 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013063 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013064 spec->sense_updated = 1;
13065 }
13066 if (spec->jack_present)
13067 mute = HDA_AMP_MUTE; /* mute internal speaker */
13068 else /* unmute internal speaker if necessary */
13069 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13070 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13071 HDA_AMP_MUTE, mute);
13072}
13073
13074
13075/* bind hp and internal speaker mute (with plug check) */
13076static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13077 struct snd_ctl_elem_value *ucontrol)
13078{
13079 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13080 long *valp = ucontrol->value.integer.value;
13081 int change;
13082
Takashi Iwai8de56b72009-07-24 16:51:47 +020013083 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013084 if (change)
13085 alc268_acer_automute(codec, 0);
13086 return change;
13087}
Takashi Iwaid2738092007-08-16 14:59:45 +020013088
Kailang Yang8ef355d2008-08-26 13:10:22 +020013089static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13090 /* output mixer control */
13091 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13092 {
13093 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13094 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013095 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013096 .info = snd_hda_mixer_amp_switch_info,
13097 .get = snd_hda_mixer_amp_switch_get,
13098 .put = alc268_acer_master_sw_put,
13099 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13100 },
13101 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13102 { }
13103};
13104
Takashi Iwaid2738092007-08-16 14:59:45 +020013105static struct snd_kcontrol_new alc268_acer_mixer[] = {
13106 /* output mixer control */
13107 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13108 {
13109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13110 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013111 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013112 .info = snd_hda_mixer_amp_switch_info,
13113 .get = snd_hda_mixer_amp_switch_get,
13114 .put = alc268_acer_master_sw_put,
13115 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13116 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13118 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13119 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013120 { }
13121};
13122
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013123static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13124 /* output mixer control */
13125 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13126 {
13127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13128 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013129 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013130 .info = snd_hda_mixer_amp_switch_info,
13131 .get = snd_hda_mixer_amp_switch_get,
13132 .put = alc268_acer_master_sw_put,
13133 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13134 },
13135 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13136 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13137 { }
13138};
13139
Kailang Yang8ef355d2008-08-26 13:10:22 +020013140static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13141 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13143 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13144 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13145 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13146 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13147 { }
13148};
13149
Takashi Iwaid2738092007-08-16 14:59:45 +020013150static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013151 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13152 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013155 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13156 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013157 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13158 { }
13159};
13160
13161/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013162#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013163#define alc268_toshiba_setup alc262_hippo_setup
13164#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013165
13166static void alc268_acer_unsol_event(struct hda_codec *codec,
13167 unsigned int res)
13168{
Takashi Iwai889c4392007-08-23 18:56:52 +020013169 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013170 return;
13171 alc268_acer_automute(codec, 1);
13172}
13173
Takashi Iwai889c4392007-08-23 18:56:52 +020013174static void alc268_acer_init_hook(struct hda_codec *codec)
13175{
13176 alc268_acer_automute(codec, 1);
13177}
13178
Kailang Yang8ef355d2008-08-26 13:10:22 +020013179/* toggle speaker-output according to the hp-jack state */
13180static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13181{
13182 unsigned int present;
13183 unsigned char bits;
13184
Wu Fengguang864f92b2009-11-18 12:38:02 +080013185 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013186 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013187 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013188 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013189 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013190 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013191}
13192
Kailang Yang8ef355d2008-08-26 13:10:22 +020013193static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13194 unsigned int res)
13195{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013196 switch (res >> 26) {
13197 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013198 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013199 break;
13200 case ALC880_MIC_EVENT:
13201 alc_mic_automute(codec);
13202 break;
13203 }
13204}
13205
13206static void alc268_acer_lc_setup(struct hda_codec *codec)
13207{
13208 struct alc_spec *spec = codec->spec;
13209 spec->ext_mic.pin = 0x18;
13210 spec->ext_mic.mux_idx = 0;
13211 spec->int_mic.pin = 0x12;
13212 spec->int_mic.mux_idx = 6;
13213 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013214}
13215
13216static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13217{
13218 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013219 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013220}
13221
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013222static struct snd_kcontrol_new alc268_dell_mixer[] = {
13223 /* output mixer control */
13224 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13225 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13228 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13229 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13230 { }
13231};
13232
13233static struct hda_verb alc268_dell_verbs[] = {
13234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13236 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013237 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013238 { }
13239};
13240
13241/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013242static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013243{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013244 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013245
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013246 spec->autocfg.hp_pins[0] = 0x15;
13247 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013248 spec->ext_mic.pin = 0x18;
13249 spec->ext_mic.mux_idx = 0;
13250 spec->int_mic.pin = 0x19;
13251 spec->int_mic.mux_idx = 1;
13252 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013253}
13254
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013255static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13256 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13257 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13258 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13259 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13260 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13261 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13262 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13263 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13264 { }
13265};
13266
13267static struct hda_verb alc267_quanta_il1_verbs[] = {
13268 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13269 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13270 { }
13271};
13272
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013273static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013274{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013275 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013276 spec->autocfg.hp_pins[0] = 0x15;
13277 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013278 spec->ext_mic.pin = 0x18;
13279 spec->ext_mic.mux_idx = 0;
13280 spec->int_mic.pin = 0x19;
13281 spec->int_mic.mux_idx = 1;
13282 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013283}
13284
Kailang Yanga361d842007-06-05 12:30:55 +020013285/*
13286 * generic initialization of ADC, input mixers and output mixers
13287 */
13288static struct hda_verb alc268_base_init_verbs[] = {
13289 /* Unmute DAC0-1 and set vol = 0 */
13290 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013291 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013292
13293 /*
13294 * Set up output mixers (0x0c - 0x0e)
13295 */
13296 /* set vol=0 to output mixers */
13297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013298 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13299
13300 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13301 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13302
13303 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13304 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13305 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13306 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13307 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13308 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13310 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13311
13312 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13313 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13314 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013316 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013317
13318 /* set PCBEEP vol = 0, mute connections */
13319 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13321 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013322
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013323 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013324
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013325 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13327 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013329
Kailang Yanga361d842007-06-05 12:30:55 +020013330 { }
13331};
13332
13333/*
13334 * generic initialization of ADC, input mixers and output mixers
13335 */
13336static struct hda_verb alc268_volume_init_verbs[] = {
13337 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013338 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13339 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013340
13341 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13342 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13343 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13344 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13345 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13346
Kailang Yanga361d842007-06-05 12:30:55 +020013347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013348 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13349 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13350
13351 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013352 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013353
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013354 /* set PCBEEP vol = 0, mute connections */
13355 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13356 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13357 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013358
13359 { }
13360};
13361
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013362static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13363 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13364 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13365 { } /* end */
13366};
13367
Kailang Yanga361d842007-06-05 12:30:55 +020013368static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13369 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13370 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013371 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013372 { } /* end */
13373};
13374
13375static struct snd_kcontrol_new alc268_capture_mixer[] = {
13376 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13377 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13378 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13379 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013380 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013381 { } /* end */
13382};
13383
13384static struct hda_input_mux alc268_capture_source = {
13385 .num_items = 4,
13386 .items = {
13387 { "Mic", 0x0 },
13388 { "Front Mic", 0x1 },
13389 { "Line", 0x2 },
13390 { "CD", 0x3 },
13391 },
13392};
13393
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013394static struct hda_input_mux alc268_acer_capture_source = {
13395 .num_items = 3,
13396 .items = {
13397 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013398 { "Internal Mic", 0x1 },
13399 { "Line", 0x2 },
13400 },
13401};
13402
13403static struct hda_input_mux alc268_acer_dmic_capture_source = {
13404 .num_items = 3,
13405 .items = {
13406 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013407 { "Internal Mic", 0x6 },
13408 { "Line", 0x2 },
13409 },
13410};
13411
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013412#ifdef CONFIG_SND_DEBUG
13413static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013414 /* Volume widgets */
13415 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13416 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13417 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13418 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13419 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13420 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13421 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13422 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13423 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13424 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13425 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13426 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13427 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013428 /* The below appears problematic on some hardwares */
13429 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013430 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13431 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13432 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13433 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13434
13435 /* Modes for retasking pin widgets */
13436 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13437 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13438 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13439 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13440
13441 /* Controls for GPIO pins, assuming they are configured as outputs */
13442 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13443 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13444 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13445 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13446
13447 /* Switches to allow the digital SPDIF output pin to be enabled.
13448 * The ALC268 does not have an SPDIF input.
13449 */
13450 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13451
13452 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13453 * this output to turn on an external amplifier.
13454 */
13455 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13456 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13457
13458 { } /* end */
13459};
13460#endif
13461
Kailang Yanga361d842007-06-05 12:30:55 +020013462/* create input playback/capture controls for the given pin */
13463static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13464 const char *ctlname, int idx)
13465{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013466 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013467 int err;
13468
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013469 switch (nid) {
13470 case 0x14:
13471 case 0x16:
13472 dac = 0x02;
13473 break;
13474 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013475 case 0x1a: /* ALC259/269 only */
13476 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013477 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013478 dac = 0x03;
13479 break;
13480 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013481 snd_printd(KERN_WARNING "hda_codec: "
13482 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013483 return 0;
13484 }
13485 if (spec->multiout.dac_nids[0] != dac &&
13486 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013487 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013488 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013489 HDA_OUTPUT));
13490 if (err < 0)
13491 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013492 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13493 }
13494
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013495 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013496 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013497 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013498 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013499 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013500 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013501 if (err < 0)
13502 return err;
13503 return 0;
13504}
13505
13506/* add playback controls from the parsed DAC table */
13507static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13508 const struct auto_pin_cfg *cfg)
13509{
13510 hda_nid_t nid;
13511 int err;
13512
Kailang Yanga361d842007-06-05 12:30:55 +020013513 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013514
13515 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013516 if (nid) {
13517 const char *name;
13518 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13519 name = "Speaker";
13520 else
13521 name = "Front";
13522 err = alc268_new_analog_output(spec, nid, name, 0);
13523 if (err < 0)
13524 return err;
13525 }
Kailang Yanga361d842007-06-05 12:30:55 +020013526
13527 nid = cfg->speaker_pins[0];
13528 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013529 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013530 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13531 if (err < 0)
13532 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013533 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013534 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13535 if (err < 0)
13536 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013537 }
13538 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013539 if (nid) {
13540 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13541 if (err < 0)
13542 return err;
13543 }
Kailang Yanga361d842007-06-05 12:30:55 +020013544
13545 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13546 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013547 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013548 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013549 if (err < 0)
13550 return err;
13551 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013552 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013553}
13554
13555/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013556static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013557 const struct auto_pin_cfg *cfg)
13558{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013559 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013560}
13561
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013562static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13563 hda_nid_t nid, int pin_type)
13564{
13565 int idx;
13566
13567 alc_set_pin_output(codec, nid, pin_type);
13568 if (nid == 0x14 || nid == 0x16)
13569 idx = 0;
13570 else
13571 idx = 1;
13572 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13573}
13574
13575static void alc268_auto_init_multi_out(struct hda_codec *codec)
13576{
13577 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013578 int i;
13579
13580 for (i = 0; i < spec->autocfg.line_outs; i++) {
13581 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013582 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13583 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13584 }
13585}
13586
13587static void alc268_auto_init_hp_out(struct hda_codec *codec)
13588{
13589 struct alc_spec *spec = codec->spec;
13590 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013591 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013592
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013593 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13594 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013595 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013596 }
13597 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13598 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013599 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013600 }
13601 if (spec->autocfg.mono_out_pin)
13602 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13603 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013604}
13605
Kailang Yanga361d842007-06-05 12:30:55 +020013606static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13607{
13608 struct alc_spec *spec = codec->spec;
13609 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13610 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13611 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13612 unsigned int dac_vol1, dac_vol2;
13613
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013614 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013615 snd_hda_codec_write(codec, speaker_nid, 0,
13616 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013617 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013618 snd_hda_codec_write(codec, 0x0f, 0,
13619 AC_VERB_SET_AMP_GAIN_MUTE,
13620 AMP_IN_UNMUTE(1));
13621 snd_hda_codec_write(codec, 0x10, 0,
13622 AC_VERB_SET_AMP_GAIN_MUTE,
13623 AMP_IN_UNMUTE(1));
13624 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013625 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013626 snd_hda_codec_write(codec, 0x0f, 0,
13627 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13628 snd_hda_codec_write(codec, 0x10, 0,
13629 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13630 }
13631
13632 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013633 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013634 dac_vol2 = AMP_OUT_ZERO;
13635 else if (line_nid == 0x15)
13636 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013637 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013638 dac_vol2 = AMP_OUT_ZERO;
13639 else if (hp_nid == 0x15)
13640 dac_vol1 = AMP_OUT_ZERO;
13641 if (line_nid != 0x16 || hp_nid != 0x16 ||
13642 spec->autocfg.line_out_pins[1] != 0x16 ||
13643 spec->autocfg.line_out_pins[2] != 0x16)
13644 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13645
13646 snd_hda_codec_write(codec, 0x02, 0,
13647 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13648 snd_hda_codec_write(codec, 0x03, 0,
13649 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13650}
13651
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013652/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013653#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13654#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013655#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013656#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13657
13658/*
13659 * BIOS auto configuration
13660 */
13661static int alc268_parse_auto_config(struct hda_codec *codec)
13662{
13663 struct alc_spec *spec = codec->spec;
13664 int err;
13665 static hda_nid_t alc268_ignore[] = { 0 };
13666
13667 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13668 alc268_ignore);
13669 if (err < 0)
13670 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013671 if (!spec->autocfg.line_outs) {
13672 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13673 spec->multiout.max_channels = 2;
13674 spec->no_analog = 1;
13675 goto dig_only;
13676 }
Kailang Yanga361d842007-06-05 12:30:55 +020013677 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013678 }
Kailang Yanga361d842007-06-05 12:30:55 +020013679 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13680 if (err < 0)
13681 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013682 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013683 if (err < 0)
13684 return err;
13685
13686 spec->multiout.max_channels = 2;
13687
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013688 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013689 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013690 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013691 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013692 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013693
Takashi Iwai892981f2009-03-02 08:04:35 +010013694 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013695 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013696
Takashi Iwaid88897e2008-10-31 15:01:37 +010013697 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013698 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013699 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013700
Takashi Iwai776e1842007-08-29 15:07:11 +020013701 err = alc_auto_add_mic_boost(codec);
13702 if (err < 0)
13703 return err;
13704
Kailang Yang6227cdc2010-02-25 08:36:52 +010013705 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013706
Kailang Yanga361d842007-06-05 12:30:55 +020013707 return 1;
13708}
13709
Kailang Yanga361d842007-06-05 12:30:55 +020013710#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13711
13712/* init callback for auto-configuration model -- overriding the default init */
13713static void alc268_auto_init(struct hda_codec *codec)
13714{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013715 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013716 alc268_auto_init_multi_out(codec);
13717 alc268_auto_init_hp_out(codec);
13718 alc268_auto_init_mono_speaker_out(codec);
13719 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013720 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013721 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013722 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013723}
13724
13725/*
13726 * configuration and preset
13727 */
13728static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013729 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013730 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013731 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013732 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013733 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013734 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013735 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013736 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013737#ifdef CONFIG_SND_DEBUG
13738 [ALC268_TEST] = "test",
13739#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013740 [ALC268_AUTO] = "auto",
13741};
13742
13743static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013744 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013745 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013746 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013747 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013748 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013749 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13750 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013751 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013752 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13753 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013754 /* almost compatible with toshiba but with optional digital outs;
13755 * auto-probing seems working fine
13756 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013757 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013758 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013759 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013760 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013761 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013762 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013763 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013764 {}
13765};
13766
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013767/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13768static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13769 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13770 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13771 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13772 ALC268_TOSHIBA),
13773 {}
13774};
13775
Kailang Yanga361d842007-06-05 12:30:55 +020013776static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013777 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013778 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13779 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013780 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13781 alc267_quanta_il1_verbs },
13782 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13783 .dac_nids = alc268_dac_nids,
13784 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13785 .adc_nids = alc268_adc_nids_alt,
13786 .hp_nid = 0x03,
13787 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13788 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013789 .unsol_event = alc_sku_unsol_event,
13790 .setup = alc267_quanta_il1_setup,
13791 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013792 },
Kailang Yanga361d842007-06-05 12:30:55 +020013793 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013794 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13795 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013796 .init_verbs = { alc268_base_init_verbs },
13797 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13798 .dac_nids = alc268_dac_nids,
13799 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13800 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013801 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013802 .hp_nid = 0x03,
13803 .dig_out_nid = ALC268_DIGOUT_NID,
13804 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13805 .channel_mode = alc268_modes,
13806 .input_mux = &alc268_capture_source,
13807 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013808 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013809 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013810 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013811 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13812 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013813 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13814 .dac_nids = alc268_dac_nids,
13815 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13816 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013817 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013818 .hp_nid = 0x03,
13819 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13820 .channel_mode = alc268_modes,
13821 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013822 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013823 .setup = alc268_toshiba_setup,
13824 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013825 },
13826 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013827 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013828 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013829 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13830 alc268_acer_verbs },
13831 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13832 .dac_nids = alc268_dac_nids,
13833 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13834 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013835 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013836 .hp_nid = 0x02,
13837 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13838 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013839 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013840 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013841 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013842 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013843 [ALC268_ACER_DMIC] = {
13844 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13845 alc268_beep_mixer },
13846 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13847 alc268_acer_verbs },
13848 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13849 .dac_nids = alc268_dac_nids,
13850 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13851 .adc_nids = alc268_adc_nids_alt,
13852 .capsrc_nids = alc268_capsrc_nids,
13853 .hp_nid = 0x02,
13854 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13855 .channel_mode = alc268_modes,
13856 .input_mux = &alc268_acer_dmic_capture_source,
13857 .unsol_event = alc268_acer_unsol_event,
13858 .init_hook = alc268_acer_init_hook,
13859 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013860 [ALC268_ACER_ASPIRE_ONE] = {
13861 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013862 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013863 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013864 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13865 alc268_acer_aspire_one_verbs },
13866 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13867 .dac_nids = alc268_dac_nids,
13868 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13869 .adc_nids = alc268_adc_nids_alt,
13870 .capsrc_nids = alc268_capsrc_nids,
13871 .hp_nid = 0x03,
13872 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13873 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013874 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013875 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013876 .init_hook = alc268_acer_lc_init_hook,
13877 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013878 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013879 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13880 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013881 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13882 alc268_dell_verbs },
13883 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13884 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013885 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13886 .adc_nids = alc268_adc_nids_alt,
13887 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013888 .hp_nid = 0x02,
13889 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13890 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013891 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013892 .setup = alc268_dell_setup,
13893 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013894 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013895 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013896 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13897 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013898 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13899 alc268_toshiba_verbs },
13900 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13901 .dac_nids = alc268_dac_nids,
13902 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13903 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013904 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013905 .hp_nid = 0x03,
13906 .dig_out_nid = ALC268_DIGOUT_NID,
13907 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13908 .channel_mode = alc268_modes,
13909 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013910 .setup = alc268_toshiba_setup,
13911 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013912 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013913#ifdef CONFIG_SND_DEBUG
13914 [ALC268_TEST] = {
13915 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13916 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13917 alc268_volume_init_verbs },
13918 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13919 .dac_nids = alc268_dac_nids,
13920 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13921 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013922 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013923 .hp_nid = 0x03,
13924 .dig_out_nid = ALC268_DIGOUT_NID,
13925 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13926 .channel_mode = alc268_modes,
13927 .input_mux = &alc268_capture_source,
13928 },
13929#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013930};
13931
13932static int patch_alc268(struct hda_codec *codec)
13933{
13934 struct alc_spec *spec;
13935 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013936 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013937
Julia Lawallef86f582009-12-19 08:18:03 +010013938 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013939 if (spec == NULL)
13940 return -ENOMEM;
13941
13942 codec->spec = spec;
13943
13944 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13945 alc268_models,
13946 alc268_cfg_tbl);
13947
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013948 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13949 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013950 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013951
Kailang Yanga361d842007-06-05 12:30:55 +020013952 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013953 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13954 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013955 board_config = ALC268_AUTO;
13956 }
13957
13958 if (board_config == ALC268_AUTO) {
13959 /* automatic parse from the BIOS config */
13960 err = alc268_parse_auto_config(codec);
13961 if (err < 0) {
13962 alc_free(codec);
13963 return err;
13964 } else if (!err) {
13965 printk(KERN_INFO
13966 "hda_codec: Cannot set up configuration "
13967 "from BIOS. Using base mode...\n");
13968 board_config = ALC268_3ST;
13969 }
13970 }
13971
13972 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013973 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013974
Kailang Yanga361d842007-06-05 12:30:55 +020013975 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13976 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013977 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013978
Kailang Yanga361d842007-06-05 12:30:55 +020013979 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13980
Takashi Iwai22971e32009-02-10 11:56:44 +010013981 has_beep = 0;
13982 for (i = 0; i < spec->num_mixers; i++) {
13983 if (spec->mixers[i] == alc268_beep_mixer) {
13984 has_beep = 1;
13985 break;
13986 }
13987 }
13988
13989 if (has_beep) {
13990 err = snd_hda_attach_beep_device(codec, 0x1);
13991 if (err < 0) {
13992 alc_free(codec);
13993 return err;
13994 }
13995 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13996 /* override the amp caps for beep generator */
13997 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013998 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13999 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14000 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14001 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014002 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014003
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014004 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014005 /* check whether NID 0x07 is valid */
14006 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010014007 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014008
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014009 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014010 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014011 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014012 if (spec->auto_mic ||
14013 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014014 spec->adc_nids = alc268_adc_nids_alt;
14015 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014016 if (spec->auto_mic)
14017 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014018 if (spec->auto_mic || spec->input_mux->num_items == 1)
14019 add_mixer(spec, alc268_capture_nosrc_mixer);
14020 else
14021 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014022 } else {
14023 spec->adc_nids = alc268_adc_nids;
14024 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014025 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014026 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014027 /* set default input source */
14028 for (i = 0; i < spec->num_adc_nids; i++)
14029 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14030 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014031 i < spec->num_mux_defs ?
14032 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014033 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014034 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014035
14036 spec->vmaster_nid = 0x02;
14037
Kailang Yanga361d842007-06-05 12:30:55 +020014038 codec->patch_ops = alc_patch_ops;
14039 if (board_config == ALC268_AUTO)
14040 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014041
Kailang Yangbf1b0222010-10-21 08:49:56 +020014042 alc_init_jacks(codec);
14043
Kailang Yanga361d842007-06-05 12:30:55 +020014044 return 0;
14045}
14046
14047/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014048 * ALC269 channel source setting (2 channel)
14049 */
14050#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14051
14052#define alc269_dac_nids alc260_dac_nids
14053
14054static hda_nid_t alc269_adc_nids[1] = {
14055 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014056 0x08,
14057};
14058
Takashi Iwaie01bf502008-08-21 16:25:07 +020014059static hda_nid_t alc269_capsrc_nids[1] = {
14060 0x23,
14061};
14062
Kailang Yang84898e82010-02-04 14:16:14 +010014063static hda_nid_t alc269vb_adc_nids[1] = {
14064 /* ADC1 */
14065 0x09,
14066};
14067
14068static hda_nid_t alc269vb_capsrc_nids[1] = {
14069 0x22,
14070};
14071
Takashi Iwai66946352010-03-29 17:21:45 +020014072static hda_nid_t alc269_adc_candidates[] = {
14073 0x08, 0x09, 0x07,
14074};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014075
Kailang Yangf6a92242007-12-13 16:52:54 +010014076#define alc269_modes alc260_modes
14077#define alc269_capture_source alc880_lg_lw_capture_source
14078
14079static struct snd_kcontrol_new alc269_base_mixer[] = {
14080 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14081 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14082 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14083 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14086 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14087 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14088 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14089 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14091 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14092 { } /* end */
14093};
14094
Kailang Yang60db6b52008-08-26 13:13:00 +020014095static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14096 /* output mixer control */
14097 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14098 {
14099 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14100 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014101 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014102 .info = snd_hda_mixer_amp_switch_info,
14103 .get = snd_hda_mixer_amp_switch_get,
14104 .put = alc268_acer_master_sw_put,
14105 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14106 },
14107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14109 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14110 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14111 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14112 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014113 { }
14114};
14115
Tony Vroon64154832008-11-06 15:08:49 +000014116static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14117 /* output mixer control */
14118 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14119 {
14120 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14121 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014122 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014123 .info = snd_hda_mixer_amp_switch_info,
14124 .get = snd_hda_mixer_amp_switch_get,
14125 .put = alc268_acer_master_sw_put,
14126 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14127 },
14128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14130 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14131 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14132 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14133 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14134 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14135 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14136 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014137 { }
14138};
14139
Kailang Yang84898e82010-02-04 14:16:14 +010014140static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014141 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014142 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014143 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014144 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014145 { } /* end */
14146};
14147
Kailang Yang84898e82010-02-04 14:16:14 +010014148static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14149 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14150 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14151 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14152 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14153 { } /* end */
14154};
14155
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014156static struct snd_kcontrol_new alc269_asus_mixer[] = {
14157 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14158 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14159 { } /* end */
14160};
14161
Kailang Yangf6a92242007-12-13 16:52:54 +010014162/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014163static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14164 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14165 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14166 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14167 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14168 { } /* end */
14169};
14170
14171static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014172 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14173 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014174 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14175 { } /* end */
14176};
14177
Kailang Yang84898e82010-02-04 14:16:14 +010014178static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14179 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14180 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14181 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14182 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14183 { } /* end */
14184};
14185
14186static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14187 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14188 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14189 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14190 { } /* end */
14191};
14192
Takashi Iwai26f5df22008-11-03 17:39:46 +010014193/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014194#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014195
Kailang Yang60db6b52008-08-26 13:13:00 +020014196static struct hda_verb alc269_quanta_fl1_verbs[] = {
14197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14198 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14200 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14201 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14202 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14203 { }
14204};
14205
Tony Vroon64154832008-11-06 15:08:49 +000014206static struct hda_verb alc269_lifebook_verbs[] = {
14207 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14208 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14209 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14211 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14212 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14213 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14214 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14215 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14216 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14217 { }
14218};
14219
Kailang Yang60db6b52008-08-26 13:13:00 +020014220/* toggle speaker-output according to the hp-jack state */
14221static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14222{
14223 unsigned int present;
14224 unsigned char bits;
14225
Wu Fengguang864f92b2009-11-18 12:38:02 +080014226 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014227 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014228 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014229 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014230 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014231 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014232
14233 snd_hda_codec_write(codec, 0x20, 0,
14234 AC_VERB_SET_COEF_INDEX, 0x0c);
14235 snd_hda_codec_write(codec, 0x20, 0,
14236 AC_VERB_SET_PROC_COEF, 0x680);
14237
14238 snd_hda_codec_write(codec, 0x20, 0,
14239 AC_VERB_SET_COEF_INDEX, 0x0c);
14240 snd_hda_codec_write(codec, 0x20, 0,
14241 AC_VERB_SET_PROC_COEF, 0x480);
14242}
14243
Tony Vroon64154832008-11-06 15:08:49 +000014244/* toggle speaker-output according to the hp-jacks state */
14245static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14246{
14247 unsigned int present;
14248 unsigned char bits;
14249
14250 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014251 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014252
14253 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014254 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014255
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014256 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014257 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014258 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014259 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014260 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014261
14262 snd_hda_codec_write(codec, 0x20, 0,
14263 AC_VERB_SET_COEF_INDEX, 0x0c);
14264 snd_hda_codec_write(codec, 0x20, 0,
14265 AC_VERB_SET_PROC_COEF, 0x680);
14266
14267 snd_hda_codec_write(codec, 0x20, 0,
14268 AC_VERB_SET_COEF_INDEX, 0x0c);
14269 snd_hda_codec_write(codec, 0x20, 0,
14270 AC_VERB_SET_PROC_COEF, 0x480);
14271}
14272
Tony Vroon64154832008-11-06 15:08:49 +000014273static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14274{
14275 unsigned int present_laptop;
14276 unsigned int present_dock;
14277
Wu Fengguang864f92b2009-11-18 12:38:02 +080014278 present_laptop = snd_hda_jack_detect(codec, 0x18);
14279 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014280
14281 /* Laptop mic port overrides dock mic port, design decision */
14282 if (present_dock)
14283 snd_hda_codec_write(codec, 0x23, 0,
14284 AC_VERB_SET_CONNECT_SEL, 0x3);
14285 if (present_laptop)
14286 snd_hda_codec_write(codec, 0x23, 0,
14287 AC_VERB_SET_CONNECT_SEL, 0x0);
14288 if (!present_dock && !present_laptop)
14289 snd_hda_codec_write(codec, 0x23, 0,
14290 AC_VERB_SET_CONNECT_SEL, 0x1);
14291}
14292
Kailang Yang60db6b52008-08-26 13:13:00 +020014293static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14294 unsigned int res)
14295{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014296 switch (res >> 26) {
14297 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014298 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014299 break;
14300 case ALC880_MIC_EVENT:
14301 alc_mic_automute(codec);
14302 break;
14303 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014304}
14305
Tony Vroon64154832008-11-06 15:08:49 +000014306static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14307 unsigned int res)
14308{
14309 if ((res >> 26) == ALC880_HP_EVENT)
14310 alc269_lifebook_speaker_automute(codec);
14311 if ((res >> 26) == ALC880_MIC_EVENT)
14312 alc269_lifebook_mic_autoswitch(codec);
14313}
14314
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014315static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14316{
14317 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014318 spec->autocfg.hp_pins[0] = 0x15;
14319 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014320 spec->ext_mic.pin = 0x18;
14321 spec->ext_mic.mux_idx = 0;
14322 spec->int_mic.pin = 0x19;
14323 spec->int_mic.mux_idx = 1;
14324 spec->auto_mic = 1;
14325}
14326
Kailang Yang60db6b52008-08-26 13:13:00 +020014327static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14328{
14329 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014330 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014331}
14332
Tony Vroon64154832008-11-06 15:08:49 +000014333static void alc269_lifebook_init_hook(struct hda_codec *codec)
14334{
14335 alc269_lifebook_speaker_automute(codec);
14336 alc269_lifebook_mic_autoswitch(codec);
14337}
14338
Kailang Yang84898e82010-02-04 14:16:14 +010014339static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14341 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14342 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14344 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14345 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14346 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14347 {}
14348};
14349
Kailang Yang84898e82010-02-04 14:16:14 +010014350static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014351 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14352 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14353 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14354 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14355 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14356 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14357 {}
14358};
14359
Kailang Yang84898e82010-02-04 14:16:14 +010014360static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14361 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14362 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14363 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14365 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14366 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14367 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14368 {}
14369};
14370
14371static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14372 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14373 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14374 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14375 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14376 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14377 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14378 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14379 {}
14380};
14381
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014382static struct hda_verb alc271_acer_dmic_verbs[] = {
14383 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14384 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14385 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14387 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14388 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14389 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14390 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14391 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14392 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14393 { }
14394};
14395
Kailang Yang60db6b52008-08-26 13:13:00 +020014396/* toggle speaker-output according to the hp-jack state */
14397static void alc269_speaker_automute(struct hda_codec *codec)
14398{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014399 struct alc_spec *spec = codec->spec;
14400 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014401 unsigned int present;
14402 unsigned char bits;
14403
Kailang Yangebb83ee2009-12-17 12:23:00 +010014404 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014405 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014406 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014407 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014408 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014409 HDA_AMP_MUTE, bits);
Kailang Yangbf1b0222010-10-21 08:49:56 +020014410 alc_report_jack(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014411}
14412
Kailang Yang60db6b52008-08-26 13:13:00 +020014413/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014414static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014415 unsigned int res)
14416{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014417 switch (res >> 26) {
14418 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014419 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014420 break;
14421 case ALC880_MIC_EVENT:
14422 alc_mic_automute(codec);
14423 break;
14424 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014425}
14426
Kailang Yang226b1ec2010-04-09 11:01:20 +020014427static void alc269_laptop_amic_setup(struct hda_codec *codec)
14428{
14429 struct alc_spec *spec = codec->spec;
14430 spec->autocfg.hp_pins[0] = 0x15;
14431 spec->autocfg.speaker_pins[0] = 0x14;
14432 spec->ext_mic.pin = 0x18;
14433 spec->ext_mic.mux_idx = 0;
14434 spec->int_mic.pin = 0x19;
14435 spec->int_mic.mux_idx = 1;
14436 spec->auto_mic = 1;
14437}
14438
Kailang Yang84898e82010-02-04 14:16:14 +010014439static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014440{
14441 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014442 spec->autocfg.hp_pins[0] = 0x15;
14443 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014444 spec->ext_mic.pin = 0x18;
14445 spec->ext_mic.mux_idx = 0;
14446 spec->int_mic.pin = 0x12;
14447 spec->int_mic.mux_idx = 5;
14448 spec->auto_mic = 1;
14449}
14450
Kailang Yang226b1ec2010-04-09 11:01:20 +020014451static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014452{
14453 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014454 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014455 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014456 spec->ext_mic.pin = 0x18;
14457 spec->ext_mic.mux_idx = 0;
14458 spec->int_mic.pin = 0x19;
14459 spec->int_mic.mux_idx = 1;
14460 spec->auto_mic = 1;
14461}
14462
Kailang Yang226b1ec2010-04-09 11:01:20 +020014463static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14464{
14465 struct alc_spec *spec = codec->spec;
14466 spec->autocfg.hp_pins[0] = 0x21;
14467 spec->autocfg.speaker_pins[0] = 0x14;
14468 spec->ext_mic.pin = 0x18;
14469 spec->ext_mic.mux_idx = 0;
14470 spec->int_mic.pin = 0x12;
14471 spec->int_mic.mux_idx = 6;
14472 spec->auto_mic = 1;
14473}
14474
Kailang Yang84898e82010-02-04 14:16:14 +010014475static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014476{
14477 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014478 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014479}
14480
Kailang Yangf6a92242007-12-13 16:52:54 +010014481/*
14482 * generic initialization of ADC, input mixers and output mixers
14483 */
14484static struct hda_verb alc269_init_verbs[] = {
14485 /*
14486 * Unmute ADC0 and set the default input to mic-in
14487 */
Kailang Yang84898e82010-02-04 14:16:14 +010014488 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014489
14490 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014491 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014492 */
14493 /* set vol=0 to output mixers */
14494 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14495 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14496
14497 /* set up input amps for analog loopback */
14498 /* Amp Indices: DAC = 0, mixer = 1 */
14499 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14501 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14503 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14505
14506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14507 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14508 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14509 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14510 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14512 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14513
14514 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14515 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014516
Kailang Yang84898e82010-02-04 14:16:14 +010014517 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014518 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14519 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014520 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014521
14522 /* set EAPD */
14523 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014524 { }
14525};
14526
14527static struct hda_verb alc269vb_init_verbs[] = {
14528 /*
14529 * Unmute ADC0 and set the default input to mic-in
14530 */
14531 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14532
14533 /*
14534 * Set up output mixers (0x02 - 0x03)
14535 */
14536 /* set vol=0 to output mixers */
14537 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14538 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14539
14540 /* set up input amps for analog loopback */
14541 /* Amp Indices: DAC = 0, mixer = 1 */
14542 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14544 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14546 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14547 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14548
14549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14550 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14551 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14556
14557 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14558 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14559
14560 /* FIXME: use Mux-type input source selection */
14561 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14562 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14563 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14564
14565 /* set EAPD */
14566 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014567 { }
14568};
14569
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014570#define alc269_auto_create_multi_out_ctls \
14571 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014572#define alc269_auto_create_input_ctls \
14573 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014574
14575#ifdef CONFIG_SND_HDA_POWER_SAVE
14576#define alc269_loopbacks alc880_loopbacks
14577#endif
14578
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014579/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014580#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14581#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14582#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14583#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14584
Takashi Iwaif03d3112009-03-05 14:18:16 +010014585static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14586 .substreams = 1,
14587 .channels_min = 2,
14588 .channels_max = 8,
14589 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14590 /* NID is set in alc_build_pcms */
14591 .ops = {
14592 .open = alc880_playback_pcm_open,
14593 .prepare = alc880_playback_pcm_prepare,
14594 .cleanup = alc880_playback_pcm_cleanup
14595 },
14596};
14597
14598static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14599 .substreams = 1,
14600 .channels_min = 2,
14601 .channels_max = 2,
14602 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14603 /* NID is set in alc_build_pcms */
14604};
14605
Takashi Iwaiad358792010-03-30 18:00:59 +020014606#ifdef CONFIG_SND_HDA_POWER_SAVE
14607static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14608{
14609 switch (codec->subsystem_id) {
14610 case 0x103c1586:
14611 return 1;
14612 }
14613 return 0;
14614}
14615
14616static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14617{
14618 /* update mute-LED according to the speaker mute state */
14619 if (nid == 0x01 || nid == 0x14) {
14620 int pinval;
14621 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14622 HDA_AMP_MUTE)
14623 pinval = 0x24;
14624 else
14625 pinval = 0x20;
14626 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014627 snd_hda_codec_update_cache(codec, 0x19, 0,
14628 AC_VERB_SET_PIN_WIDGET_CONTROL,
14629 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014630 }
14631 return alc_check_power_status(codec, nid);
14632}
14633#endif /* CONFIG_SND_HDA_POWER_SAVE */
14634
Takashi Iwai840b64c2010-07-13 22:49:01 +020014635static int alc275_setup_dual_adc(struct hda_codec *codec)
14636{
14637 struct alc_spec *spec = codec->spec;
14638
14639 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14640 return 0;
14641 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14642 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14643 if (spec->ext_mic.pin <= 0x12) {
14644 spec->private_adc_nids[0] = 0x08;
14645 spec->private_adc_nids[1] = 0x11;
14646 spec->private_capsrc_nids[0] = 0x23;
14647 spec->private_capsrc_nids[1] = 0x22;
14648 } else {
14649 spec->private_adc_nids[0] = 0x11;
14650 spec->private_adc_nids[1] = 0x08;
14651 spec->private_capsrc_nids[0] = 0x22;
14652 spec->private_capsrc_nids[1] = 0x23;
14653 }
14654 spec->adc_nids = spec->private_adc_nids;
14655 spec->capsrc_nids = spec->private_capsrc_nids;
14656 spec->num_adc_nids = 2;
14657 spec->dual_adc_switch = 1;
14658 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14659 spec->adc_nids[0], spec->adc_nids[1]);
14660 return 1;
14661 }
14662 return 0;
14663}
14664
Takashi Iwaid433a672010-09-20 15:11:54 +020014665/* different alc269-variants */
14666enum {
14667 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014668 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014669 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014670 ALC269_TYPE_ALC269VB,
14671 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014672 ALC269_TYPE_ALC271X,
14673};
14674
Kailang Yangf6a92242007-12-13 16:52:54 +010014675/*
14676 * BIOS auto configuration
14677 */
14678static int alc269_parse_auto_config(struct hda_codec *codec)
14679{
14680 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014681 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014682 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14683
14684 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14685 alc269_ignore);
14686 if (err < 0)
14687 return err;
14688
14689 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14690 if (err < 0)
14691 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014692 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14693 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14694 else
14695 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14696 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014697 if (err < 0)
14698 return err;
14699
14700 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14701
Takashi Iwai757899a2010-07-30 10:48:14 +020014702 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014703
Takashi Iwai603c4012008-07-30 15:01:44 +020014704 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014705 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014706
Takashi Iwaid433a672010-09-20 15:11:54 +020014707 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014708 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014709 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014710 } else {
14711 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014712 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014713 }
14714
Kailang Yangf6a92242007-12-13 16:52:54 +010014715 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014716 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014717
14718 if (!alc275_setup_dual_adc(codec))
14719 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14720 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014721
Takashi Iwaie01bf502008-08-21 16:25:07 +020014722 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014723 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014724 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14725 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014726
14727 err = alc_auto_add_mic_boost(codec);
14728 if (err < 0)
14729 return err;
14730
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014731 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014732 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014733
Kailang Yangf6a92242007-12-13 16:52:54 +010014734 return 1;
14735}
14736
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014737#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14738#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014739#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14740
14741
14742/* init callback for auto-configuration model -- overriding the default init */
14743static void alc269_auto_init(struct hda_codec *codec)
14744{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014745 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014746 alc269_auto_init_multi_out(codec);
14747 alc269_auto_init_hp_out(codec);
14748 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014749 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014750 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014751 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014752}
14753
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014754#ifdef SND_HDA_NEEDS_RESUME
14755static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14756{
14757 int val = alc_read_coef_idx(codec, 0x04);
14758 if (power_up)
14759 val |= 1 << 11;
14760 else
14761 val &= ~(1 << 11);
14762 alc_write_coef_idx(codec, 0x04, val);
14763}
14764
Kailang Yang977ddd62010-09-15 10:02:29 +020014765#ifdef CONFIG_SND_HDA_POWER_SAVE
14766static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14767{
14768 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014769
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014770 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14771 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014772 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014773 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014774 msleep(150);
14775 }
14776
14777 alc_shutup(codec);
14778 if (spec && spec->power_hook)
14779 spec->power_hook(codec);
14780 return 0;
14781}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014782#endif /* CONFIG_SND_HDA_POWER_SAVE */
14783
Kailang Yang977ddd62010-09-15 10:02:29 +020014784static int alc269_resume(struct hda_codec *codec)
14785{
Kailang Yang977ddd62010-09-15 10:02:29 +020014786 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014787 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014788 msleep(150);
14789 }
14790
14791 codec->patch_ops.init(codec);
14792
14793 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014794 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014795 msleep(200);
14796 }
14797
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014798 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14799 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014800
14801 snd_hda_codec_resume_amp(codec);
14802 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014803 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014804 return 0;
14805}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014806#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014807
Takashi Iwaiff818c22010-04-12 08:59:25 +020014808enum {
14809 ALC269_FIXUP_SONY_VAIO,
David Henningsson145a9022010-09-16 10:07:53 +020014810 ALC269_FIXUP_DELL_M101Z,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014811};
14812
Takashi Iwaiff818c22010-04-12 08:59:25 +020014813static const struct alc_fixup alc269_fixups[] = {
14814 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014815 .verbs = (const struct hda_verb[]) {
14816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14817 {}
14818 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014819 },
David Henningsson145a9022010-09-16 10:07:53 +020014820 [ALC269_FIXUP_DELL_M101Z] = {
14821 .verbs = (const struct hda_verb[]) {
14822 /* Enables internal speaker */
14823 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14824 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14825 {}
14826 }
14827 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014828};
14829
14830static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwaiabdd8f52010-09-21 17:38:14 +020014831 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014832 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014833 {}
14834};
14835
14836
Kailang Yangf6a92242007-12-13 16:52:54 +010014837/*
14838 * configuration and preset
14839 */
14840static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014841 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014842 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014843 [ALC269_AMIC] = "laptop-amic",
14844 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014845 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014846 [ALC269_LIFEBOOK] = "lifebook",
14847 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014848};
14849
14850static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014851 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014852 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014853 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014854 ALC269_AMIC),
14855 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14856 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14857 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14858 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14859 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14860 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14861 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14862 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14863 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14864 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14865 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14866 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14867 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14868 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14869 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14870 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14871 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14872 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14873 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14874 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14875 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14876 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14877 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14878 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14879 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14880 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14881 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14882 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14883 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14884 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14885 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14886 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14887 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14888 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14889 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14890 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014891 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014892 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014893 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014894 ALC269_DMIC),
14895 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14896 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014897 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014898 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014899 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14900 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14901 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14902 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14903 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14904 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014905 {}
14906};
14907
14908static struct alc_config_preset alc269_presets[] = {
14909 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014910 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014911 .init_verbs = { alc269_init_verbs },
14912 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14913 .dac_nids = alc269_dac_nids,
14914 .hp_nid = 0x03,
14915 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14916 .channel_mode = alc269_modes,
14917 .input_mux = &alc269_capture_source,
14918 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014919 [ALC269_QUANTA_FL1] = {
14920 .mixers = { alc269_quanta_fl1_mixer },
14921 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14922 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14923 .dac_nids = alc269_dac_nids,
14924 .hp_nid = 0x03,
14925 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14926 .channel_mode = alc269_modes,
14927 .input_mux = &alc269_capture_source,
14928 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014929 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014930 .init_hook = alc269_quanta_fl1_init_hook,
14931 },
Kailang Yang84898e82010-02-04 14:16:14 +010014932 [ALC269_AMIC] = {
14933 .mixers = { alc269_laptop_mixer },
14934 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014935 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014936 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014937 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14938 .dac_nids = alc269_dac_nids,
14939 .hp_nid = 0x03,
14940 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14941 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014942 .unsol_event = alc269_laptop_unsol_event,
14943 .setup = alc269_laptop_amic_setup,
14944 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014945 },
Kailang Yang84898e82010-02-04 14:16:14 +010014946 [ALC269_DMIC] = {
14947 .mixers = { alc269_laptop_mixer },
14948 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014949 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014950 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014951 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14952 .dac_nids = alc269_dac_nids,
14953 .hp_nid = 0x03,
14954 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14955 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014956 .unsol_event = alc269_laptop_unsol_event,
14957 .setup = alc269_laptop_dmic_setup,
14958 .init_hook = alc269_laptop_inithook,
14959 },
14960 [ALC269VB_AMIC] = {
14961 .mixers = { alc269vb_laptop_mixer },
14962 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14963 .init_verbs = { alc269vb_init_verbs,
14964 alc269vb_laptop_amic_init_verbs },
14965 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14966 .dac_nids = alc269_dac_nids,
14967 .hp_nid = 0x03,
14968 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14969 .channel_mode = alc269_modes,
14970 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014971 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014972 .init_hook = alc269_laptop_inithook,
14973 },
14974 [ALC269VB_DMIC] = {
14975 .mixers = { alc269vb_laptop_mixer },
14976 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14977 .init_verbs = { alc269vb_init_verbs,
14978 alc269vb_laptop_dmic_init_verbs },
14979 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14980 .dac_nids = alc269_dac_nids,
14981 .hp_nid = 0x03,
14982 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14983 .channel_mode = alc269_modes,
14984 .unsol_event = alc269_laptop_unsol_event,
14985 .setup = alc269vb_laptop_dmic_setup,
14986 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014987 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014988 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014989 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014990 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014991 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014992 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014993 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14994 .dac_nids = alc269_dac_nids,
14995 .hp_nid = 0x03,
14996 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14997 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014998 .unsol_event = alc269_laptop_unsol_event,
14999 .setup = alc269_laptop_dmic_setup,
15000 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015001 },
Tony Vroon64154832008-11-06 15:08:49 +000015002 [ALC269_LIFEBOOK] = {
15003 .mixers = { alc269_lifebook_mixer },
15004 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15005 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15006 .dac_nids = alc269_dac_nids,
15007 .hp_nid = 0x03,
15008 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15009 .channel_mode = alc269_modes,
15010 .input_mux = &alc269_capture_source,
15011 .unsol_event = alc269_lifebook_unsol_event,
15012 .init_hook = alc269_lifebook_init_hook,
15013 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015014 [ALC271_ACER] = {
15015 .mixers = { alc269_asus_mixer },
15016 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15017 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15018 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15019 .dac_nids = alc269_dac_nids,
15020 .adc_nids = alc262_dmic_adc_nids,
15021 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15022 .capsrc_nids = alc262_dmic_capsrc_nids,
15023 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15024 .channel_mode = alc269_modes,
15025 .input_mux = &alc269_capture_source,
15026 .dig_out_nid = ALC880_DIGOUT_NID,
15027 .unsol_event = alc_sku_unsol_event,
15028 .setup = alc269vb_laptop_dmic_setup,
15029 .init_hook = alc_inithook,
15030 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015031};
15032
Kailang Yang977ddd62010-09-15 10:02:29 +020015033static int alc269_fill_coef(struct hda_codec *codec)
15034{
15035 int val;
15036
15037 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15038 alc_write_coef_idx(codec, 0xf, 0x960b);
15039 alc_write_coef_idx(codec, 0xe, 0x8817);
15040 }
15041
15042 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15043 alc_write_coef_idx(codec, 0xf, 0x960b);
15044 alc_write_coef_idx(codec, 0xe, 0x8814);
15045 }
15046
15047 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15048 val = alc_read_coef_idx(codec, 0x04);
15049 /* Power up output pin */
15050 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15051 }
15052
15053 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15054 val = alc_read_coef_idx(codec, 0xd);
15055 if ((val & 0x0c00) >> 10 != 0x1) {
15056 /* Capless ramp up clock control */
15057 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15058 }
15059 val = alc_read_coef_idx(codec, 0x17);
15060 if ((val & 0x01c0) >> 6 != 0x4) {
15061 /* Class D power on reset */
15062 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15063 }
15064 }
15065 return 0;
15066}
15067
Kailang Yangf6a92242007-12-13 16:52:54 +010015068static int patch_alc269(struct hda_codec *codec)
15069{
15070 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015071 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015072 int err;
15073
15074 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15075 if (spec == NULL)
15076 return -ENOMEM;
15077
15078 codec->spec = spec;
15079
Kailang Yangda00c242010-03-19 11:23:45 +010015080 alc_auto_parse_customize_define(codec);
15081
Kailang Yang48c88e82010-11-23 08:56:16 +010015082 coef = alc_read_coef_idx(codec, 0);
15083 if ((coef & 0x00f0) == 0x0010) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015084 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaid433a672010-09-20 15:11:54 +020015085 spec->cdefine.platform_type == 1) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015086 alc_codec_rename(codec, "ALC271X");
Takashi Iwaid433a672010-09-20 15:11:54 +020015087 spec->codec_variant = ALC269_TYPE_ALC271X;
Kailang Yang48c88e82010-11-23 08:56:16 +010015088 } else if ((coef & 0xf000) == 0x1000) {
15089 spec->codec_variant = ALC269_TYPE_ALC270;
15090 } else if ((coef & 0xf000) == 0x2000) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015091 alc_codec_rename(codec, "ALC259");
Takashi Iwaid433a672010-09-20 15:11:54 +020015092 spec->codec_variant = ALC269_TYPE_ALC259;
Kailang Yang48c88e82010-11-23 08:56:16 +010015093 } else if ((coef & 0xf000) == 0x3000) {
15094 alc_codec_rename(codec, "ALC258");
15095 spec->codec_variant = ALC269_TYPE_ALC258;
15096 } else {
15097 alc_codec_rename(codec, "ALC269VB");
15098 spec->codec_variant = ALC269_TYPE_ALC269VB;
Takashi Iwaid433a672010-09-20 15:11:54 +020015099 }
Kailang Yangc027ddc2010-03-19 11:33:06 +010015100 } else
15101 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010015102
Kailang Yang977ddd62010-09-15 10:02:29 +020015103 alc269_fill_coef(codec);
15104
Kailang Yangf6a92242007-12-13 16:52:54 +010015105 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15106 alc269_models,
15107 alc269_cfg_tbl);
15108
15109 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015110 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15111 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015112 board_config = ALC269_AUTO;
15113 }
15114
Takashi Iwaiff818c22010-04-12 08:59:25 +020015115 if (board_config == ALC269_AUTO)
15116 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
15117
Kailang Yangf6a92242007-12-13 16:52:54 +010015118 if (board_config == ALC269_AUTO) {
15119 /* automatic parse from the BIOS config */
15120 err = alc269_parse_auto_config(codec);
15121 if (err < 0) {
15122 alc_free(codec);
15123 return err;
15124 } else if (!err) {
15125 printk(KERN_INFO
15126 "hda_codec: Cannot set up configuration "
15127 "from BIOS. Using base mode...\n");
15128 board_config = ALC269_BASIC;
15129 }
15130 }
15131
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015132 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015133 err = snd_hda_attach_beep_device(codec, 0x1);
15134 if (err < 0) {
15135 alc_free(codec);
15136 return err;
15137 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015138 }
15139
Kailang Yangf6a92242007-12-13 16:52:54 +010015140 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015141 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015142
Kailang Yang84898e82010-02-04 14:16:14 +010015143 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015144 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15145 * fix the sample rate of analog I/O to 44.1kHz
15146 */
15147 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15148 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015149 } else if (spec->dual_adc_switch) {
15150 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15151 /* switch ADC dynamically */
15152 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015153 } else {
15154 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15155 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15156 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015157 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15158 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15159
Takashi Iwai66946352010-03-29 17:21:45 +020015160 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015161 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015162 spec->adc_nids = alc269_adc_nids;
15163 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15164 spec->capsrc_nids = alc269_capsrc_nids;
15165 } else {
15166 spec->adc_nids = alc269vb_adc_nids;
15167 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15168 spec->capsrc_nids = alc269vb_capsrc_nids;
15169 }
Kailang Yang84898e82010-02-04 14:16:14 +010015170 }
15171
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015172 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015173 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015174 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015175 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015176
Takashi Iwaiff818c22010-04-12 08:59:25 +020015177 if (board_config == ALC269_AUTO)
15178 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15179
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015180 spec->vmaster_nid = 0x02;
15181
Kailang Yangf6a92242007-12-13 16:52:54 +010015182 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015183#ifdef CONFIG_SND_HDA_POWER_SAVE
15184 codec->patch_ops.suspend = alc269_suspend;
15185#endif
15186#ifdef SND_HDA_NEEDS_RESUME
15187 codec->patch_ops.resume = alc269_resume;
15188#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015189 if (board_config == ALC269_AUTO)
15190 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015191
15192 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015193#ifdef CONFIG_SND_HDA_POWER_SAVE
15194 if (!spec->loopback.amplist)
15195 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015196 if (alc269_mic2_for_mute_led(codec))
15197 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015198#endif
15199
15200 return 0;
15201}
15202
15203/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015204 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15205 */
15206
15207/*
15208 * set the path ways for 2 channel output
15209 * need to set the codec line out and mic 1 pin widgets to inputs
15210 */
15211static struct hda_verb alc861_threestack_ch2_init[] = {
15212 /* set pin widget 1Ah (line in) for input */
15213 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015214 /* set pin widget 18h (mic1/2) for input, for mic also enable
15215 * the vref
15216 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015217 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15218
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015219 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15220#if 0
15221 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15222 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15223#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015224 { } /* end */
15225};
15226/*
15227 * 6ch mode
15228 * need to set the codec line out and mic 1 pin widgets to outputs
15229 */
15230static struct hda_verb alc861_threestack_ch6_init[] = {
15231 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15232 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15233 /* set pin widget 18h (mic1) for output (CLFE)*/
15234 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15235
15236 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015237 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015238
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015239 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15240#if 0
15241 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15242 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15243#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015244 { } /* end */
15245};
15246
15247static struct hda_channel_mode alc861_threestack_modes[2] = {
15248 { 2, alc861_threestack_ch2_init },
15249 { 6, alc861_threestack_ch6_init },
15250};
Takashi Iwai22309c32006-08-09 16:57:28 +020015251/* Set mic1 as input and unmute the mixer */
15252static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15253 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15254 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15255 { } /* end */
15256};
15257/* Set mic1 as output and mute mixer */
15258static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15259 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15260 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15261 { } /* end */
15262};
15263
15264static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15265 { 2, alc861_uniwill_m31_ch2_init },
15266 { 4, alc861_uniwill_m31_ch4_init },
15267};
Kailang Yangdf694da2005-12-05 19:42:22 +010015268
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015269/* Set mic1 and line-in as input and unmute the mixer */
15270static struct hda_verb alc861_asus_ch2_init[] = {
15271 /* set pin widget 1Ah (line in) for input */
15272 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015273 /* set pin widget 18h (mic1/2) for input, for mic also enable
15274 * the vref
15275 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015276 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15277
15278 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15279#if 0
15280 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15281 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15282#endif
15283 { } /* end */
15284};
15285/* Set mic1 nad line-in as output and mute mixer */
15286static struct hda_verb alc861_asus_ch6_init[] = {
15287 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15288 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15289 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15290 /* set pin widget 18h (mic1) for output (CLFE)*/
15291 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15292 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15293 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15294 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15295
15296 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15297#if 0
15298 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15299 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15300#endif
15301 { } /* end */
15302};
15303
15304static struct hda_channel_mode alc861_asus_modes[2] = {
15305 { 2, alc861_asus_ch2_init },
15306 { 6, alc861_asus_ch6_init },
15307};
15308
Kailang Yangdf694da2005-12-05 19:42:22 +010015309/* patch-ALC861 */
15310
15311static struct snd_kcontrol_new alc861_base_mixer[] = {
15312 /* output mixer control */
15313 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15314 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15315 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15316 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15317 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15318
15319 /*Input mixer control */
15320 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15321 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15322 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15323 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15324 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15325 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15327 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15328 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015330
Kailang Yangdf694da2005-12-05 19:42:22 +010015331 { } /* end */
15332};
15333
15334static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15335 /* output mixer control */
15336 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15337 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15338 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15339 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15340 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15341
15342 /* Input mixer control */
15343 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15344 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15345 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15346 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15347 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15348 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15349 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15350 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15351 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015353
Kailang Yangdf694da2005-12-05 19:42:22 +010015354 {
15355 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15356 .name = "Channel Mode",
15357 .info = alc_ch_mode_info,
15358 .get = alc_ch_mode_get,
15359 .put = alc_ch_mode_put,
15360 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15361 },
15362 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015363};
15364
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015365static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015366 /* output mixer control */
15367 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15369 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015370
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015371 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015372};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015373
Takashi Iwai22309c32006-08-09 16:57:28 +020015374static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15375 /* output mixer control */
15376 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15377 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15378 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15379 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15380 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15381
15382 /* Input mixer control */
15383 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15384 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15385 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15386 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15387 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15388 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15390 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15391 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15392 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015393
Takashi Iwai22309c32006-08-09 16:57:28 +020015394 {
15395 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15396 .name = "Channel Mode",
15397 .info = alc_ch_mode_info,
15398 .get = alc_ch_mode_get,
15399 .put = alc_ch_mode_put,
15400 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15401 },
15402 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015403};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015404
15405static struct snd_kcontrol_new alc861_asus_mixer[] = {
15406 /* output mixer control */
15407 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15408 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15409 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15410 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15411 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15412
15413 /* Input mixer control */
15414 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15415 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15416 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15417 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15418 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15419 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15421 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15422 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015423 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15424
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015425 {
15426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15427 .name = "Channel Mode",
15428 .info = alc_ch_mode_info,
15429 .get = alc_ch_mode_get,
15430 .put = alc_ch_mode_put,
15431 .private_value = ARRAY_SIZE(alc861_asus_modes),
15432 },
15433 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015434};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015435
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015436/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015437static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015438 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15439 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015440 { }
15441};
15442
Kailang Yangdf694da2005-12-05 19:42:22 +010015443/*
15444 * generic initialization of ADC, input mixers and output mixers
15445 */
15446static struct hda_verb alc861_base_init_verbs[] = {
15447 /*
15448 * Unmute ADC0 and set the default input to mic-in
15449 */
15450 /* port-A for surround (rear panel) */
15451 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15452 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15453 /* port-B for mic-in (rear panel) with vref */
15454 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15455 /* port-C for line-in (rear panel) */
15456 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15457 /* port-D for Front */
15458 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15459 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15460 /* port-E for HP out (front panel) */
15461 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15462 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015463 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015464 /* port-F for mic-in (front panel) with vref */
15465 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15466 /* port-G for CLFE (rear panel) */
15467 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15468 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15469 /* port-H for side (rear panel) */
15470 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15471 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15472 /* CD-in */
15473 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15474 /* route front mic to ADC1*/
15475 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15476 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015477
Kailang Yangdf694da2005-12-05 19:42:22 +010015478 /* Unmute DAC0~3 & spdif out*/
15479 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15480 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15481 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15482 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15483 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015484
Kailang Yangdf694da2005-12-05 19:42:22 +010015485 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15486 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15487 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15488 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15489 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015490
Kailang Yangdf694da2005-12-05 19:42:22 +010015491 /* Unmute Stereo Mixer 15 */
15492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15493 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015496
15497 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15498 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15499 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15500 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15501 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15502 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15504 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015505 /* hp used DAC 3 (Front) */
15506 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15508
15509 { }
15510};
15511
15512static struct hda_verb alc861_threestack_init_verbs[] = {
15513 /*
15514 * Unmute ADC0 and set the default input to mic-in
15515 */
15516 /* port-A for surround (rear panel) */
15517 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15518 /* port-B for mic-in (rear panel) with vref */
15519 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15520 /* port-C for line-in (rear panel) */
15521 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15522 /* port-D for Front */
15523 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15524 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15525 /* port-E for HP out (front panel) */
15526 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15527 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015528 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015529 /* port-F for mic-in (front panel) with vref */
15530 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15531 /* port-G for CLFE (rear panel) */
15532 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15533 /* port-H for side (rear panel) */
15534 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15535 /* CD-in */
15536 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15537 /* route front mic to ADC1*/
15538 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15540 /* Unmute DAC0~3 & spdif out*/
15541 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15542 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15543 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15544 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015546
Kailang Yangdf694da2005-12-05 19:42:22 +010015547 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15548 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15549 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15550 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15551 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015552
Kailang Yangdf694da2005-12-05 19:42:22 +010015553 /* Unmute Stereo Mixer 15 */
15554 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15555 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15556 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015558
15559 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15560 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15561 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15562 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15563 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15564 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15566 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015567 /* hp used DAC 3 (Front) */
15568 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015569 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15570 { }
15571};
Takashi Iwai22309c32006-08-09 16:57:28 +020015572
15573static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15574 /*
15575 * Unmute ADC0 and set the default input to mic-in
15576 */
15577 /* port-A for surround (rear panel) */
15578 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15579 /* port-B for mic-in (rear panel) with vref */
15580 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15581 /* port-C for line-in (rear panel) */
15582 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15583 /* port-D for Front */
15584 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15585 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15586 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015587 /* this has to be set to VREF80 */
15588 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015589 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015590 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015591 /* port-F for mic-in (front panel) with vref */
15592 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15593 /* port-G for CLFE (rear panel) */
15594 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15595 /* port-H for side (rear panel) */
15596 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15597 /* CD-in */
15598 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15599 /* route front mic to ADC1*/
15600 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15601 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15602 /* Unmute DAC0~3 & spdif out*/
15603 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15604 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15605 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15606 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15607 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015608
Takashi Iwai22309c32006-08-09 16:57:28 +020015609 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15610 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15611 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15612 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15613 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015614
Takashi Iwai22309c32006-08-09 16:57:28 +020015615 /* Unmute Stereo Mixer 15 */
15616 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15617 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15618 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015619 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015620
15621 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15622 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15623 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15624 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15625 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15626 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15627 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15628 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015629 /* hp used DAC 3 (Front) */
15630 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015631 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15632 { }
15633};
15634
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015635static struct hda_verb alc861_asus_init_verbs[] = {
15636 /*
15637 * Unmute ADC0 and set the default input to mic-in
15638 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015639 /* port-A for surround (rear panel)
15640 * according to codec#0 this is the HP jack
15641 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015642 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15643 /* route front PCM to HP */
15644 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15645 /* port-B for mic-in (rear panel) with vref */
15646 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15647 /* port-C for line-in (rear panel) */
15648 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15649 /* port-D for Front */
15650 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15651 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15652 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015653 /* this has to be set to VREF80 */
15654 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015655 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015656 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015657 /* port-F for mic-in (front panel) with vref */
15658 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15659 /* port-G for CLFE (rear panel) */
15660 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15661 /* port-H for side (rear panel) */
15662 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15663 /* CD-in */
15664 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15665 /* route front mic to ADC1*/
15666 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15668 /* Unmute DAC0~3 & spdif out*/
15669 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15670 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15671 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15672 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15674 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15675 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15676 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15677 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15678 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015679
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015680 /* Unmute Stereo Mixer 15 */
15681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015685
15686 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15687 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15689 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15690 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15691 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15692 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15693 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015694 /* hp used DAC 3 (Front) */
15695 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015696 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15697 { }
15698};
15699
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015700/* additional init verbs for ASUS laptops */
15701static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15702 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15703 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15704 { }
15705};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015706
Kailang Yangdf694da2005-12-05 19:42:22 +010015707/*
15708 * generic initialization of ADC, input mixers and output mixers
15709 */
15710static struct hda_verb alc861_auto_init_verbs[] = {
15711 /*
15712 * Unmute ADC0 and set the default input to mic-in
15713 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015714 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015716
Kailang Yangdf694da2005-12-05 19:42:22 +010015717 /* Unmute DAC0~3 & spdif out*/
15718 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15719 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15720 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15721 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015723
Kailang Yangdf694da2005-12-05 19:42:22 +010015724 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15725 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15726 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15727 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15728 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015729
Kailang Yangdf694da2005-12-05 19:42:22 +010015730 /* Unmute Stereo Mixer 15 */
15731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15733 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15735
Takashi Iwai1c209302009-07-22 15:17:45 +020015736 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15737 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15738 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15739 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15743 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015744
15745 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15746 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015747 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015749 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15750 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015751 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15752 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015753
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015754 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015755
15756 { }
15757};
15758
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015759static struct hda_verb alc861_toshiba_init_verbs[] = {
15760 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015761
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015762 { }
15763};
15764
15765/* toggle speaker-output according to the hp-jack state */
15766static void alc861_toshiba_automute(struct hda_codec *codec)
15767{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015768 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015769
Takashi Iwai47fd8302007-08-10 17:11:07 +020015770 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15771 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15772 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15773 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015774}
15775
15776static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15777 unsigned int res)
15778{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015779 if ((res >> 26) == ALC880_HP_EVENT)
15780 alc861_toshiba_automute(codec);
15781}
15782
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015783/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015784#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15785#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15786#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15787#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15788
15789
15790#define ALC861_DIGOUT_NID 0x07
15791
15792static struct hda_channel_mode alc861_8ch_modes[1] = {
15793 { 8, NULL }
15794};
15795
15796static hda_nid_t alc861_dac_nids[4] = {
15797 /* front, surround, clfe, side */
15798 0x03, 0x06, 0x05, 0x04
15799};
15800
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015801static hda_nid_t alc660_dac_nids[3] = {
15802 /* front, clfe, surround */
15803 0x03, 0x05, 0x06
15804};
15805
Kailang Yangdf694da2005-12-05 19:42:22 +010015806static hda_nid_t alc861_adc_nids[1] = {
15807 /* ADC0-2 */
15808 0x08,
15809};
15810
15811static struct hda_input_mux alc861_capture_source = {
15812 .num_items = 5,
15813 .items = {
15814 { "Mic", 0x0 },
15815 { "Front Mic", 0x3 },
15816 { "Line", 0x1 },
15817 { "CD", 0x4 },
15818 { "Mixer", 0x5 },
15819 },
15820};
15821
Takashi Iwai1c209302009-07-22 15:17:45 +020015822static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15823{
15824 struct alc_spec *spec = codec->spec;
15825 hda_nid_t mix, srcs[5];
15826 int i, j, num;
15827
15828 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15829 return 0;
15830 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15831 if (num < 0)
15832 return 0;
15833 for (i = 0; i < num; i++) {
15834 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015835 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015836 if (type != AC_WID_AUD_OUT)
15837 continue;
15838 for (j = 0; j < spec->multiout.num_dacs; j++)
15839 if (spec->multiout.dac_nids[j] == srcs[i])
15840 break;
15841 if (j >= spec->multiout.num_dacs)
15842 return srcs[i];
15843 }
15844 return 0;
15845}
15846
Kailang Yangdf694da2005-12-05 19:42:22 +010015847/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015848static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015849 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015850{
Takashi Iwai1c209302009-07-22 15:17:45 +020015851 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015852 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015853 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015854
15855 spec->multiout.dac_nids = spec->private_dac_nids;
15856 for (i = 0; i < cfg->line_outs; i++) {
15857 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015858 dac = alc861_look_for_dac(codec, nid);
15859 if (!dac)
15860 continue;
15861 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015862 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015863 return 0;
15864}
15865
Takashi Iwai1c209302009-07-22 15:17:45 +020015866static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15867 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015868{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015869 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015870 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15871}
15872
15873/* add playback controls from the parsed DAC table */
15874static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15875 const struct auto_pin_cfg *cfg)
15876{
15877 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015878 static const char *chname[4] = {
15879 "Front", "Surround", NULL /*CLFE*/, "Side"
15880 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015881 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015882 int i, err;
15883
15884 if (cfg->line_outs == 1) {
15885 const char *pfx = NULL;
15886 if (!cfg->hp_outs)
15887 pfx = "Master";
15888 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15889 pfx = "Speaker";
15890 if (pfx) {
15891 nid = spec->multiout.dac_nids[0];
15892 return alc861_create_out_sw(codec, pfx, nid, 3);
15893 }
15894 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015895
15896 for (i = 0; i < cfg->line_outs; i++) {
15897 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015898 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015899 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015900 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015901 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015902 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015903 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015904 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015905 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015906 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015907 return err;
15908 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015909 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015910 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015911 return err;
15912 }
15913 }
15914 return 0;
15915}
15916
Takashi Iwai1c209302009-07-22 15:17:45 +020015917static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015918{
Takashi Iwai1c209302009-07-22 15:17:45 +020015919 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015920 int err;
15921 hda_nid_t nid;
15922
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015923 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015924 return 0;
15925
15926 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015927 nid = alc861_look_for_dac(codec, pin);
15928 if (nid) {
15929 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15930 if (err < 0)
15931 return err;
15932 spec->multiout.hp_nid = nid;
15933 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015934 }
15935 return 0;
15936}
15937
15938/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015939static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015940 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015941{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015942 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015943}
15944
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015945static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15946 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015947 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015948{
Takashi Iwai1c209302009-07-22 15:17:45 +020015949 hda_nid_t mix, srcs[5];
15950 int i, num;
15951
Jacek Luczak564c5be2008-05-03 18:41:23 +020015952 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15953 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015954 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015955 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015956 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15957 return;
15958 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15959 if (num < 0)
15960 return;
15961 for (i = 0; i < num; i++) {
15962 unsigned int mute;
15963 if (srcs[i] == dac || srcs[i] == 0x15)
15964 mute = AMP_IN_UNMUTE(i);
15965 else
15966 mute = AMP_IN_MUTE(i);
15967 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15968 mute);
15969 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015970}
15971
15972static void alc861_auto_init_multi_out(struct hda_codec *codec)
15973{
15974 struct alc_spec *spec = codec->spec;
15975 int i;
15976
15977 for (i = 0; i < spec->autocfg.line_outs; i++) {
15978 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015979 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015980 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015981 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015982 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015983 }
15984}
15985
15986static void alc861_auto_init_hp_out(struct hda_codec *codec)
15987{
15988 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015989
Takashi Iwai15870f02009-10-05 08:25:13 +020015990 if (spec->autocfg.hp_outs)
15991 alc861_auto_set_output_and_unmute(codec,
15992 spec->autocfg.hp_pins[0],
15993 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015994 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015995 if (spec->autocfg.speaker_outs)
15996 alc861_auto_set_output_and_unmute(codec,
15997 spec->autocfg.speaker_pins[0],
15998 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015999 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016000}
16001
16002static void alc861_auto_init_analog_input(struct hda_codec *codec)
16003{
16004 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016005 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016006 int i;
16007
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016008 for (i = 0; i < cfg->num_inputs; i++) {
16009 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016010 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016011 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016012 }
16013}
16014
16015/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016016/* return 1 if successful, 0 if the proper config is not found,
16017 * or a negative error code
16018 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016019static int alc861_parse_auto_config(struct hda_codec *codec)
16020{
16021 struct alc_spec *spec = codec->spec;
16022 int err;
16023 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16024
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016025 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16026 alc861_ignore);
16027 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016028 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016029 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016030 return 0; /* can't find valid BIOS pin config */
16031
Takashi Iwai1c209302009-07-22 15:17:45 +020016032 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016033 if (err < 0)
16034 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016035 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016036 if (err < 0)
16037 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016038 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016039 if (err < 0)
16040 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016041 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016042 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016043 return err;
16044
16045 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16046
Takashi Iwai757899a2010-07-30 10:48:14 +020016047 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016048
Takashi Iwai603c4012008-07-30 15:01:44 +020016049 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016050 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016051
Takashi Iwaid88897e2008-10-31 15:01:37 +010016052 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016053
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016054 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016055 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016056
16057 spec->adc_nids = alc861_adc_nids;
16058 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016059 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016060
Kailang Yang6227cdc2010-02-25 08:36:52 +010016061 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016062
Kailang Yangdf694da2005-12-05 19:42:22 +010016063 return 1;
16064}
16065
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016066/* additional initialization for auto-configuration model */
16067static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016068{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016069 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016070 alc861_auto_init_multi_out(codec);
16071 alc861_auto_init_hp_out(codec);
16072 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016073 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016074 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016075 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016076}
16077
Takashi Iwaicb53c622007-08-10 17:21:45 +020016078#ifdef CONFIG_SND_HDA_POWER_SAVE
16079static struct hda_amp_list alc861_loopbacks[] = {
16080 { 0x15, HDA_INPUT, 0 },
16081 { 0x15, HDA_INPUT, 1 },
16082 { 0x15, HDA_INPUT, 2 },
16083 { 0x15, HDA_INPUT, 3 },
16084 { } /* end */
16085};
16086#endif
16087
Kailang Yangdf694da2005-12-05 19:42:22 +010016088
16089/*
16090 * configuration and preset
16091 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016092static const char *alc861_models[ALC861_MODEL_LAST] = {
16093 [ALC861_3ST] = "3stack",
16094 [ALC660_3ST] = "3stack-660",
16095 [ALC861_3ST_DIG] = "3stack-dig",
16096 [ALC861_6ST_DIG] = "6stack-dig",
16097 [ALC861_UNIWILL_M31] = "uniwill-m31",
16098 [ALC861_TOSHIBA] = "toshiba",
16099 [ALC861_ASUS] = "asus",
16100 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16101 [ALC861_AUTO] = "auto",
16102};
16103
16104static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016105 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016106 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16107 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16108 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016109 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016110 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016111 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016112 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16113 * Any other models that need this preset?
16114 */
16115 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016116 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16117 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016118 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16119 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16120 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16121 /* FIXME: the below seems conflict */
16122 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16123 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16124 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016125 {}
16126};
16127
16128static struct alc_config_preset alc861_presets[] = {
16129 [ALC861_3ST] = {
16130 .mixers = { alc861_3ST_mixer },
16131 .init_verbs = { alc861_threestack_init_verbs },
16132 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16133 .dac_nids = alc861_dac_nids,
16134 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16135 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016136 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016137 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16138 .adc_nids = alc861_adc_nids,
16139 .input_mux = &alc861_capture_source,
16140 },
16141 [ALC861_3ST_DIG] = {
16142 .mixers = { alc861_base_mixer },
16143 .init_verbs = { alc861_threestack_init_verbs },
16144 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16145 .dac_nids = alc861_dac_nids,
16146 .dig_out_nid = ALC861_DIGOUT_NID,
16147 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16148 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016149 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016150 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16151 .adc_nids = alc861_adc_nids,
16152 .input_mux = &alc861_capture_source,
16153 },
16154 [ALC861_6ST_DIG] = {
16155 .mixers = { alc861_base_mixer },
16156 .init_verbs = { alc861_base_init_verbs },
16157 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16158 .dac_nids = alc861_dac_nids,
16159 .dig_out_nid = ALC861_DIGOUT_NID,
16160 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16161 .channel_mode = alc861_8ch_modes,
16162 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16163 .adc_nids = alc861_adc_nids,
16164 .input_mux = &alc861_capture_source,
16165 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016166 [ALC660_3ST] = {
16167 .mixers = { alc861_3ST_mixer },
16168 .init_verbs = { alc861_threestack_init_verbs },
16169 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16170 .dac_nids = alc660_dac_nids,
16171 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16172 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016173 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016174 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16175 .adc_nids = alc861_adc_nids,
16176 .input_mux = &alc861_capture_source,
16177 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016178 [ALC861_UNIWILL_M31] = {
16179 .mixers = { alc861_uniwill_m31_mixer },
16180 .init_verbs = { alc861_uniwill_m31_init_verbs },
16181 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16182 .dac_nids = alc861_dac_nids,
16183 .dig_out_nid = ALC861_DIGOUT_NID,
16184 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16185 .channel_mode = alc861_uniwill_m31_modes,
16186 .need_dac_fix = 1,
16187 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16188 .adc_nids = alc861_adc_nids,
16189 .input_mux = &alc861_capture_source,
16190 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016191 [ALC861_TOSHIBA] = {
16192 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016193 .init_verbs = { alc861_base_init_verbs,
16194 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016195 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16196 .dac_nids = alc861_dac_nids,
16197 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16198 .channel_mode = alc883_3ST_2ch_modes,
16199 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16200 .adc_nids = alc861_adc_nids,
16201 .input_mux = &alc861_capture_source,
16202 .unsol_event = alc861_toshiba_unsol_event,
16203 .init_hook = alc861_toshiba_automute,
16204 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016205 [ALC861_ASUS] = {
16206 .mixers = { alc861_asus_mixer },
16207 .init_verbs = { alc861_asus_init_verbs },
16208 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16209 .dac_nids = alc861_dac_nids,
16210 .dig_out_nid = ALC861_DIGOUT_NID,
16211 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16212 .channel_mode = alc861_asus_modes,
16213 .need_dac_fix = 1,
16214 .hp_nid = 0x06,
16215 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16216 .adc_nids = alc861_adc_nids,
16217 .input_mux = &alc861_capture_source,
16218 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016219 [ALC861_ASUS_LAPTOP] = {
16220 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16221 .init_verbs = { alc861_asus_init_verbs,
16222 alc861_asus_laptop_init_verbs },
16223 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16224 .dac_nids = alc861_dac_nids,
16225 .dig_out_nid = ALC861_DIGOUT_NID,
16226 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16227 .channel_mode = alc883_3ST_2ch_modes,
16228 .need_dac_fix = 1,
16229 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16230 .adc_nids = alc861_adc_nids,
16231 .input_mux = &alc861_capture_source,
16232 },
16233};
Kailang Yangdf694da2005-12-05 19:42:22 +010016234
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016235/* Pin config fixes */
16236enum {
16237 PINFIX_FSC_AMILO_PI1505,
16238};
16239
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016240static const struct alc_fixup alc861_fixups[] = {
16241 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016242 .pins = (const struct alc_pincfg[]) {
16243 { 0x0b, 0x0221101f }, /* HP */
16244 { 0x0f, 0x90170310 }, /* speaker */
16245 { }
16246 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016247 },
16248};
16249
16250static struct snd_pci_quirk alc861_fixup_tbl[] = {
16251 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16252 {}
16253};
Kailang Yangdf694da2005-12-05 19:42:22 +010016254
16255static int patch_alc861(struct hda_codec *codec)
16256{
16257 struct alc_spec *spec;
16258 int board_config;
16259 int err;
16260
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016261 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016262 if (spec == NULL)
16263 return -ENOMEM;
16264
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016265 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016266
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016267 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16268 alc861_models,
16269 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016270
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016271 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016272 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16273 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016274 board_config = ALC861_AUTO;
16275 }
16276
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016277 if (board_config == ALC861_AUTO)
16278 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016279
Kailang Yangdf694da2005-12-05 19:42:22 +010016280 if (board_config == ALC861_AUTO) {
16281 /* automatic parse from the BIOS config */
16282 err = alc861_parse_auto_config(codec);
16283 if (err < 0) {
16284 alc_free(codec);
16285 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016286 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016287 printk(KERN_INFO
16288 "hda_codec: Cannot set up configuration "
16289 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016290 board_config = ALC861_3ST_DIG;
16291 }
16292 }
16293
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016294 err = snd_hda_attach_beep_device(codec, 0x23);
16295 if (err < 0) {
16296 alc_free(codec);
16297 return err;
16298 }
16299
Kailang Yangdf694da2005-12-05 19:42:22 +010016300 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016301 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016302
Kailang Yangdf694da2005-12-05 19:42:22 +010016303 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16304 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16305
Kailang Yangdf694da2005-12-05 19:42:22 +010016306 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16307 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16308
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016309 if (!spec->cap_mixer)
16310 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016311 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16312
Takashi Iwai2134ea42008-01-10 16:53:55 +010016313 spec->vmaster_nid = 0x03;
16314
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016315 if (board_config == ALC861_AUTO)
16316 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16317
Kailang Yangdf694da2005-12-05 19:42:22 +010016318 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016319 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016320 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016321#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016322 spec->power_hook = alc_power_eapd;
16323#endif
16324 }
16325#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016326 if (!spec->loopback.amplist)
16327 spec->loopback.amplist = alc861_loopbacks;
16328#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016329
Kailang Yangdf694da2005-12-05 19:42:22 +010016330 return 0;
16331}
16332
16333/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016334 * ALC861-VD support
16335 *
16336 * Based on ALC882
16337 *
16338 * In addition, an independent DAC
16339 */
16340#define ALC861VD_DIGOUT_NID 0x06
16341
16342static hda_nid_t alc861vd_dac_nids[4] = {
16343 /* front, surr, clfe, side surr */
16344 0x02, 0x03, 0x04, 0x05
16345};
16346
16347/* dac_nids for ALC660vd are in a different order - according to
16348 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016349 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016350 * of ALC660vd codecs, but for now there is only 3stack mixer
16351 * - and it is the same as in 861vd.
16352 * adc_nids in ALC660vd are (is) the same as in 861vd
16353 */
16354static hda_nid_t alc660vd_dac_nids[3] = {
16355 /* front, rear, clfe, rear_surr */
16356 0x02, 0x04, 0x03
16357};
16358
16359static hda_nid_t alc861vd_adc_nids[1] = {
16360 /* ADC0 */
16361 0x09,
16362};
16363
Takashi Iwaie1406342008-02-11 18:32:32 +010016364static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16365
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016366/* input MUX */
16367/* FIXME: should be a matrix-type input source selection */
16368static struct hda_input_mux alc861vd_capture_source = {
16369 .num_items = 4,
16370 .items = {
16371 { "Mic", 0x0 },
16372 { "Front Mic", 0x1 },
16373 { "Line", 0x2 },
16374 { "CD", 0x4 },
16375 },
16376};
16377
Kailang Yang272a5272007-05-14 11:00:38 +020016378static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016379 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016380 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016381 { "Ext Mic", 0x0 },
16382 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016383 },
16384};
16385
Kailang Yangd1a991a2007-08-15 16:21:59 +020016386static struct hda_input_mux alc861vd_hp_capture_source = {
16387 .num_items = 2,
16388 .items = {
16389 { "Front Mic", 0x0 },
16390 { "ATAPI Mic", 0x1 },
16391 },
16392};
16393
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016394/*
16395 * 2ch mode
16396 */
16397static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16398 { 2, NULL }
16399};
16400
16401/*
16402 * 6ch mode
16403 */
16404static struct hda_verb alc861vd_6stack_ch6_init[] = {
16405 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16406 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16407 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16408 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16409 { } /* end */
16410};
16411
16412/*
16413 * 8ch mode
16414 */
16415static struct hda_verb alc861vd_6stack_ch8_init[] = {
16416 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16417 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16418 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16419 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16420 { } /* end */
16421};
16422
16423static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16424 { 6, alc861vd_6stack_ch6_init },
16425 { 8, alc861vd_6stack_ch8_init },
16426};
16427
16428static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16429 {
16430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16431 .name = "Channel Mode",
16432 .info = alc_ch_mode_info,
16433 .get = alc_ch_mode_get,
16434 .put = alc_ch_mode_put,
16435 },
16436 { } /* end */
16437};
16438
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016439/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16440 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16441 */
16442static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16443 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16444 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16445
16446 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16447 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16448
16449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16450 HDA_OUTPUT),
16451 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16452 HDA_OUTPUT),
16453 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16454 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16455
16456 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16457 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16458
16459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16460
16461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16464
16465 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16466 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16467 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16468
16469 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16470 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16471
16472 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16473 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16474
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016475 { } /* end */
16476};
16477
16478static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16479 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16480 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16481
16482 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16483
16484 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16487
16488 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16489 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16490 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16491
16492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16493 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16494
16495 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16496 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16497
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016498 { } /* end */
16499};
16500
Kailang Yangbdd148a2007-05-08 15:19:08 +020016501static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16502 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16503 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16504 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16505
16506 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16507
16508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16509 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16510 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16511
16512 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16513 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16514 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16515
16516 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16517 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16518
16519 { } /* end */
16520};
16521
Tobin Davisb419f342008-03-07 11:57:51 +010016522/* Pin assignment: Speaker=0x14, HP = 0x15,
16523 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016524 */
16525static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016526 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16527 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016528 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16529 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016530 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16531 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16532 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16533 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16534 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16535 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016536 { } /* end */
16537};
16538
Kailang Yangd1a991a2007-08-15 16:21:59 +020016539/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16540 * Front Mic=0x18, ATAPI Mic = 0x19,
16541 */
16542static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16543 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16544 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16545 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16546 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16547 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16548 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16549 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16550 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016551
Kailang Yangd1a991a2007-08-15 16:21:59 +020016552 { } /* end */
16553};
16554
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016555/*
16556 * generic initialization of ADC, input mixers and output mixers
16557 */
16558static struct hda_verb alc861vd_volume_init_verbs[] = {
16559 /*
16560 * Unmute ADC0 and set the default input to mic-in
16561 */
16562 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16563 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16564
16565 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16566 * the analog-loopback mixer widget
16567 */
16568 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016574
16575 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016580
16581 /*
16582 * Set up output mixers (0x02 - 0x05)
16583 */
16584 /* set vol=0 to output mixers */
16585 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16586 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16587 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16588 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16589
16590 /* set up input amps for analog loopback */
16591 /* Amp Indices: DAC = 0, mixer = 1 */
16592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16594 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16595 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16596 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16598 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16599 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16600
16601 { }
16602};
16603
16604/*
16605 * 3-stack pin configuration:
16606 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16607 */
16608static struct hda_verb alc861vd_3stack_init_verbs[] = {
16609 /*
16610 * Set pin mode and muting
16611 */
16612 /* set front pin widgets 0x14 for output */
16613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16614 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16615 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16616
16617 /* Mic (rear) pin: input vref at 80% */
16618 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16619 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16620 /* Front Mic pin: input vref at 80% */
16621 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16622 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16623 /* Line In pin: input */
16624 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16626 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16628 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16629 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16630 /* CD pin widget for input */
16631 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16632
16633 { }
16634};
16635
16636/*
16637 * 6-stack pin configuration:
16638 */
16639static struct hda_verb alc861vd_6stack_init_verbs[] = {
16640 /*
16641 * Set pin mode and muting
16642 */
16643 /* set front pin widgets 0x14 for output */
16644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16647
16648 /* Rear Pin: output 1 (0x0d) */
16649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16652 /* CLFE Pin: output 2 (0x0e) */
16653 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16654 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16655 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16656 /* Side Pin: output 3 (0x0f) */
16657 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16658 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16659 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16660
16661 /* Mic (rear) pin: input vref at 80% */
16662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16664 /* Front Mic pin: input vref at 80% */
16665 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16666 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16667 /* Line In pin: input */
16668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16670 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16673 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16674 /* CD pin widget for input */
16675 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16676
16677 { }
16678};
16679
Kailang Yangbdd148a2007-05-08 15:19:08 +020016680static struct hda_verb alc861vd_eapd_verbs[] = {
16681 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16682 { }
16683};
16684
Kailang Yangf9423e72008-05-27 12:32:25 +020016685static struct hda_verb alc660vd_eapd_verbs[] = {
16686 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16687 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16688 { }
16689};
16690
Kailang Yangbdd148a2007-05-08 15:19:08 +020016691static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16695 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016696 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016697 {}
16698};
16699
Kailang Yangbdd148a2007-05-08 15:19:08 +020016700static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16701{
16702 unsigned int present;
16703 unsigned char bits;
16704
Wu Fengguang864f92b2009-11-18 12:38:02 +080016705 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016706 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016707
Takashi Iwai47fd8302007-08-10 17:11:07 +020016708 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16709 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016710}
16711
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016712static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016713{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016714 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016715 spec->autocfg.hp_pins[0] = 0x1b;
16716 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016717}
16718
16719static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16720{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016721 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016722 alc861vd_lenovo_mic_automute(codec);
16723}
16724
16725static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16726 unsigned int res)
16727{
16728 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016729 case ALC880_MIC_EVENT:
16730 alc861vd_lenovo_mic_automute(codec);
16731 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016732 default:
16733 alc_automute_amp_unsol_event(codec, res);
16734 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016735 }
16736}
16737
Kailang Yang272a5272007-05-14 11:00:38 +020016738static struct hda_verb alc861vd_dallas_verbs[] = {
16739 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16740 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16741 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16742 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16743
16744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16750 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16751 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016752
Kailang Yang272a5272007-05-14 11:00:38 +020016753 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16756 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16757 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16759 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16760 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16761
16762 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16763 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16767 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16768 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16769 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16770
16771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16775
16776 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016777 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016778 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16779
16780 { } /* end */
16781};
16782
16783/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016784static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016785{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016786 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016787
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016788 spec->autocfg.hp_pins[0] = 0x15;
16789 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016790}
16791
Takashi Iwaicb53c622007-08-10 17:21:45 +020016792#ifdef CONFIG_SND_HDA_POWER_SAVE
16793#define alc861vd_loopbacks alc880_loopbacks
16794#endif
16795
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016796/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016797#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16798#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16799#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16800#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16801
16802/*
16803 * configuration and preset
16804 */
16805static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16806 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016807 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016808 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016809 [ALC861VD_3ST] = "3stack",
16810 [ALC861VD_3ST_DIG] = "3stack-digout",
16811 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016812 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016813 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016814 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016815 [ALC861VD_AUTO] = "auto",
16816};
16817
16818static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016819 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16820 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016821 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016822 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016823 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016824 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016825 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016826 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016827 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016828 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016829 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016830 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016831 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016832 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016833 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016834 {}
16835};
16836
16837static struct alc_config_preset alc861vd_presets[] = {
16838 [ALC660VD_3ST] = {
16839 .mixers = { alc861vd_3st_mixer },
16840 .init_verbs = { alc861vd_volume_init_verbs,
16841 alc861vd_3stack_init_verbs },
16842 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16843 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016844 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16845 .channel_mode = alc861vd_3stack_2ch_modes,
16846 .input_mux = &alc861vd_capture_source,
16847 },
Mike Crash6963f842007-06-25 12:12:51 +020016848 [ALC660VD_3ST_DIG] = {
16849 .mixers = { alc861vd_3st_mixer },
16850 .init_verbs = { alc861vd_volume_init_verbs,
16851 alc861vd_3stack_init_verbs },
16852 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16853 .dac_nids = alc660vd_dac_nids,
16854 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016855 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16856 .channel_mode = alc861vd_3stack_2ch_modes,
16857 .input_mux = &alc861vd_capture_source,
16858 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016859 [ALC861VD_3ST] = {
16860 .mixers = { alc861vd_3st_mixer },
16861 .init_verbs = { alc861vd_volume_init_verbs,
16862 alc861vd_3stack_init_verbs },
16863 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16864 .dac_nids = alc861vd_dac_nids,
16865 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16866 .channel_mode = alc861vd_3stack_2ch_modes,
16867 .input_mux = &alc861vd_capture_source,
16868 },
16869 [ALC861VD_3ST_DIG] = {
16870 .mixers = { alc861vd_3st_mixer },
16871 .init_verbs = { alc861vd_volume_init_verbs,
16872 alc861vd_3stack_init_verbs },
16873 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16874 .dac_nids = alc861vd_dac_nids,
16875 .dig_out_nid = ALC861VD_DIGOUT_NID,
16876 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16877 .channel_mode = alc861vd_3stack_2ch_modes,
16878 .input_mux = &alc861vd_capture_source,
16879 },
16880 [ALC861VD_6ST_DIG] = {
16881 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16882 .init_verbs = { alc861vd_volume_init_verbs,
16883 alc861vd_6stack_init_verbs },
16884 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16885 .dac_nids = alc861vd_dac_nids,
16886 .dig_out_nid = ALC861VD_DIGOUT_NID,
16887 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16888 .channel_mode = alc861vd_6stack_modes,
16889 .input_mux = &alc861vd_capture_source,
16890 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016891 [ALC861VD_LENOVO] = {
16892 .mixers = { alc861vd_lenovo_mixer },
16893 .init_verbs = { alc861vd_volume_init_verbs,
16894 alc861vd_3stack_init_verbs,
16895 alc861vd_eapd_verbs,
16896 alc861vd_lenovo_unsol_verbs },
16897 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16898 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016899 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16900 .channel_mode = alc861vd_3stack_2ch_modes,
16901 .input_mux = &alc861vd_capture_source,
16902 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016903 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016904 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016905 },
Kailang Yang272a5272007-05-14 11:00:38 +020016906 [ALC861VD_DALLAS] = {
16907 .mixers = { alc861vd_dallas_mixer },
16908 .init_verbs = { alc861vd_dallas_verbs },
16909 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16910 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016911 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16912 .channel_mode = alc861vd_3stack_2ch_modes,
16913 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016914 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016915 .setup = alc861vd_dallas_setup,
16916 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016917 },
16918 [ALC861VD_HP] = {
16919 .mixers = { alc861vd_hp_mixer },
16920 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16921 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16922 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016923 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016924 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16925 .channel_mode = alc861vd_3stack_2ch_modes,
16926 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016927 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016928 .setup = alc861vd_dallas_setup,
16929 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016930 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016931 [ALC660VD_ASUS_V1S] = {
16932 .mixers = { alc861vd_lenovo_mixer },
16933 .init_verbs = { alc861vd_volume_init_verbs,
16934 alc861vd_3stack_init_verbs,
16935 alc861vd_eapd_verbs,
16936 alc861vd_lenovo_unsol_verbs },
16937 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16938 .dac_nids = alc660vd_dac_nids,
16939 .dig_out_nid = ALC861VD_DIGOUT_NID,
16940 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16941 .channel_mode = alc861vd_3stack_2ch_modes,
16942 .input_mux = &alc861vd_capture_source,
16943 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016944 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016945 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016946 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016947};
16948
16949/*
16950 * BIOS auto configuration
16951 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016952static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16953 const struct auto_pin_cfg *cfg)
16954{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020016955 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016956}
16957
16958
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016959static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16960 hda_nid_t nid, int pin_type, int dac_idx)
16961{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016962 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016963}
16964
16965static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16966{
16967 struct alc_spec *spec = codec->spec;
16968 int i;
16969
16970 for (i = 0; i <= HDA_SIDE; i++) {
16971 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016972 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016973 if (nid)
16974 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016975 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016976 }
16977}
16978
16979
16980static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16981{
16982 struct alc_spec *spec = codec->spec;
16983 hda_nid_t pin;
16984
16985 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016986 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016987 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016988 pin = spec->autocfg.speaker_pins[0];
16989 if (pin)
16990 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016991}
16992
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016993#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16994
16995static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16996{
16997 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016998 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016999 int i;
17000
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017001 for (i = 0; i < cfg->num_inputs; i++) {
17002 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017003 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017004 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017005 if (nid != ALC861VD_PIN_CD_NID &&
17006 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017007 snd_hda_codec_write(codec, nid, 0,
17008 AC_VERB_SET_AMP_GAIN_MUTE,
17009 AMP_OUT_MUTE);
17010 }
17011 }
17012}
17013
Takashi Iwaif511b012008-08-15 16:46:42 +020017014#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17015
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017016#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17017#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17018
17019/* add playback controls from the parsed DAC table */
17020/* Based on ALC880 version. But ALC861VD has separate,
17021 * different NIDs for mute/unmute switch and volume control */
17022static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17023 const struct auto_pin_cfg *cfg)
17024{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017025 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
17026 hda_nid_t nid_v, nid_s;
17027 int i, err;
17028
17029 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017030 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017031 continue;
17032 nid_v = alc861vd_idx_to_mixer_vol(
17033 alc880_dac_to_idx(
17034 spec->multiout.dac_nids[i]));
17035 nid_s = alc861vd_idx_to_mixer_switch(
17036 alc880_dac_to_idx(
17037 spec->multiout.dac_nids[i]));
17038
17039 if (i == 2) {
17040 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017041 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17042 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017043 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17044 HDA_OUTPUT));
17045 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017046 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017047 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17048 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017049 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17050 HDA_OUTPUT));
17051 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017052 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017053 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17054 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017055 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17056 HDA_INPUT));
17057 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017058 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017059 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17060 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017061 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17062 HDA_INPUT));
17063 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017064 return err;
17065 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017066 const char *pfx;
17067 if (cfg->line_outs == 1 &&
17068 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17069 if (!cfg->hp_pins)
17070 pfx = "Speaker";
17071 else
17072 pfx = "PCM";
17073 } else
17074 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017075 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017076 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17077 HDA_OUTPUT));
17078 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017079 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017080 if (cfg->line_outs == 1 &&
17081 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17082 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017083 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017084 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017085 HDA_INPUT));
17086 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017087 return err;
17088 }
17089 }
17090 return 0;
17091}
17092
17093/* add playback controls for speaker and HP outputs */
17094/* Based on ALC880 version. But ALC861VD has separate,
17095 * different NIDs for mute/unmute switch and volume control */
17096static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17097 hda_nid_t pin, const char *pfx)
17098{
17099 hda_nid_t nid_v, nid_s;
17100 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017101
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017102 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017103 return 0;
17104
17105 if (alc880_is_fixed_pin(pin)) {
17106 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17107 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017108 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017109 spec->multiout.hp_nid = nid_v;
17110 else
17111 spec->multiout.extra_out_nid[0] = nid_v;
17112 /* control HP volume/switch on the output mixer amp */
17113 nid_v = alc861vd_idx_to_mixer_vol(
17114 alc880_fixed_pin_idx(pin));
17115 nid_s = alc861vd_idx_to_mixer_switch(
17116 alc880_fixed_pin_idx(pin));
17117
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017118 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017119 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17120 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017121 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017122 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017123 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17124 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017125 return err;
17126 } else if (alc880_is_multi_pin(pin)) {
17127 /* set manual connection */
17128 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017129 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017130 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17131 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017132 return err;
17133 }
17134 return 0;
17135}
17136
17137/* parse the BIOS configuration and set up the alc_spec
17138 * return 1 if successful, 0 if the proper config is not found,
17139 * or a negative error code
17140 * Based on ALC880 version - had to change it to override
17141 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17142static int alc861vd_parse_auto_config(struct hda_codec *codec)
17143{
17144 struct alc_spec *spec = codec->spec;
17145 int err;
17146 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17147
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017148 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17149 alc861vd_ignore);
17150 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017151 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017152 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017153 return 0; /* can't find valid BIOS pin config */
17154
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017155 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17156 if (err < 0)
17157 return err;
17158 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17159 if (err < 0)
17160 return err;
17161 err = alc861vd_auto_create_extra_out(spec,
17162 spec->autocfg.speaker_pins[0],
17163 "Speaker");
17164 if (err < 0)
17165 return err;
17166 err = alc861vd_auto_create_extra_out(spec,
17167 spec->autocfg.hp_pins[0],
17168 "Headphone");
17169 if (err < 0)
17170 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017171 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017172 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017173 return err;
17174
17175 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17176
Takashi Iwai757899a2010-07-30 10:48:14 +020017177 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017178
Takashi Iwai603c4012008-07-30 15:01:44 +020017179 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017180 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017181
Takashi Iwaid88897e2008-10-31 15:01:37 +010017182 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017183
17184 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017185 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017186
Takashi Iwai776e1842007-08-29 15:07:11 +020017187 err = alc_auto_add_mic_boost(codec);
17188 if (err < 0)
17189 return err;
17190
Kailang Yang6227cdc2010-02-25 08:36:52 +010017191 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017192
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017193 return 1;
17194}
17195
17196/* additional initialization for auto-configuration model */
17197static void alc861vd_auto_init(struct hda_codec *codec)
17198{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017199 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017200 alc861vd_auto_init_multi_out(codec);
17201 alc861vd_auto_init_hp_out(codec);
17202 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017203 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017204 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017205 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017206 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017207}
17208
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017209enum {
17210 ALC660VD_FIX_ASUS_GPIO1
17211};
17212
17213/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017214static const struct alc_fixup alc861vd_fixups[] = {
17215 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017216 .verbs = (const struct hda_verb[]) {
17217 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17218 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17219 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17220 { }
17221 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017222 },
17223};
17224
17225static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17226 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17227 {}
17228};
17229
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017230static int patch_alc861vd(struct hda_codec *codec)
17231{
17232 struct alc_spec *spec;
17233 int err, board_config;
17234
17235 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17236 if (spec == NULL)
17237 return -ENOMEM;
17238
17239 codec->spec = spec;
17240
17241 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17242 alc861vd_models,
17243 alc861vd_cfg_tbl);
17244
17245 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017246 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17247 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017248 board_config = ALC861VD_AUTO;
17249 }
17250
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017251 if (board_config == ALC861VD_AUTO)
17252 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017253
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017254 if (board_config == ALC861VD_AUTO) {
17255 /* automatic parse from the BIOS config */
17256 err = alc861vd_parse_auto_config(codec);
17257 if (err < 0) {
17258 alc_free(codec);
17259 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017260 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017261 printk(KERN_INFO
17262 "hda_codec: Cannot set up configuration "
17263 "from BIOS. Using base mode...\n");
17264 board_config = ALC861VD_3ST;
17265 }
17266 }
17267
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017268 err = snd_hda_attach_beep_device(codec, 0x23);
17269 if (err < 0) {
17270 alc_free(codec);
17271 return err;
17272 }
17273
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017274 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017275 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017276
Kailang Yang2f893282008-05-27 12:14:47 +020017277 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017278 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017279 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017280 }
17281
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017282 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17283 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17284
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017285 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17286 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17287
Takashi Iwaidd704692009-08-11 08:45:11 +020017288 if (!spec->adc_nids) {
17289 spec->adc_nids = alc861vd_adc_nids;
17290 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17291 }
17292 if (!spec->capsrc_nids)
17293 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017294
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017295 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017296 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017297
Takashi Iwai2134ea42008-01-10 16:53:55 +010017298 spec->vmaster_nid = 0x02;
17299
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017300 if (board_config == ALC861VD_AUTO)
17301 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17302
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017303 codec->patch_ops = alc_patch_ops;
17304
17305 if (board_config == ALC861VD_AUTO)
17306 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017307#ifdef CONFIG_SND_HDA_POWER_SAVE
17308 if (!spec->loopback.amplist)
17309 spec->loopback.amplist = alc861vd_loopbacks;
17310#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017311
17312 return 0;
17313}
17314
17315/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017316 * ALC662 support
17317 *
17318 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17319 * configuration. Each pin widget can choose any input DACs and a mixer.
17320 * Each ADC is connected from a mixer of all inputs. This makes possible
17321 * 6-channel independent captures.
17322 *
17323 * In addition, an independent DAC for the multi-playback (not used in this
17324 * driver yet).
17325 */
17326#define ALC662_DIGOUT_NID 0x06
17327#define ALC662_DIGIN_NID 0x0a
17328
17329static hda_nid_t alc662_dac_nids[4] = {
17330 /* front, rear, clfe, rear_surr */
17331 0x02, 0x03, 0x04
17332};
17333
Kailang Yang622e84c2009-04-21 07:39:04 +020017334static hda_nid_t alc272_dac_nids[2] = {
17335 0x02, 0x03
17336};
17337
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017338static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017339 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017340 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017341};
Takashi Iwaie1406342008-02-11 18:32:32 +010017342
Kailang Yang622e84c2009-04-21 07:39:04 +020017343static hda_nid_t alc272_adc_nids[1] = {
17344 /* ADC1-2 */
17345 0x08,
17346};
17347
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017348static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017349static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17350
Takashi Iwaie1406342008-02-11 18:32:32 +010017351
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017352/* input MUX */
17353/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017354static struct hda_input_mux alc662_capture_source = {
17355 .num_items = 4,
17356 .items = {
17357 { "Mic", 0x0 },
17358 { "Front Mic", 0x1 },
17359 { "Line", 0x2 },
17360 { "CD", 0x4 },
17361 },
17362};
17363
17364static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17365 .num_items = 2,
17366 .items = {
17367 { "Mic", 0x1 },
17368 { "Line", 0x2 },
17369 },
17370};
Kailang Yang291702f2007-10-16 14:28:03 +020017371
Kailang Yang6dda9f42008-05-27 12:05:31 +020017372static struct hda_input_mux alc663_capture_source = {
17373 .num_items = 3,
17374 .items = {
17375 { "Mic", 0x0 },
17376 { "Front Mic", 0x1 },
17377 { "Line", 0x2 },
17378 },
17379};
17380
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017381#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017382static struct hda_input_mux alc272_nc10_capture_source = {
17383 .num_items = 16,
17384 .items = {
17385 { "Autoselect Mic", 0x0 },
17386 { "Internal Mic", 0x1 },
17387 { "In-0x02", 0x2 },
17388 { "In-0x03", 0x3 },
17389 { "In-0x04", 0x4 },
17390 { "In-0x05", 0x5 },
17391 { "In-0x06", 0x6 },
17392 { "In-0x07", 0x7 },
17393 { "In-0x08", 0x8 },
17394 { "In-0x09", 0x9 },
17395 { "In-0x0a", 0x0a },
17396 { "In-0x0b", 0x0b },
17397 { "In-0x0c", 0x0c },
17398 { "In-0x0d", 0x0d },
17399 { "In-0x0e", 0x0e },
17400 { "In-0x0f", 0x0f },
17401 },
17402};
17403#endif
17404
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017405/*
17406 * 2ch mode
17407 */
17408static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17409 { 2, NULL }
17410};
17411
17412/*
17413 * 2ch mode
17414 */
17415static struct hda_verb alc662_3ST_ch2_init[] = {
17416 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17417 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17418 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17419 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17420 { } /* end */
17421};
17422
17423/*
17424 * 6ch mode
17425 */
17426static struct hda_verb alc662_3ST_ch6_init[] = {
17427 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17428 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17429 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17430 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17431 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17432 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17433 { } /* end */
17434};
17435
17436static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17437 { 2, alc662_3ST_ch2_init },
17438 { 6, alc662_3ST_ch6_init },
17439};
17440
17441/*
17442 * 2ch mode
17443 */
17444static struct hda_verb alc662_sixstack_ch6_init[] = {
17445 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17446 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17447 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17448 { } /* end */
17449};
17450
17451/*
17452 * 6ch mode
17453 */
17454static struct hda_verb alc662_sixstack_ch8_init[] = {
17455 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17456 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17457 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17458 { } /* end */
17459};
17460
17461static struct hda_channel_mode alc662_5stack_modes[2] = {
17462 { 2, alc662_sixstack_ch6_init },
17463 { 6, alc662_sixstack_ch8_init },
17464};
17465
17466/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17467 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17468 */
17469
17470static struct snd_kcontrol_new alc662_base_mixer[] = {
17471 /* output mixer control */
17472 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017473 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017474 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017475 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017476 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17477 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017478 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17479 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017480 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17481
17482 /*Input mixer control */
17483 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17484 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17485 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17486 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17487 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17488 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17489 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17490 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017491 { } /* end */
17492};
17493
17494static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17495 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017496 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017497 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17498 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17499 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17500 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17501 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17502 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17503 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17504 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17505 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017506 { } /* end */
17507};
17508
17509static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17510 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017511 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017512 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017513 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017514 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17515 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017516 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17517 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017518 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17519 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17520 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17521 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17522 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17523 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17524 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17525 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17526 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017527 { } /* end */
17528};
17529
17530static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17531 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17532 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017533 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17534 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017535 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17536 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17537 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017540 { } /* end */
17541};
17542
Kailang Yang291702f2007-10-16 14:28:03 +020017543static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017544 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17545 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017546
17547 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17548 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17549 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17550
17551 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17552 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17553 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17554 { } /* end */
17555};
17556
Kailang Yang8c427222008-01-10 13:03:59 +010017557static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017558 ALC262_HIPPO_MASTER_SWITCH,
17559 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017560 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017561 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17562 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017563 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17564 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17565 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17568 { } /* end */
17569};
17570
Kailang Yangf1d4e282008-08-26 14:03:29 +020017571static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17572 .ops = &snd_hda_bind_vol,
17573 .values = {
17574 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17575 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17576 0
17577 },
17578};
17579
17580static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17581 .ops = &snd_hda_bind_sw,
17582 .values = {
17583 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17584 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17585 0
17586 },
17587};
17588
Kailang Yang6dda9f42008-05-27 12:05:31 +020017589static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017590 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17591 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17593 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17594 { } /* end */
17595};
17596
17597static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17598 .ops = &snd_hda_bind_sw,
17599 .values = {
17600 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17601 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17602 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17603 0
17604 },
17605};
17606
17607static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17608 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17609 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17612 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17613 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17614
17615 { } /* end */
17616};
17617
17618static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17619 .ops = &snd_hda_bind_sw,
17620 .values = {
17621 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17622 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17623 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17624 0
17625 },
17626};
17627
17628static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17629 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17630 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17633 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17634 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17635 { } /* end */
17636};
17637
17638static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017639 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17640 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017641 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17644 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17645 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17646 { } /* end */
17647};
17648
17649static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17650 .ops = &snd_hda_bind_vol,
17651 .values = {
17652 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17653 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17654 0
17655 },
17656};
17657
17658static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17659 .ops = &snd_hda_bind_sw,
17660 .values = {
17661 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17662 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17663 0
17664 },
17665};
17666
17667static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17668 HDA_BIND_VOL("Master Playback Volume",
17669 &alc663_asus_two_bind_master_vol),
17670 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17671 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017672 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017675 { } /* end */
17676};
17677
17678static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17679 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17680 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17681 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17684 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017685 { } /* end */
17686};
17687
17688static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17689 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17690 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17691 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17692 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17693 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17694
17695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17697 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17698 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17699 { } /* end */
17700};
17701
17702static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17703 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17704 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17705 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17706
17707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17709 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17710 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17711 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17712 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17713 { } /* end */
17714};
17715
Kailang Yangebb83ee2009-12-17 12:23:00 +010017716static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17717 .ops = &snd_hda_bind_sw,
17718 .values = {
17719 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17720 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17721 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17722 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17723 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17724 0
17725 },
17726};
17727
17728static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17729 .ops = &snd_hda_bind_sw,
17730 .values = {
17731 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17732 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17733 0
17734 },
17735};
17736
17737static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17738 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17739 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17740 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17741 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17742 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17743 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17744 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17747 { } /* end */
17748};
17749
17750static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17751 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17752 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17753 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17754 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17755 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17758 { } /* end */
17759};
17760
17761
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017762static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17763 {
17764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17765 .name = "Channel Mode",
17766 .info = alc_ch_mode_info,
17767 .get = alc_ch_mode_get,
17768 .put = alc_ch_mode_put,
17769 },
17770 { } /* end */
17771};
17772
17773static struct hda_verb alc662_init_verbs[] = {
17774 /* ADC: mute amp left and right */
17775 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17776 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017777
Kailang Yangb60dd392007-09-20 12:50:29 +020017778 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17780 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17781 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17782 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17783 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017784
17785 /* Front Pin: output 0 (0x0c) */
17786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17788
17789 /* Rear Pin: output 1 (0x0d) */
17790 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17792
17793 /* CLFE Pin: output 2 (0x0e) */
17794 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17795 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17796
17797 /* Mic (rear) pin: input vref at 80% */
17798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17800 /* Front Mic pin: input vref at 80% */
17801 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17803 /* Line In pin: input */
17804 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17806 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17808 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17809 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17810 /* CD pin widget for input */
17811 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17812
17813 /* FIXME: use matrix-type input source selection */
17814 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17815 /* Input mixer */
17816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017817 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017818
17819 /* always trun on EAPD */
17820 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17821 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17822
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017823 { }
17824};
17825
Kailang Yangcec27c82010-02-04 14:18:18 +010017826static struct hda_verb alc663_init_verbs[] = {
17827 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17828 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17829 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17830 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17831 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17832 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17833 { }
17834};
17835
17836static struct hda_verb alc272_init_verbs[] = {
17837 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17839 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17840 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17841 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17842 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17845 { }
17846};
17847
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017848static struct hda_verb alc662_sue_init_verbs[] = {
17849 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17850 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017851 {}
17852};
17853
17854static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17855 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17856 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17857 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017858};
17859
Kailang Yang8c427222008-01-10 13:03:59 +010017860/* Set Unsolicited Event*/
17861static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17862 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17863 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17864 {}
17865};
17866
Kailang Yang6dda9f42008-05-27 12:05:31 +020017867static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17869 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017870 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17871 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017872 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017875 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17876 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17877 {}
17878};
17879
Kailang Yangf1d4e282008-08-26 14:03:29 +020017880static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17881 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17882 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17883 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17886 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17887 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17888 {}
17889};
17890
17891static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17892 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17894 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17895 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17898 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17899 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17900 {}
17901};
17902
17903static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17906 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17909 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17910 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17911 {}
17912};
17913
17914static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17915 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17916 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17917 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17918 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17923 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17924 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17925 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17926 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17927 {}
17928};
17929
17930static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17931 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17932 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17933 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17934 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17935 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17937 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17940 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17942 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17943 {}
17944};
17945
Kailang Yang6dda9f42008-05-27 12:05:31 +020017946static struct hda_verb alc663_g71v_init_verbs[] = {
17947 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17948 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17949 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17950
17951 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17952 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17953 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17954
17955 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17956 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17957 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17958 {}
17959};
17960
17961static struct hda_verb alc663_g50v_init_verbs[] = {
17962 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17963 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17964 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17965
17966 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17967 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17968 {}
17969};
17970
Kailang Yangf1d4e282008-08-26 14:03:29 +020017971static struct hda_verb alc662_ecs_init_verbs[] = {
17972 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17973 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17974 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17975 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17976 {}
17977};
17978
Kailang Yang622e84c2009-04-21 07:39:04 +020017979static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17980 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17981 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17982 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17983 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17984 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17985 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17986 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17987 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17988 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17989 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17990 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17991 {}
17992};
17993
17994static struct hda_verb alc272_dell_init_verbs[] = {
17995 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17996 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17998 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17999 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18000 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18001 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18002 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18003 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18004 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18005 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18006 {}
18007};
18008
Kailang Yangebb83ee2009-12-17 12:23:00 +010018009static struct hda_verb alc663_mode7_init_verbs[] = {
18010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18011 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18012 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18013 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18014 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18015 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18016 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18017 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18018 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18019 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18022 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18023 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18024 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18025 {}
18026};
18027
18028static struct hda_verb alc663_mode8_init_verbs[] = {
18029 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18030 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18031 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18032 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18033 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18034 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18035 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18036 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18037 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18038 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18039 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18042 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18043 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18044 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18045 {}
18046};
18047
Kailang Yangf1d4e282008-08-26 14:03:29 +020018048static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18049 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18050 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18051 { } /* end */
18052};
18053
Kailang Yang622e84c2009-04-21 07:39:04 +020018054static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18055 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18056 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18057 { } /* end */
18058};
18059
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018060static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18061{
18062 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018063 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018064
Wu Fengguang864f92b2009-11-18 12:38:02 +080018065 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018066 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018067
Takashi Iwai47fd8302007-08-10 17:11:07 +020018068 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18069 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018070}
18071
18072static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18073{
18074 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018075 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018076
Wu Fengguang864f92b2009-11-18 12:38:02 +080018077 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018078 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018079
Takashi Iwai47fd8302007-08-10 17:11:07 +020018080 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18081 HDA_AMP_MUTE, bits);
18082 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18083 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018084}
18085
18086static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18087 unsigned int res)
18088{
18089 if ((res >> 26) == ALC880_HP_EVENT)
18090 alc662_lenovo_101e_all_automute(codec);
18091 if ((res >> 26) == ALC880_FRONT_EVENT)
18092 alc662_lenovo_101e_ispeaker_automute(codec);
18093}
18094
Kailang Yang291702f2007-10-16 14:28:03 +020018095/* unsolicited event for HP jack sensing */
18096static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18097 unsigned int res)
18098{
Kailang Yang291702f2007-10-16 14:28:03 +020018099 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018100 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018101 else
18102 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018103}
18104
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018105static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018106{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018107 struct alc_spec *spec = codec->spec;
18108
18109 alc262_hippo1_setup(codec);
18110 spec->ext_mic.pin = 0x18;
18111 spec->ext_mic.mux_idx = 0;
18112 spec->int_mic.pin = 0x19;
18113 spec->int_mic.mux_idx = 1;
18114 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018115}
18116
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018117static void alc662_eeepc_inithook(struct hda_codec *codec)
18118{
18119 alc262_hippo_automute(codec);
18120 alc_mic_automute(codec);
18121}
18122
18123static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018124{
Takashi Iwai42171c12009-05-08 14:11:43 +020018125 struct alc_spec *spec = codec->spec;
18126
18127 spec->autocfg.hp_pins[0] = 0x14;
18128 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018129}
18130
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018131#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18132
Kailang Yang6dda9f42008-05-27 12:05:31 +020018133static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18134{
18135 unsigned int present;
18136 unsigned char bits;
18137
Wu Fengguang864f92b2009-11-18 12:38:02 +080018138 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018139 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018140 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018141 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018142 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018143 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018144}
18145
18146static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18147{
18148 unsigned int present;
18149 unsigned char bits;
18150
Wu Fengguang864f92b2009-11-18 12:38:02 +080018151 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018152 bits = present ? HDA_AMP_MUTE : 0;
18153 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018154 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018155 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018156 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018157 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018158 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018159 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018160 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018161}
18162
18163static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18164{
18165 unsigned int present;
18166 unsigned char bits;
18167
Wu Fengguang864f92b2009-11-18 12:38:02 +080018168 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018169 bits = present ? HDA_AMP_MUTE : 0;
18170 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018171 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018172 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018173 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018174 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018175 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018176 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018177 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018178}
18179
18180static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18181{
18182 unsigned int present;
18183 unsigned char bits;
18184
Wu Fengguang864f92b2009-11-18 12:38:02 +080018185 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018186 bits = present ? 0 : PIN_OUT;
18187 snd_hda_codec_write(codec, 0x14, 0,
18188 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18189}
18190
18191static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18192{
18193 unsigned int present1, present2;
18194
Wu Fengguang864f92b2009-11-18 12:38:02 +080018195 present1 = snd_hda_jack_detect(codec, 0x21);
18196 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018197
18198 if (present1 || present2) {
18199 snd_hda_codec_write_cache(codec, 0x14, 0,
18200 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18201 } else {
18202 snd_hda_codec_write_cache(codec, 0x14, 0,
18203 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18204 }
18205}
18206
18207static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18208{
18209 unsigned int present1, present2;
18210
Wu Fengguang864f92b2009-11-18 12:38:02 +080018211 present1 = snd_hda_jack_detect(codec, 0x1b);
18212 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018213
18214 if (present1 || present2) {
18215 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018216 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018217 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018218 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018219 } else {
18220 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018221 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018222 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018223 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018224 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018225}
18226
Kailang Yangebb83ee2009-12-17 12:23:00 +010018227static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18228{
18229 unsigned int present1, present2;
18230
18231 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18232 AC_VERB_GET_PIN_SENSE, 0)
18233 & AC_PINSENSE_PRESENCE;
18234 present2 = snd_hda_codec_read(codec, 0x21, 0,
18235 AC_VERB_GET_PIN_SENSE, 0)
18236 & AC_PINSENSE_PRESENCE;
18237
18238 if (present1 || present2) {
18239 snd_hda_codec_write_cache(codec, 0x14, 0,
18240 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18241 snd_hda_codec_write_cache(codec, 0x17, 0,
18242 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18243 } else {
18244 snd_hda_codec_write_cache(codec, 0x14, 0,
18245 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18246 snd_hda_codec_write_cache(codec, 0x17, 0,
18247 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18248 }
18249}
18250
18251static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18252{
18253 unsigned int present1, present2;
18254
18255 present1 = snd_hda_codec_read(codec, 0x21, 0,
18256 AC_VERB_GET_PIN_SENSE, 0)
18257 & AC_PINSENSE_PRESENCE;
18258 present2 = snd_hda_codec_read(codec, 0x15, 0,
18259 AC_VERB_GET_PIN_SENSE, 0)
18260 & AC_PINSENSE_PRESENCE;
18261
18262 if (present1 || present2) {
18263 snd_hda_codec_write_cache(codec, 0x14, 0,
18264 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18265 snd_hda_codec_write_cache(codec, 0x17, 0,
18266 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18267 } else {
18268 snd_hda_codec_write_cache(codec, 0x14, 0,
18269 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18270 snd_hda_codec_write_cache(codec, 0x17, 0,
18271 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18272 }
18273}
18274
Kailang Yang6dda9f42008-05-27 12:05:31 +020018275static void alc663_m51va_unsol_event(struct hda_codec *codec,
18276 unsigned int res)
18277{
18278 switch (res >> 26) {
18279 case ALC880_HP_EVENT:
18280 alc663_m51va_speaker_automute(codec);
18281 break;
18282 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018283 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018284 break;
18285 }
18286}
18287
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018288static void alc663_m51va_setup(struct hda_codec *codec)
18289{
18290 struct alc_spec *spec = codec->spec;
18291 spec->ext_mic.pin = 0x18;
18292 spec->ext_mic.mux_idx = 0;
18293 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018294 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018295 spec->auto_mic = 1;
18296}
18297
Kailang Yang6dda9f42008-05-27 12:05:31 +020018298static void alc663_m51va_inithook(struct hda_codec *codec)
18299{
18300 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018301 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018302}
18303
Kailang Yangf1d4e282008-08-26 14:03:29 +020018304/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018305#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018306
18307static void alc663_mode1_setup(struct hda_codec *codec)
18308{
18309 struct alc_spec *spec = codec->spec;
18310 spec->ext_mic.pin = 0x18;
18311 spec->ext_mic.mux_idx = 0;
18312 spec->int_mic.pin = 0x19;
18313 spec->int_mic.mux_idx = 1;
18314 spec->auto_mic = 1;
18315}
18316
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018317#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018318
Kailang Yangf1d4e282008-08-26 14:03:29 +020018319/* ***************** Mode2 ******************************/
18320static void alc662_mode2_unsol_event(struct hda_codec *codec,
18321 unsigned int res)
18322{
18323 switch (res >> 26) {
18324 case ALC880_HP_EVENT:
18325 alc662_f5z_speaker_automute(codec);
18326 break;
18327 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018328 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018329 break;
18330 }
18331}
18332
Kailang Yangebb83ee2009-12-17 12:23:00 +010018333#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018334
Kailang Yangf1d4e282008-08-26 14:03:29 +020018335static void alc662_mode2_inithook(struct hda_codec *codec)
18336{
18337 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018338 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018339}
18340/* ***************** Mode3 ******************************/
18341static void alc663_mode3_unsol_event(struct hda_codec *codec,
18342 unsigned int res)
18343{
18344 switch (res >> 26) {
18345 case ALC880_HP_EVENT:
18346 alc663_two_hp_m1_speaker_automute(codec);
18347 break;
18348 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018349 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018350 break;
18351 }
18352}
18353
Kailang Yangebb83ee2009-12-17 12:23:00 +010018354#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018355
Kailang Yangf1d4e282008-08-26 14:03:29 +020018356static void alc663_mode3_inithook(struct hda_codec *codec)
18357{
18358 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018359 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018360}
18361/* ***************** Mode4 ******************************/
18362static void alc663_mode4_unsol_event(struct hda_codec *codec,
18363 unsigned int res)
18364{
18365 switch (res >> 26) {
18366 case ALC880_HP_EVENT:
18367 alc663_21jd_two_speaker_automute(codec);
18368 break;
18369 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018370 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018371 break;
18372 }
18373}
18374
Kailang Yangebb83ee2009-12-17 12:23:00 +010018375#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018376
Kailang Yangf1d4e282008-08-26 14:03:29 +020018377static void alc663_mode4_inithook(struct hda_codec *codec)
18378{
18379 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018380 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018381}
18382/* ***************** Mode5 ******************************/
18383static void alc663_mode5_unsol_event(struct hda_codec *codec,
18384 unsigned int res)
18385{
18386 switch (res >> 26) {
18387 case ALC880_HP_EVENT:
18388 alc663_15jd_two_speaker_automute(codec);
18389 break;
18390 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018391 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018392 break;
18393 }
18394}
18395
Kailang Yangebb83ee2009-12-17 12:23:00 +010018396#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018397
Kailang Yangf1d4e282008-08-26 14:03:29 +020018398static void alc663_mode5_inithook(struct hda_codec *codec)
18399{
18400 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018401 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018402}
18403/* ***************** Mode6 ******************************/
18404static void alc663_mode6_unsol_event(struct hda_codec *codec,
18405 unsigned int res)
18406{
18407 switch (res >> 26) {
18408 case ALC880_HP_EVENT:
18409 alc663_two_hp_m2_speaker_automute(codec);
18410 break;
18411 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018412 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018413 break;
18414 }
18415}
18416
Kailang Yangebb83ee2009-12-17 12:23:00 +010018417#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018418
Kailang Yangf1d4e282008-08-26 14:03:29 +020018419static void alc663_mode6_inithook(struct hda_codec *codec)
18420{
18421 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018422 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018423}
18424
Kailang Yangebb83ee2009-12-17 12:23:00 +010018425/* ***************** Mode7 ******************************/
18426static void alc663_mode7_unsol_event(struct hda_codec *codec,
18427 unsigned int res)
18428{
18429 switch (res >> 26) {
18430 case ALC880_HP_EVENT:
18431 alc663_two_hp_m7_speaker_automute(codec);
18432 break;
18433 case ALC880_MIC_EVENT:
18434 alc_mic_automute(codec);
18435 break;
18436 }
18437}
18438
18439#define alc663_mode7_setup alc663_mode1_setup
18440
18441static void alc663_mode7_inithook(struct hda_codec *codec)
18442{
18443 alc663_two_hp_m7_speaker_automute(codec);
18444 alc_mic_automute(codec);
18445}
18446
18447/* ***************** Mode8 ******************************/
18448static void alc663_mode8_unsol_event(struct hda_codec *codec,
18449 unsigned int res)
18450{
18451 switch (res >> 26) {
18452 case ALC880_HP_EVENT:
18453 alc663_two_hp_m8_speaker_automute(codec);
18454 break;
18455 case ALC880_MIC_EVENT:
18456 alc_mic_automute(codec);
18457 break;
18458 }
18459}
18460
18461#define alc663_mode8_setup alc663_m51va_setup
18462
18463static void alc663_mode8_inithook(struct hda_codec *codec)
18464{
18465 alc663_two_hp_m8_speaker_automute(codec);
18466 alc_mic_automute(codec);
18467}
18468
Kailang Yang6dda9f42008-05-27 12:05:31 +020018469static void alc663_g71v_hp_automute(struct hda_codec *codec)
18470{
18471 unsigned int present;
18472 unsigned char bits;
18473
Wu Fengguang864f92b2009-11-18 12:38:02 +080018474 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018475 bits = present ? HDA_AMP_MUTE : 0;
18476 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18477 HDA_AMP_MUTE, bits);
18478 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18479 HDA_AMP_MUTE, bits);
18480}
18481
18482static void alc663_g71v_front_automute(struct hda_codec *codec)
18483{
18484 unsigned int present;
18485 unsigned char bits;
18486
Wu Fengguang864f92b2009-11-18 12:38:02 +080018487 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018488 bits = present ? HDA_AMP_MUTE : 0;
18489 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18490 HDA_AMP_MUTE, bits);
18491}
18492
18493static void alc663_g71v_unsol_event(struct hda_codec *codec,
18494 unsigned int res)
18495{
18496 switch (res >> 26) {
18497 case ALC880_HP_EVENT:
18498 alc663_g71v_hp_automute(codec);
18499 break;
18500 case ALC880_FRONT_EVENT:
18501 alc663_g71v_front_automute(codec);
18502 break;
18503 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018504 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018505 break;
18506 }
18507}
18508
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018509#define alc663_g71v_setup alc663_m51va_setup
18510
Kailang Yang6dda9f42008-05-27 12:05:31 +020018511static void alc663_g71v_inithook(struct hda_codec *codec)
18512{
18513 alc663_g71v_front_automute(codec);
18514 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018515 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018516}
18517
18518static void alc663_g50v_unsol_event(struct hda_codec *codec,
18519 unsigned int res)
18520{
18521 switch (res >> 26) {
18522 case ALC880_HP_EVENT:
18523 alc663_m51va_speaker_automute(codec);
18524 break;
18525 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018526 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018527 break;
18528 }
18529}
18530
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018531#define alc663_g50v_setup alc663_m51va_setup
18532
Kailang Yang6dda9f42008-05-27 12:05:31 +020018533static void alc663_g50v_inithook(struct hda_codec *codec)
18534{
18535 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018536 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018537}
18538
Kailang Yangf1d4e282008-08-26 14:03:29 +020018539static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18540 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018541 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018542
18543 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18544 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18545 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18546
18547 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18548 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18549 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18550 { } /* end */
18551};
18552
Chris Pockelé9541ba12009-05-12 08:08:53 +020018553static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18554 /* Master Playback automatically created from Speaker and Headphone */
18555 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18556 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18557 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18559
18560 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18561 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18562 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18563
18564 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18565 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18566 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18567 { } /* end */
18568};
18569
Takashi Iwaicb53c622007-08-10 17:21:45 +020018570#ifdef CONFIG_SND_HDA_POWER_SAVE
18571#define alc662_loopbacks alc880_loopbacks
18572#endif
18573
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018574
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018575/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018576#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18577#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18578#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18579#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18580
18581/*
18582 * configuration and preset
18583 */
18584static const char *alc662_models[ALC662_MODEL_LAST] = {
18585 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18586 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18587 [ALC662_3ST_6ch] = "3stack-6ch",
18588 [ALC662_5ST_DIG] = "6stack-dig",
18589 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018590 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018591 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018592 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018593 [ALC663_ASUS_M51VA] = "m51va",
18594 [ALC663_ASUS_G71V] = "g71v",
18595 [ALC663_ASUS_H13] = "h13",
18596 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018597 [ALC663_ASUS_MODE1] = "asus-mode1",
18598 [ALC662_ASUS_MODE2] = "asus-mode2",
18599 [ALC663_ASUS_MODE3] = "asus-mode3",
18600 [ALC663_ASUS_MODE4] = "asus-mode4",
18601 [ALC663_ASUS_MODE5] = "asus-mode5",
18602 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018603 [ALC663_ASUS_MODE7] = "asus-mode7",
18604 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018605 [ALC272_DELL] = "dell",
18606 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018607 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018608 [ALC662_AUTO] = "auto",
18609};
18610
18611static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018612 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018613 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18614 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018615 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18616 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018617 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018618 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18619 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18620 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18621 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018622 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18623 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018624 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018625 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18626 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18627 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18628 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18629 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018630 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018631 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18632 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018633 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18634 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18635 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18636 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018637 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018638 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18639 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18640 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018641 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18642 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18643 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18644 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018645 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018646 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18647 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018648 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018649 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18650 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18651 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018652 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018653 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018654 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18655 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018656 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18657 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18658 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018659 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018660 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18661 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018662 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018663 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018664 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018665 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18666 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18667 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018668 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018669 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18670 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018671 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018672 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018673 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018674 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018675 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18676 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018677 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018678 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018679 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18680 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018681 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018682 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018683 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018684 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018685 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018686 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018687 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18688 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018689 {}
18690};
18691
18692static struct alc_config_preset alc662_presets[] = {
18693 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018694 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018695 .init_verbs = { alc662_init_verbs },
18696 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18697 .dac_nids = alc662_dac_nids,
18698 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018699 .dig_in_nid = ALC662_DIGIN_NID,
18700 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18701 .channel_mode = alc662_3ST_2ch_modes,
18702 .input_mux = &alc662_capture_source,
18703 },
18704 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018705 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018706 .init_verbs = { alc662_init_verbs },
18707 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18708 .dac_nids = alc662_dac_nids,
18709 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018710 .dig_in_nid = ALC662_DIGIN_NID,
18711 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18712 .channel_mode = alc662_3ST_6ch_modes,
18713 .need_dac_fix = 1,
18714 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018715 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018716 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018717 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018718 .init_verbs = { alc662_init_verbs },
18719 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18720 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018721 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18722 .channel_mode = alc662_3ST_6ch_modes,
18723 .need_dac_fix = 1,
18724 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018725 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018726 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018727 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018728 .init_verbs = { alc662_init_verbs },
18729 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18730 .dac_nids = alc662_dac_nids,
18731 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018732 .dig_in_nid = ALC662_DIGIN_NID,
18733 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18734 .channel_mode = alc662_5stack_modes,
18735 .input_mux = &alc662_capture_source,
18736 },
18737 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018738 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018739 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18740 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18741 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018742 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18743 .channel_mode = alc662_3ST_2ch_modes,
18744 .input_mux = &alc662_lenovo_101e_capture_source,
18745 .unsol_event = alc662_lenovo_101e_unsol_event,
18746 .init_hook = alc662_lenovo_101e_all_automute,
18747 },
Kailang Yang291702f2007-10-16 14:28:03 +020018748 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018749 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018750 .init_verbs = { alc662_init_verbs,
18751 alc662_eeepc_sue_init_verbs },
18752 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18753 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018754 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18755 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018756 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018757 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018758 .init_hook = alc662_eeepc_inithook,
18759 },
Kailang Yang8c427222008-01-10 13:03:59 +010018760 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018761 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018762 alc662_chmode_mixer },
18763 .init_verbs = { alc662_init_verbs,
18764 alc662_eeepc_ep20_sue_init_verbs },
18765 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18766 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018767 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18768 .channel_mode = alc662_3ST_6ch_modes,
18769 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018770 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018771 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018772 .init_hook = alc662_eeepc_ep20_inithook,
18773 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018774 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018775 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018776 .init_verbs = { alc662_init_verbs,
18777 alc662_ecs_init_verbs },
18778 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18779 .dac_nids = alc662_dac_nids,
18780 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18781 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018782 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018783 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018784 .init_hook = alc662_eeepc_inithook,
18785 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018786 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018787 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018788 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18789 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18790 .dac_nids = alc662_dac_nids,
18791 .dig_out_nid = ALC662_DIGOUT_NID,
18792 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18793 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018794 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018795 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018796 .init_hook = alc663_m51va_inithook,
18797 },
18798 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018799 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018800 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18801 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18802 .dac_nids = alc662_dac_nids,
18803 .dig_out_nid = ALC662_DIGOUT_NID,
18804 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18805 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018806 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018807 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018808 .init_hook = alc663_g71v_inithook,
18809 },
18810 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018811 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018812 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18813 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18814 .dac_nids = alc662_dac_nids,
18815 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18816 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018817 .unsol_event = alc663_m51va_unsol_event,
18818 .init_hook = alc663_m51va_inithook,
18819 },
18820 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018821 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018822 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18823 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18824 .dac_nids = alc662_dac_nids,
18825 .dig_out_nid = ALC662_DIGOUT_NID,
18826 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18827 .channel_mode = alc662_3ST_6ch_modes,
18828 .input_mux = &alc663_capture_source,
18829 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018830 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018831 .init_hook = alc663_g50v_inithook,
18832 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018833 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018834 .mixers = { alc663_m51va_mixer },
18835 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018836 .init_verbs = { alc662_init_verbs,
18837 alc663_21jd_amic_init_verbs },
18838 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18839 .hp_nid = 0x03,
18840 .dac_nids = alc662_dac_nids,
18841 .dig_out_nid = ALC662_DIGOUT_NID,
18842 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18843 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018844 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018845 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018846 .init_hook = alc663_mode1_inithook,
18847 },
18848 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018849 .mixers = { alc662_1bjd_mixer },
18850 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018851 .init_verbs = { alc662_init_verbs,
18852 alc662_1bjd_amic_init_verbs },
18853 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18854 .dac_nids = alc662_dac_nids,
18855 .dig_out_nid = ALC662_DIGOUT_NID,
18856 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18857 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018858 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018859 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018860 .init_hook = alc662_mode2_inithook,
18861 },
18862 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018863 .mixers = { alc663_two_hp_m1_mixer },
18864 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018865 .init_verbs = { alc662_init_verbs,
18866 alc663_two_hp_amic_m1_init_verbs },
18867 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18868 .hp_nid = 0x03,
18869 .dac_nids = alc662_dac_nids,
18870 .dig_out_nid = ALC662_DIGOUT_NID,
18871 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18872 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018873 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018874 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018875 .init_hook = alc663_mode3_inithook,
18876 },
18877 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018878 .mixers = { alc663_asus_21jd_clfe_mixer },
18879 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018880 .init_verbs = { alc662_init_verbs,
18881 alc663_21jd_amic_init_verbs},
18882 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18883 .hp_nid = 0x03,
18884 .dac_nids = alc662_dac_nids,
18885 .dig_out_nid = ALC662_DIGOUT_NID,
18886 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18887 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018888 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018889 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018890 .init_hook = alc663_mode4_inithook,
18891 },
18892 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018893 .mixers = { alc663_asus_15jd_clfe_mixer },
18894 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018895 .init_verbs = { alc662_init_verbs,
18896 alc663_15jd_amic_init_verbs },
18897 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18898 .hp_nid = 0x03,
18899 .dac_nids = alc662_dac_nids,
18900 .dig_out_nid = ALC662_DIGOUT_NID,
18901 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18902 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018903 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018904 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018905 .init_hook = alc663_mode5_inithook,
18906 },
18907 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018908 .mixers = { alc663_two_hp_m2_mixer },
18909 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018910 .init_verbs = { alc662_init_verbs,
18911 alc663_two_hp_amic_m2_init_verbs },
18912 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18913 .hp_nid = 0x03,
18914 .dac_nids = alc662_dac_nids,
18915 .dig_out_nid = ALC662_DIGOUT_NID,
18916 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18917 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018918 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018919 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018920 .init_hook = alc663_mode6_inithook,
18921 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018922 [ALC663_ASUS_MODE7] = {
18923 .mixers = { alc663_mode7_mixer },
18924 .cap_mixer = alc662_auto_capture_mixer,
18925 .init_verbs = { alc662_init_verbs,
18926 alc663_mode7_init_verbs },
18927 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18928 .hp_nid = 0x03,
18929 .dac_nids = alc662_dac_nids,
18930 .dig_out_nid = ALC662_DIGOUT_NID,
18931 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18932 .channel_mode = alc662_3ST_2ch_modes,
18933 .unsol_event = alc663_mode7_unsol_event,
18934 .setup = alc663_mode7_setup,
18935 .init_hook = alc663_mode7_inithook,
18936 },
18937 [ALC663_ASUS_MODE8] = {
18938 .mixers = { alc663_mode8_mixer },
18939 .cap_mixer = alc662_auto_capture_mixer,
18940 .init_verbs = { alc662_init_verbs,
18941 alc663_mode8_init_verbs },
18942 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18943 .hp_nid = 0x03,
18944 .dac_nids = alc662_dac_nids,
18945 .dig_out_nid = ALC662_DIGOUT_NID,
18946 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18947 .channel_mode = alc662_3ST_2ch_modes,
18948 .unsol_event = alc663_mode8_unsol_event,
18949 .setup = alc663_mode8_setup,
18950 .init_hook = alc663_mode8_inithook,
18951 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018952 [ALC272_DELL] = {
18953 .mixers = { alc663_m51va_mixer },
18954 .cap_mixer = alc272_auto_capture_mixer,
18955 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18956 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18957 .dac_nids = alc662_dac_nids,
18958 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18959 .adc_nids = alc272_adc_nids,
18960 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18961 .capsrc_nids = alc272_capsrc_nids,
18962 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018963 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018964 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018965 .init_hook = alc663_m51va_inithook,
18966 },
18967 [ALC272_DELL_ZM1] = {
18968 .mixers = { alc663_m51va_mixer },
18969 .cap_mixer = alc662_auto_capture_mixer,
18970 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18971 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18972 .dac_nids = alc662_dac_nids,
18973 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18974 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018975 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018976 .capsrc_nids = alc662_capsrc_nids,
18977 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018978 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018979 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018980 .init_hook = alc663_m51va_inithook,
18981 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018982 [ALC272_SAMSUNG_NC10] = {
18983 .mixers = { alc272_nc10_mixer },
18984 .init_verbs = { alc662_init_verbs,
18985 alc663_21jd_amic_init_verbs },
18986 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18987 .dac_nids = alc272_dac_nids,
18988 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18989 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018990 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018991 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018992 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018993 .init_hook = alc663_mode4_inithook,
18994 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018995};
18996
18997
18998/*
18999 * BIOS auto configuration
19000 */
19001
Takashi Iwai7085ec12009-10-02 09:03:58 +020019002/* convert from MIX nid to DAC */
19003static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19004{
19005 if (nid == 0x0f)
19006 return 0x02;
19007 else if (nid >= 0x0c && nid <= 0x0e)
19008 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019009 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19010 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019011 else
19012 return 0;
19013}
19014
19015/* get MIX nid connected to the given pin targeted to DAC */
19016static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19017 hda_nid_t dac)
19018{
David Henningssoncc1c4522010-11-24 14:17:47 +010019019 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019020 int i, num;
19021
19022 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19023 for (i = 0; i < num; i++) {
19024 if (alc662_mix_to_dac(mix[i]) == dac)
19025 return mix[i];
19026 }
19027 return 0;
19028}
19029
19030/* look for an empty DAC slot */
19031static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19032{
19033 struct alc_spec *spec = codec->spec;
19034 hda_nid_t srcs[5];
19035 int i, j, num;
19036
19037 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19038 if (num < 0)
19039 return 0;
19040 for (i = 0; i < num; i++) {
19041 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19042 if (!nid)
19043 continue;
19044 for (j = 0; j < spec->multiout.num_dacs; j++)
19045 if (spec->multiout.dac_nids[j] == nid)
19046 break;
19047 if (j >= spec->multiout.num_dacs)
19048 return nid;
19049 }
19050 return 0;
19051}
19052
19053/* fill in the dac_nids table from the parsed pin configuration */
19054static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19055 const struct auto_pin_cfg *cfg)
19056{
19057 struct alc_spec *spec = codec->spec;
19058 int i;
19059 hda_nid_t dac;
19060
19061 spec->multiout.dac_nids = spec->private_dac_nids;
19062 for (i = 0; i < cfg->line_outs; i++) {
19063 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19064 if (!dac)
19065 continue;
19066 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19067 }
19068 return 0;
19069}
19070
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019071static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019072 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019073{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019074 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019075 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19076}
19077
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019078static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019079 hda_nid_t nid, unsigned int chs)
19080{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019081 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019082 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19083}
19084
19085#define alc662_add_stereo_vol(spec, pfx, nid) \
19086 alc662_add_vol_ctl(spec, pfx, nid, 3)
19087#define alc662_add_stereo_sw(spec, pfx, nid) \
19088 alc662_add_sw_ctl(spec, pfx, nid, 3)
19089
19090/* add playback controls from the parsed DAC table */
19091static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19092 const struct auto_pin_cfg *cfg)
19093{
19094 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019095 static const char *chname[4] = {
19096 "Front", "Surround", NULL /*CLFE*/, "Side"
19097 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020019098 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019099 int i, err;
19100
19101 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019102 nid = spec->multiout.dac_nids[i];
19103 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019104 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019105 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19106 if (!mix)
19107 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019108 if (i == 2) {
19109 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019110 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019111 if (err < 0)
19112 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019113 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019114 if (err < 0)
19115 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019116 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019117 if (err < 0)
19118 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019119 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019120 if (err < 0)
19121 return err;
19122 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019123 const char *pfx;
19124 if (cfg->line_outs == 1 &&
19125 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019126 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019127 pfx = "Speaker";
19128 else
19129 pfx = "PCM";
19130 } else
19131 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019132 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019133 if (err < 0)
19134 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019135 if (cfg->line_outs == 1 &&
19136 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19137 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020019138 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019139 if (err < 0)
19140 return err;
19141 }
19142 }
19143 return 0;
19144}
19145
19146/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019147/* return DAC nid if any new DAC is assigned */
19148static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019149 const char *pfx)
19150{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019151 struct alc_spec *spec = codec->spec;
19152 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019153 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019154
19155 if (!pin)
19156 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019157 nid = alc662_look_for_dac(codec, pin);
19158 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019159 /* the corresponding DAC is already occupied */
19160 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19161 return 0; /* no way */
19162 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019163 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019164 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19165 }
19166
19167 mix = alc662_dac_to_mix(codec, pin, nid);
19168 if (!mix)
19169 return 0;
19170 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19171 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019172 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019173 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19174 if (err < 0)
19175 return err;
19176 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019177}
19178
19179/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019180#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019181 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019182
19183static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19184 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019185 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019186{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019187 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019188 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019189
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019190 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019191 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019192 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19193 if (num <= 1)
19194 return;
19195 for (i = 0; i < num; i++) {
19196 if (alc662_mix_to_dac(srcs[i]) != dac)
19197 continue;
19198 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19199 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019200 }
19201}
19202
19203static void alc662_auto_init_multi_out(struct hda_codec *codec)
19204{
19205 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019206 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019207 int i;
19208
19209 for (i = 0; i <= HDA_SIDE; i++) {
19210 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19211 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019212 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019213 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019214 }
19215}
19216
19217static void alc662_auto_init_hp_out(struct hda_codec *codec)
19218{
19219 struct alc_spec *spec = codec->spec;
19220 hda_nid_t pin;
19221
19222 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019223 if (pin)
19224 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19225 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019226 pin = spec->autocfg.speaker_pins[0];
19227 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019228 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19229 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019230}
19231
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019232#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19233
19234static void alc662_auto_init_analog_input(struct hda_codec *codec)
19235{
19236 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019237 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019238 int i;
19239
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019240 for (i = 0; i < cfg->num_inputs; i++) {
19241 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019242 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019243 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019244 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019245 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019246 snd_hda_codec_write(codec, nid, 0,
19247 AC_VERB_SET_AMP_GAIN_MUTE,
19248 AMP_OUT_MUTE);
19249 }
19250 }
19251}
19252
Takashi Iwaif511b012008-08-15 16:46:42 +020019253#define alc662_auto_init_input_src alc882_auto_init_input_src
19254
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019255static int alc662_parse_auto_config(struct hda_codec *codec)
19256{
19257 struct alc_spec *spec = codec->spec;
19258 int err;
19259 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19260
19261 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19262 alc662_ignore);
19263 if (err < 0)
19264 return err;
19265 if (!spec->autocfg.line_outs)
19266 return 0; /* can't find valid BIOS pin config */
19267
Takashi Iwai7085ec12009-10-02 09:03:58 +020019268 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019269 if (err < 0)
19270 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019271 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019272 if (err < 0)
19273 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019274 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019275 spec->autocfg.speaker_pins[0],
19276 "Speaker");
19277 if (err < 0)
19278 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019279 if (err)
19280 spec->multiout.extra_out_nid[0] = err;
19281 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019282 "Headphone");
19283 if (err < 0)
19284 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019285 if (err)
19286 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019287 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019288 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019289 return err;
19290
19291 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19292
Takashi Iwai757899a2010-07-30 10:48:14 +020019293 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019294
Takashi Iwai603c4012008-07-30 15:01:44 +020019295 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019296 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019297
19298 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019299 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019300
Kailang Yangcec27c82010-02-04 14:18:18 +010019301 add_verb(spec, alc662_init_verbs);
19302 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019303 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019304 add_verb(spec, alc663_init_verbs);
19305
19306 if (codec->vendor_id == 0x10ec0272)
19307 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019308
19309 err = alc_auto_add_mic_boost(codec);
19310 if (err < 0)
19311 return err;
19312
Kailang Yang6227cdc2010-02-25 08:36:52 +010019313 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19314 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19315 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19316 else
19317 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019318
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019319 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019320}
19321
19322/* additional initialization for auto-configuration model */
19323static void alc662_auto_init(struct hda_codec *codec)
19324{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019325 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019326 alc662_auto_init_multi_out(codec);
19327 alc662_auto_init_hp_out(codec);
19328 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019329 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019330 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019331 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019332 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019333}
19334
David Henningsson6cb3b702010-09-09 08:51:44 +020019335enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019336 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019337 ALC662_FIXUP_IDEAPAD,
19338};
19339
19340static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019341 [ALC662_FIXUP_ASPIRE] = {
19342 .pins = (const struct alc_pincfg[]) {
19343 { 0x15, 0x99130112 }, /* subwoofer */
19344 { }
19345 }
19346 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019347 [ALC662_FIXUP_IDEAPAD] = {
19348 .pins = (const struct alc_pincfg[]) {
19349 { 0x17, 0x99130112 }, /* subwoofer */
19350 { }
19351 }
19352 },
19353};
19354
19355static struct snd_pci_quirk alc662_fixup_tbl[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019356 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019357 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019358 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019359 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19360 {}
19361};
19362
19363
19364
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019365static int patch_alc662(struct hda_codec *codec)
19366{
19367 struct alc_spec *spec;
19368 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019369 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019370
19371 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19372 if (!spec)
19373 return -ENOMEM;
19374
19375 codec->spec = spec;
19376
Kailang Yangda00c242010-03-19 11:23:45 +010019377 alc_auto_parse_customize_define(codec);
19378
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019379 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19380
Kailang Yang693194f2010-10-21 08:51:48 +020019381 coef = alc_read_coef_idx(codec, 0);
19382 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019383 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019384 else if (coef & (1 << 14) &&
19385 codec->bus->pci->subsystem_vendor == 0x1025 &&
19386 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019387 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019388 else if (coef == 0x4011)
19389 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019390
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019391 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19392 alc662_models,
19393 alc662_cfg_tbl);
19394 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019395 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19396 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019397 board_config = ALC662_AUTO;
19398 }
19399
19400 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019401 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019402 /* automatic parse from the BIOS config */
19403 err = alc662_parse_auto_config(codec);
19404 if (err < 0) {
19405 alc_free(codec);
19406 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019407 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019408 printk(KERN_INFO
19409 "hda_codec: Cannot set up configuration "
19410 "from BIOS. Using base mode...\n");
19411 board_config = ALC662_3ST_2ch_DIG;
19412 }
19413 }
19414
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019415 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019416 err = snd_hda_attach_beep_device(codec, 0x1);
19417 if (err < 0) {
19418 alc_free(codec);
19419 return err;
19420 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019421 }
19422
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019423 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019424 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019425
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019426 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19427 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19428
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019429 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19430 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19431
Takashi Iwaidd704692009-08-11 08:45:11 +020019432 if (!spec->adc_nids) {
19433 spec->adc_nids = alc662_adc_nids;
19434 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19435 }
19436 if (!spec->capsrc_nids)
19437 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019438
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019439 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019440 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019441
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019442 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019443 switch (codec->vendor_id) {
19444 case 0x10ec0662:
19445 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19446 break;
19447 case 0x10ec0272:
19448 case 0x10ec0663:
19449 case 0x10ec0665:
19450 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19451 break;
19452 case 0x10ec0273:
19453 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19454 break;
19455 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019456 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019457 spec->vmaster_nid = 0x02;
19458
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019459 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019460 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019461 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019462 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19463 }
19464
Kailang Yangbf1b0222010-10-21 08:49:56 +020019465 alc_init_jacks(codec);
19466
Takashi Iwaicb53c622007-08-10 17:21:45 +020019467#ifdef CONFIG_SND_HDA_POWER_SAVE
19468 if (!spec->loopback.amplist)
19469 spec->loopback.amplist = alc662_loopbacks;
19470#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019471
19472 return 0;
19473}
19474
Kailang Yang274693f2009-12-03 10:07:50 +010019475static int patch_alc888(struct hda_codec *codec)
19476{
19477 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19478 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019479 if (codec->vendor_id == 0x10ec0887)
19480 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19481 else
19482 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019483 if (!codec->chip_name) {
19484 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019485 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019486 }
19487 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019488 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019489 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019490}
19491
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019492/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019493 * ALC680 support
19494 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019495#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019496#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19497#define alc680_modes alc260_modes
19498
19499static hda_nid_t alc680_dac_nids[3] = {
19500 /* Lout1, Lout2, hp */
19501 0x02, 0x03, 0x04
19502};
19503
19504static hda_nid_t alc680_adc_nids[3] = {
19505 /* ADC0-2 */
19506 /* DMIC, MIC, Line-in*/
19507 0x07, 0x08, 0x09
19508};
19509
Kailang Yangc69aefa2010-08-17 10:39:22 +020019510/*
19511 * Analog capture ADC cgange
19512 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019513static void alc680_rec_autoswitch(struct hda_codec *codec)
19514{
19515 struct alc_spec *spec = codec->spec;
19516 struct auto_pin_cfg *cfg = &spec->autocfg;
19517 int pin_found = 0;
19518 int type_found = AUTO_PIN_LAST;
19519 hda_nid_t nid;
19520 int i;
19521
19522 for (i = 0; i < cfg->num_inputs; i++) {
19523 nid = cfg->inputs[i].pin;
19524 if (!(snd_hda_query_pin_caps(codec, nid) &
19525 AC_PINCAP_PRES_DETECT))
19526 continue;
19527 if (snd_hda_jack_detect(codec, nid)) {
19528 if (cfg->inputs[i].type < type_found) {
19529 type_found = cfg->inputs[i].type;
19530 pin_found = nid;
19531 }
19532 }
19533 }
19534
19535 nid = 0x07;
19536 if (pin_found)
19537 snd_hda_get_connections(codec, pin_found, &nid, 1);
19538
19539 if (nid != spec->cur_adc)
19540 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19541 spec->cur_adc = nid;
19542 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19543 spec->cur_adc_format);
19544}
19545
Kailang Yangc69aefa2010-08-17 10:39:22 +020019546static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19547 struct hda_codec *codec,
19548 unsigned int stream_tag,
19549 unsigned int format,
19550 struct snd_pcm_substream *substream)
19551{
19552 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019553
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019554 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019555 spec->cur_adc_stream_tag = stream_tag;
19556 spec->cur_adc_format = format;
19557
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019558 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019559 return 0;
19560}
19561
19562static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19563 struct hda_codec *codec,
19564 struct snd_pcm_substream *substream)
19565{
19566 snd_hda_codec_cleanup_stream(codec, 0x07);
19567 snd_hda_codec_cleanup_stream(codec, 0x08);
19568 snd_hda_codec_cleanup_stream(codec, 0x09);
19569 return 0;
19570}
19571
19572static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19573 .substreams = 1, /* can be overridden */
19574 .channels_min = 2,
19575 .channels_max = 2,
19576 /* NID is set in alc_build_pcms */
19577 .ops = {
19578 .prepare = alc680_capture_pcm_prepare,
19579 .cleanup = alc680_capture_pcm_cleanup
19580 },
19581};
19582
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019583static struct snd_kcontrol_new alc680_base_mixer[] = {
19584 /* output mixer control */
19585 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19586 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19587 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019589 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019590 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019591 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019592 { }
19593};
19594
Kailang Yangc69aefa2010-08-17 10:39:22 +020019595static struct hda_bind_ctls alc680_bind_cap_vol = {
19596 .ops = &snd_hda_bind_vol,
19597 .values = {
19598 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19599 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19600 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19601 0
19602 },
19603};
19604
19605static struct hda_bind_ctls alc680_bind_cap_switch = {
19606 .ops = &snd_hda_bind_sw,
19607 .values = {
19608 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19609 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19610 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19611 0
19612 },
19613};
19614
19615static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19616 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19617 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019618 { } /* end */
19619};
19620
19621/*
19622 * generic initialization of ADC, input mixers and output mixers
19623 */
19624static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019625 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19626 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19627 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019628
Kailang Yangc69aefa2010-08-17 10:39:22 +020019629 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19631 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19632 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19633 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19634 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019635
19636 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19638 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19639 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19640 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019641
19642 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19643 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019644 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019645
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019646 { }
19647};
19648
Kailang Yangc69aefa2010-08-17 10:39:22 +020019649/* toggle speaker-output according to the hp-jack state */
19650static void alc680_base_setup(struct hda_codec *codec)
19651{
19652 struct alc_spec *spec = codec->spec;
19653
19654 spec->autocfg.hp_pins[0] = 0x16;
19655 spec->autocfg.speaker_pins[0] = 0x14;
19656 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019657 spec->autocfg.num_inputs = 2;
19658 spec->autocfg.inputs[0].pin = 0x18;
19659 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19660 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019661 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019662}
19663
19664static void alc680_unsol_event(struct hda_codec *codec,
19665 unsigned int res)
19666{
19667 if ((res >> 26) == ALC880_HP_EVENT)
19668 alc_automute_amp(codec);
19669 if ((res >> 26) == ALC880_MIC_EVENT)
19670 alc680_rec_autoswitch(codec);
19671}
19672
19673static void alc680_inithook(struct hda_codec *codec)
19674{
19675 alc_automute_amp(codec);
19676 alc680_rec_autoswitch(codec);
19677}
19678
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019679/* create input playback/capture controls for the given pin */
19680static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19681 const char *ctlname, int idx)
19682{
19683 hda_nid_t dac;
19684 int err;
19685
19686 switch (nid) {
19687 case 0x14:
19688 dac = 0x02;
19689 break;
19690 case 0x15:
19691 dac = 0x03;
19692 break;
19693 case 0x16:
19694 dac = 0x04;
19695 break;
19696 default:
19697 return 0;
19698 }
19699 if (spec->multiout.dac_nids[0] != dac &&
19700 spec->multiout.dac_nids[1] != dac) {
19701 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19702 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19703 HDA_OUTPUT));
19704 if (err < 0)
19705 return err;
19706
19707 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19708 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19709
19710 if (err < 0)
19711 return err;
19712 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19713 }
19714
19715 return 0;
19716}
19717
19718/* add playback controls from the parsed DAC table */
19719static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19720 const struct auto_pin_cfg *cfg)
19721{
19722 hda_nid_t nid;
19723 int err;
19724
19725 spec->multiout.dac_nids = spec->private_dac_nids;
19726
19727 nid = cfg->line_out_pins[0];
19728 if (nid) {
19729 const char *name;
19730 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19731 name = "Speaker";
19732 else
19733 name = "Front";
19734 err = alc680_new_analog_output(spec, nid, name, 0);
19735 if (err < 0)
19736 return err;
19737 }
19738
19739 nid = cfg->speaker_pins[0];
19740 if (nid) {
19741 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19742 if (err < 0)
19743 return err;
19744 }
19745 nid = cfg->hp_pins[0];
19746 if (nid) {
19747 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19748 if (err < 0)
19749 return err;
19750 }
19751
19752 return 0;
19753}
19754
19755static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19756 hda_nid_t nid, int pin_type)
19757{
19758 alc_set_pin_output(codec, nid, pin_type);
19759}
19760
19761static void alc680_auto_init_multi_out(struct hda_codec *codec)
19762{
19763 struct alc_spec *spec = codec->spec;
19764 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19765 if (nid) {
19766 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19767 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19768 }
19769}
19770
19771static void alc680_auto_init_hp_out(struct hda_codec *codec)
19772{
19773 struct alc_spec *spec = codec->spec;
19774 hda_nid_t pin;
19775
19776 pin = spec->autocfg.hp_pins[0];
19777 if (pin)
19778 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19779 pin = spec->autocfg.speaker_pins[0];
19780 if (pin)
19781 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19782}
19783
19784/* pcm configuration: identical with ALC880 */
19785#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19786#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19787#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19788#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019789#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019790
19791/*
19792 * BIOS auto configuration
19793 */
19794static int alc680_parse_auto_config(struct hda_codec *codec)
19795{
19796 struct alc_spec *spec = codec->spec;
19797 int err;
19798 static hda_nid_t alc680_ignore[] = { 0 };
19799
19800 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19801 alc680_ignore);
19802 if (err < 0)
19803 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019804
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019805 if (!spec->autocfg.line_outs) {
19806 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19807 spec->multiout.max_channels = 2;
19808 spec->no_analog = 1;
19809 goto dig_only;
19810 }
19811 return 0; /* can't find valid BIOS pin config */
19812 }
19813 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19814 if (err < 0)
19815 return err;
19816
19817 spec->multiout.max_channels = 2;
19818
19819 dig_only:
19820 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019821 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019822 if (spec->kctls.list)
19823 add_mixer(spec, spec->kctls.list);
19824
19825 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019826
19827 err = alc_auto_add_mic_boost(codec);
19828 if (err < 0)
19829 return err;
19830
19831 return 1;
19832}
19833
19834#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19835
19836/* init callback for auto-configuration model -- overriding the default init */
19837static void alc680_auto_init(struct hda_codec *codec)
19838{
19839 struct alc_spec *spec = codec->spec;
19840 alc680_auto_init_multi_out(codec);
19841 alc680_auto_init_hp_out(codec);
19842 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019843 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019844 if (spec->unsol_event)
19845 alc_inithook(codec);
19846}
19847
19848/*
19849 * configuration and preset
19850 */
19851static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019852 [ALC680_BASE] = "base",
19853 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019854};
19855
19856static struct snd_pci_quirk alc680_cfg_tbl[] = {
19857 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19858 {}
19859};
19860
19861static struct alc_config_preset alc680_presets[] = {
19862 [ALC680_BASE] = {
19863 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019864 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019865 .init_verbs = { alc680_init_verbs },
19866 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19867 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019868 .dig_out_nid = ALC680_DIGOUT_NID,
19869 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19870 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019871 .unsol_event = alc680_unsol_event,
19872 .setup = alc680_base_setup,
19873 .init_hook = alc680_inithook,
19874
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019875 },
19876};
19877
19878static int patch_alc680(struct hda_codec *codec)
19879{
19880 struct alc_spec *spec;
19881 int board_config;
19882 int err;
19883
19884 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19885 if (spec == NULL)
19886 return -ENOMEM;
19887
19888 codec->spec = spec;
19889
19890 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19891 alc680_models,
19892 alc680_cfg_tbl);
19893
19894 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19895 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19896 codec->chip_name);
19897 board_config = ALC680_AUTO;
19898 }
19899
19900 if (board_config == ALC680_AUTO) {
19901 /* automatic parse from the BIOS config */
19902 err = alc680_parse_auto_config(codec);
19903 if (err < 0) {
19904 alc_free(codec);
19905 return err;
19906 } else if (!err) {
19907 printk(KERN_INFO
19908 "hda_codec: Cannot set up configuration "
19909 "from BIOS. Using base mode...\n");
19910 board_config = ALC680_BASE;
19911 }
19912 }
19913
19914 if (board_config != ALC680_AUTO)
19915 setup_preset(codec, &alc680_presets[board_config]);
19916
19917 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019918 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019919 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019920 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019921
19922 if (!spec->adc_nids) {
19923 spec->adc_nids = alc680_adc_nids;
19924 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19925 }
19926
19927 if (!spec->cap_mixer)
19928 set_capture_mixer(codec);
19929
19930 spec->vmaster_nid = 0x02;
19931
19932 codec->patch_ops = alc_patch_ops;
19933 if (board_config == ALC680_AUTO)
19934 spec->init_hook = alc680_auto_init;
19935
19936 return 0;
19937}
19938
19939/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019940 * patch entries
19941 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019942static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019943 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019944 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019945 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019946 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019947 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019948 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019949 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019950 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019951 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019952 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019953 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19954 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19955 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019956 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019957 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019958 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19959 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019960 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019961 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019962 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019963 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019964 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019965 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019966 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019967 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019968 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019969 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019970 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019971 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010019972 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020019973 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019974 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019975 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019976 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019977 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019978 {} /* terminator */
19979};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019980
19981MODULE_ALIAS("snd-hda-codec-id:10ec*");
19982
19983MODULE_LICENSE("GPL");
19984MODULE_DESCRIPTION("Realtek HD-audio codec");
19985
19986static struct hda_codec_preset_list realtek_list = {
19987 .preset = snd_hda_preset_realtek,
19988 .owner = THIS_MODULE,
19989};
19990
19991static int __init patch_realtek_init(void)
19992{
19993 return snd_hda_add_codec_preset(&realtek_list);
19994}
19995
19996static void __exit patch_realtek_exit(void)
19997{
19998 snd_hda_delete_codec_preset(&realtek_list);
19999}
20000
20001module_init(patch_realtek_init)
20002module_exit(patch_realtek_exit)