blob: 69554061c16eed90d46aef417fc0b1db5f4a00e2 [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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Avdoninbab282b2006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
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
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100306struct alc_fixup;
307
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308struct alc_spec {
309 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100310 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100312 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100313 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200315 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200316 * don't forget NULL
317 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200318 */
319 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200321 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 struct hda_pcm_stream *stream_analog_playback;
323 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100324 struct hda_pcm_stream *stream_analog_alt_playback;
325 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200327 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 struct hda_pcm_stream *stream_digital_playback;
329 struct hda_pcm_stream *stream_digital_capture;
330
331 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200332 struct hda_multi_out multiout; /* playback set-up
333 * max_channels, dacs must be set
334 * dig_out_nid and hp_nid are optional
335 */
Takashi Iwai63300792008-01-24 15:31:36 +0100336 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100337 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100338 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
340 /* capture */
341 unsigned int num_adc_nids;
342 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100343 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200344 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
Takashi Iwai840b64c2010-07-13 22:49:01 +0200346 /* capture setup for dynamic dual-adc switch */
347 unsigned int cur_adc_idx;
348 hda_nid_t cur_adc;
349 unsigned int cur_adc_stream_tag;
350 unsigned int cur_adc_format;
351
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200353 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 const struct hda_input_mux *input_mux;
355 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200356 struct alc_mic_route ext_mic;
357 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358
359 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100360 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200362 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200363 int const_channel_count;
364 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
366 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100367 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200368
Kailang Yang9ad0e492010-09-14 23:22:00 +0200369 /* jack detection */
370 struct snd_array jacks;
371
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200372 /* dynamic controls, init_verbs and input_mux */
373 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100374 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200375 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200376 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200377 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200378 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
379 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100380
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100381 /* hooks */
382 void (*init_hook)(struct hda_codec *codec);
383 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100384#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500385 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100386#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100387
Takashi Iwai834be882006-03-01 14:16:17 +0100388 /* for pin sensing */
389 unsigned int sense_updated: 1;
390 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100391 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200392 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200393
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100394 /* other flags */
395 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200396 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200397 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200398 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100399
Takashi Iwai2134ea42008-01-10 16:53:55 +0100400 /* for virtual master */
401 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200402#ifdef CONFIG_SND_HDA_POWER_SAVE
403 struct hda_loopback_check loopback;
404#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200405
406 /* for PLL fix */
407 hda_nid_t pll_nid;
408 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100409
410 /* fix-up list */
411 int fixup_id;
412 const struct alc_fixup *fixup_list;
413 const char *fixup_name;
Kailang Yangdf694da2005-12-05 19:42:22 +0100414};
415
416/*
417 * configuration template - to be copied to the spec instance
418 */
419struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420 struct snd_kcontrol_new *mixers[5]; /* should be identical size
421 * with spec
422 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100423 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100424 const struct hda_verb *init_verbs[5];
425 unsigned int num_dacs;
426 hda_nid_t *dac_nids;
427 hda_nid_t dig_out_nid; /* optional */
428 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800429 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100430 unsigned int num_adc_nids;
431 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100432 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100433 hda_nid_t dig_in_nid;
434 unsigned int num_channel_mode;
435 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200436 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200437 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200438 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100439 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100440 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200441 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100442 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200443#ifdef CONFIG_SND_HDA_POWER_SAVE
444 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500445 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200446#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447};
448
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
450/*
451 * input MUX handling
452 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200453static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
454 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455{
456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
457 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200458 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
459 if (mux_idx >= spec->num_mux_defs)
460 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100461 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
462 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200463 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464}
465
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200466static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
467 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468{
469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
470 struct alc_spec *spec = codec->spec;
471 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
472
473 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
474 return 0;
475}
476
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100482 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100484 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100485 hda_nid_t nid = spec->capsrc_nids ?
486 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200487 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488
Takashi Iwaicd896c32008-11-18 12:36:33 +0100489 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
490 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100491 if (!imux->num_items && mux_idx > 0)
492 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100493
Takashi Iwaia22d5432009-07-27 12:54:26 +0200494 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200495 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100496 /* Matrix-mixer style (e.g. ALC882) */
497 unsigned int *cur_val = &spec->cur_mux[adc_idx];
498 unsigned int i, idx;
499
500 idx = ucontrol->value.enumerated.item[0];
501 if (idx >= imux->num_items)
502 idx = imux->num_items - 1;
503 if (*cur_val == idx)
504 return 0;
505 for (i = 0; i < imux->num_items; i++) {
506 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
507 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
508 imux->items[i].index,
509 HDA_AMP_MUTE, v);
510 }
511 *cur_val = idx;
512 return 1;
513 } else {
514 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100515 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100516 &spec->cur_mux[adc_idx]);
517 }
518}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200519
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520/*
521 * channel mode setting
522 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
527 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100528 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
529 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530}
531
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534{
535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
536 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100537 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200539 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540}
541
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
543 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544{
545 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
546 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200547 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
548 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200549 &spec->ext_channel_count);
550 if (err >= 0 && !spec->const_channel_count) {
551 spec->multiout.max_channels = spec->ext_channel_count;
552 if (spec->need_dac_fix)
553 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
554 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200555 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556}
557
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200560 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561 * being part of a format specifier. Maximum allowed length of a value is
562 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100563 *
564 * Note: some retasking pin complexes seem to ignore requests for input
565 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
566 * are requested. Therefore order this list so that this behaviour will not
567 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200568 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
569 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200570 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100571static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100572 "Mic 50pc bias", "Mic 80pc bias",
573 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574};
575static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100576 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577};
578/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200579 * in the pin being assumed to be exclusively an input or an output pin. In
580 * addition, "input" pins may or may not process the mic bias option
581 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
582 * accept requests for bias as of chip versions up to March 2006) and/or
583 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100584 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200585#define ALC_PIN_DIR_IN 0x00
586#define ALC_PIN_DIR_OUT 0x01
587#define ALC_PIN_DIR_INOUT 0x02
588#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
589#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100590
Kailang Yangea1fb292008-08-26 12:58:38 +0200591/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592 * For each direction the minimum and maximum values are given.
593 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200594static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100595 { 0, 2 }, /* ALC_PIN_DIR_IN */
596 { 3, 4 }, /* ALC_PIN_DIR_OUT */
597 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200598 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
599 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100600};
601#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
602#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
603#define alc_pin_mode_n_items(_dir) \
604 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
605
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200606static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
607 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200608{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100609 unsigned int item_num = uinfo->value.enumerated.item;
610 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
611
612 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200613 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100614 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
615
616 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
617 item_num = alc_pin_mode_min(dir);
618 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200619 return 0;
620}
621
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200624{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100625 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100628 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200629 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200630 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
631 AC_VERB_GET_PIN_WIDGET_CONTROL,
632 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200633
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100634 /* Find enumerated value for current pinctl setting */
635 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200636 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100637 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200638 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100639 return 0;
640}
641
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200642static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100644{
645 signed int change;
646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
647 hda_nid_t nid = kcontrol->private_value & 0xffff;
648 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
649 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200650 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
651 AC_VERB_GET_PIN_WIDGET_CONTROL,
652 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100653
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200654 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100655 val = alc_pin_mode_min(dir);
656
657 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100658 if (change) {
659 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200660 snd_hda_codec_write_cache(codec, nid, 0,
661 AC_VERB_SET_PIN_WIDGET_CONTROL,
662 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100663
Kailang Yangea1fb292008-08-26 12:58:38 +0200664 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100665 * for the requested pin mode. Enum values of 2 or less are
666 * input modes.
667 *
668 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200669 * reduces noise slightly (particularly on input) so we'll
670 * do it. However, having both input and output buffers
671 * enabled simultaneously doesn't seem to be problematic if
672 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100673 */
674 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200675 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
676 HDA_AMP_MUTE, HDA_AMP_MUTE);
677 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
678 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100679 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200680 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
681 HDA_AMP_MUTE, HDA_AMP_MUTE);
682 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
683 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100684 }
685 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200686 return change;
687}
688
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100689#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200690 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100691 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100692 .info = alc_pin_mode_info, \
693 .get = alc_pin_mode_get, \
694 .put = alc_pin_mode_put, \
695 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100696
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100697/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
698 * together using a mask with more than one bit set. This control is
699 * currently used only by the ALC260 test model. At this stage they are not
700 * needed for any "production" models.
701 */
702#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200703#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200704
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
706 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100707{
708 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
709 hda_nid_t nid = kcontrol->private_value & 0xffff;
710 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
711 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200712 unsigned int val = snd_hda_codec_read(codec, nid, 0,
713 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100714
715 *valp = (val & mask) != 0;
716 return 0;
717}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200718static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
719 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100720{
721 signed int change;
722 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
723 hda_nid_t nid = kcontrol->private_value & 0xffff;
724 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
725 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
727 AC_VERB_GET_GPIO_DATA,
728 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100729
730 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200731 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
732 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100733 gpio_data &= ~mask;
734 else
735 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200736 snd_hda_codec_write_cache(codec, nid, 0,
737 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100738
739 return change;
740}
741#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
742 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100743 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100744 .info = alc_gpio_data_info, \
745 .get = alc_gpio_data_get, \
746 .put = alc_gpio_data_put, \
747 .private_value = nid | (mask<<16) }
748#endif /* CONFIG_SND_DEBUG */
749
Jonathan Woithe92621f12006-02-28 11:47:47 +0100750/* A switch control to allow the enabling of the digital IO pins on the
751 * ALC260. This is incredibly simplistic; the intention of this control is
752 * to provide something in the test model allowing digital outputs to be
753 * identified if present. If models are found which can utilise these
754 * outputs a more complete mixer control can be devised for those models if
755 * necessary.
756 */
757#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200758#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200759
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200760static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
761 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100762{
763 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
764 hda_nid_t nid = kcontrol->private_value & 0xffff;
765 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
766 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200767 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100768 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100769
770 *valp = (val & mask) != 0;
771 return 0;
772}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200773static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
774 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100775{
776 signed int change;
777 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
778 hda_nid_t nid = kcontrol->private_value & 0xffff;
779 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
780 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200781 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100782 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200783 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100784
785 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200786 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100787 if (val==0)
788 ctrl_data &= ~mask;
789 else
790 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200791 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
792 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100793
794 return change;
795}
796#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
797 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100798 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100799 .info = alc_spdif_ctrl_info, \
800 .get = alc_spdif_ctrl_get, \
801 .put = alc_spdif_ctrl_put, \
802 .private_value = nid | (mask<<16) }
803#endif /* CONFIG_SND_DEBUG */
804
Jonathan Woithef8225f62008-01-08 12:16:54 +0100805/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
806 * Again, this is only used in the ALC26x test models to help identify when
807 * the EAPD line must be asserted for features to work.
808 */
809#ifdef CONFIG_SND_DEBUG
810#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
811
812static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
813 struct snd_ctl_elem_value *ucontrol)
814{
815 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
816 hda_nid_t nid = kcontrol->private_value & 0xffff;
817 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
818 long *valp = ucontrol->value.integer.value;
819 unsigned int val = snd_hda_codec_read(codec, nid, 0,
820 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
821
822 *valp = (val & mask) != 0;
823 return 0;
824}
825
826static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
827 struct snd_ctl_elem_value *ucontrol)
828{
829 int change;
830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
831 hda_nid_t nid = kcontrol->private_value & 0xffff;
832 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
833 long val = *ucontrol->value.integer.value;
834 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
835 AC_VERB_GET_EAPD_BTLENABLE,
836 0x00);
837
838 /* Set/unset the masked control bit(s) as needed */
839 change = (!val ? 0 : mask) != (ctrl_data & mask);
840 if (!val)
841 ctrl_data &= ~mask;
842 else
843 ctrl_data |= mask;
844 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
845 ctrl_data);
846
847 return change;
848}
849
850#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
851 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100852 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100853 .info = alc_eapd_ctrl_info, \
854 .get = alc_eapd_ctrl_get, \
855 .put = alc_eapd_ctrl_put, \
856 .private_value = nid | (mask<<16) }
857#endif /* CONFIG_SND_DEBUG */
858
Kailang Yangdf694da2005-12-05 19:42:22 +0100859/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100860 * set up the input pin config (depending on the given auto-pin type)
861 */
862static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
863 int auto_pin_type)
864{
865 unsigned int val = PIN_IN;
866
Takashi Iwai86e29592010-09-09 14:50:17 +0200867 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100868 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200869 unsigned int oldval;
870 oldval = snd_hda_codec_read(codec, nid, 0,
871 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100872 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100873 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200874 /* if the default pin setup is vref50, we give it priority */
875 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100876 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200877 else if (pincap & AC_PINCAP_VREF_50)
878 val = PIN_VREF50;
879 else if (pincap & AC_PINCAP_VREF_100)
880 val = PIN_VREF100;
881 else if (pincap & AC_PINCAP_VREF_GRD)
882 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100883 }
884 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
885}
886
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200887static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
888{
889 struct alc_spec *spec = codec->spec;
890 struct auto_pin_cfg *cfg = &spec->autocfg;
891
892 if (!cfg->line_outs) {
893 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
894 cfg->line_out_pins[cfg->line_outs])
895 cfg->line_outs++;
896 }
897 if (!cfg->speaker_outs) {
898 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
899 cfg->speaker_pins[cfg->speaker_outs])
900 cfg->speaker_outs++;
901 }
902 if (!cfg->hp_outs) {
903 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
904 cfg->hp_pins[cfg->hp_outs])
905 cfg->hp_outs++;
906 }
907}
908
Takashi Iwai23f0c042009-02-26 13:03:58 +0100909/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100910 */
911static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
912{
913 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
914 return;
915 spec->mixers[spec->num_mixers++] = mix;
916}
917
918static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
919{
920 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
921 return;
922 spec->init_verbs[spec->num_init_verbs++] = verb;
923}
924
925/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100926 * set up from the preset table
927 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200928static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200929 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100930{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200931 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100932 int i;
933
934 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100935 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100936 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200937 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
938 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100939 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200940
Kailang Yangdf694da2005-12-05 19:42:22 +0100941 spec->channel_mode = preset->channel_mode;
942 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200943 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200944 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100945
Hector Martin3b315d72009-06-02 10:54:19 +0200946 if (preset->const_channel_count)
947 spec->multiout.max_channels = preset->const_channel_count;
948 else
949 spec->multiout.max_channels = spec->channel_mode[0].channels;
950 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100951
952 spec->multiout.num_dacs = preset->num_dacs;
953 spec->multiout.dac_nids = preset->dac_nids;
954 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800955 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100956 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200957
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200958 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200959 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200960 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100961 spec->input_mux = preset->input_mux;
962
963 spec->num_adc_nids = preset->num_adc_nids;
964 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100965 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100966 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100967
968 spec->unsol_event = preset->unsol_event;
969 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200970#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100971 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200972 spec->loopback.amplist = preset->loopbacks;
973#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200974
975 if (preset->setup)
976 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200977
978 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100979}
980
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200981/* Enable GPIO mask and set output */
982static struct hda_verb alc_gpio1_init_verbs[] = {
983 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
984 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
985 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
986 { }
987};
988
989static struct hda_verb alc_gpio2_init_verbs[] = {
990 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
991 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
992 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
993 { }
994};
995
Kailang Yangbdd148a2007-05-08 15:19:08 +0200996static struct hda_verb alc_gpio3_init_verbs[] = {
997 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
998 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
999 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
1000 { }
1001};
1002
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02001003/*
1004 * Fix hardware PLL issue
1005 * On some codecs, the analog PLL gating control must be off while
1006 * the default value is 1.
1007 */
1008static void alc_fix_pll(struct hda_codec *codec)
1009{
1010 struct alc_spec *spec = codec->spec;
1011 unsigned int val;
1012
1013 if (!spec->pll_nid)
1014 return;
1015 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1016 spec->pll_coef_idx);
1017 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1018 AC_VERB_GET_PROC_COEF, 0);
1019 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1020 spec->pll_coef_idx);
1021 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1022 val & ~(1 << spec->pll_coef_bit));
1023}
1024
1025static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1026 unsigned int coef_idx, unsigned int coef_bit)
1027{
1028 struct alc_spec *spec = codec->spec;
1029 spec->pll_nid = nid;
1030 spec->pll_coef_idx = coef_idx;
1031 spec->pll_coef_bit = coef_bit;
1032 alc_fix_pll(codec);
1033}
1034
Kailang Yang9ad0e492010-09-14 23:22:00 +02001035#ifdef CONFIG_SND_HDA_INPUT_JACK
1036static void alc_free_jack_priv(struct snd_jack *jack)
1037{
1038 struct alc_jack *jacks = jack->private_data;
1039 jacks->nid = 0;
1040 jacks->jack = NULL;
1041}
1042
1043static int alc_add_jack(struct hda_codec *codec,
1044 hda_nid_t nid, int type)
1045{
1046 struct alc_spec *spec;
1047 struct alc_jack *jack;
1048 const char *name;
1049 int err;
1050
1051 spec = codec->spec;
1052 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1053 jack = snd_array_new(&spec->jacks);
1054 if (!jack)
1055 return -ENOMEM;
1056
1057 jack->nid = nid;
1058 jack->type = type;
1059 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1060
1061 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1062 if (err < 0)
1063 return err;
1064 jack->jack->private_data = jack;
1065 jack->jack->private_free = alc_free_jack_priv;
1066 return 0;
1067}
1068
1069static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1070{
1071 struct alc_spec *spec = codec->spec;
1072 struct alc_jack *jacks = spec->jacks.list;
1073
1074 if (jacks) {
1075 int i;
1076 for (i = 0; i < spec->jacks.used; i++) {
1077 if (jacks->nid == nid) {
1078 unsigned int present;
1079 present = snd_hda_jack_detect(codec, nid);
1080
1081 present = (present) ? jacks->type : 0;
1082
1083 snd_jack_report(jacks->jack, present);
1084 }
1085 jacks++;
1086 }
1087 }
1088}
1089
1090static int alc_init_jacks(struct hda_codec *codec)
1091{
1092 struct alc_spec *spec = codec->spec;
1093 int err;
1094 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1095 unsigned int mic_nid = spec->ext_mic.pin;
1096
Takashi Iwai265a0242010-09-21 11:26:21 +02001097 if (hp_nid) {
1098 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1099 if (err < 0)
1100 return err;
1101 alc_report_jack(codec, hp_nid);
1102 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001103
Takashi Iwai265a0242010-09-21 11:26:21 +02001104 if (mic_nid) {
1105 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1106 if (err < 0)
1107 return err;
1108 alc_report_jack(codec, mic_nid);
1109 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001110
1111 return 0;
1112}
1113#else
1114static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1115{
1116}
1117
1118static inline int alc_init_jacks(struct hda_codec *codec)
1119{
1120 return 0;
1121}
1122#endif
1123
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001124static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001125{
1126 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001127 unsigned int mute;
1128 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001129 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001130
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001131 spec->jack_present = 0;
1132 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1133 nid = spec->autocfg.hp_pins[i];
1134 if (!nid)
1135 break;
1136 if (snd_hda_jack_detect(codec, nid)) {
1137 spec->jack_present = 1;
1138 break;
1139 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001140 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001141 }
1142
1143 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1144 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001145 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1146 nid = spec->autocfg.speaker_pins[i];
1147 if (!nid)
1148 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001149 if (pinctl) {
1150 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001151 AC_VERB_SET_PIN_WIDGET_CONTROL,
1152 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001153 } else {
1154 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1155 HDA_AMP_MUTE, mute);
1156 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001157 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001158}
1159
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001160static void alc_automute_pin(struct hda_codec *codec)
1161{
1162 alc_automute_speaker(codec, 1);
1163}
1164
Takashi Iwai6c819492009-08-10 18:47:44 +02001165static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1166 hda_nid_t nid)
1167{
1168 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1169 int i, nums;
1170
1171 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1172 for (i = 0; i < nums; i++)
1173 if (conn[i] == nid)
1174 return i;
1175 return -1;
1176}
1177
Takashi Iwai840b64c2010-07-13 22:49:01 +02001178/* switch the current ADC according to the jack state */
1179static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1180{
1181 struct alc_spec *spec = codec->spec;
1182 unsigned int present;
1183 hda_nid_t new_adc;
1184
1185 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1186 if (present)
1187 spec->cur_adc_idx = 1;
1188 else
1189 spec->cur_adc_idx = 0;
1190 new_adc = spec->adc_nids[spec->cur_adc_idx];
1191 if (spec->cur_adc && spec->cur_adc != new_adc) {
1192 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001193 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001194 spec->cur_adc = new_adc;
1195 snd_hda_codec_setup_stream(codec, new_adc,
1196 spec->cur_adc_stream_tag, 0,
1197 spec->cur_adc_format);
1198 }
1199}
1200
Kailang Yang7fb0d782008-10-15 11:12:35 +02001201static void alc_mic_automute(struct hda_codec *codec)
1202{
1203 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001204 struct alc_mic_route *dead, *alive;
1205 unsigned int present, type;
1206 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001207
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001208 if (!spec->auto_mic)
1209 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001210 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1211 return;
1212 if (snd_BUG_ON(!spec->adc_nids))
1213 return;
1214
Takashi Iwai840b64c2010-07-13 22:49:01 +02001215 if (spec->dual_adc_switch) {
1216 alc_dual_mic_adc_auto_switch(codec);
1217 return;
1218 }
1219
Takashi Iwai6c819492009-08-10 18:47:44 +02001220 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1221
Wu Fengguang864f92b2009-11-18 12:38:02 +08001222 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001223 if (present) {
1224 alive = &spec->ext_mic;
1225 dead = &spec->int_mic;
1226 } else {
1227 alive = &spec->int_mic;
1228 dead = &spec->ext_mic;
1229 }
1230
Takashi Iwai6c819492009-08-10 18:47:44 +02001231 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1232 if (type == AC_WID_AUD_MIX) {
1233 /* Matrix-mixer style (e.g. ALC882) */
1234 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1235 alive->mux_idx,
1236 HDA_AMP_MUTE, 0);
1237 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1238 dead->mux_idx,
1239 HDA_AMP_MUTE, HDA_AMP_MUTE);
1240 } else {
1241 /* MUX style (e.g. ALC880) */
1242 snd_hda_codec_write_cache(codec, cap_nid, 0,
1243 AC_VERB_SET_CONNECT_SEL,
1244 alive->mux_idx);
1245 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001246 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001247
1248 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001249}
1250
Kailang Yangc9b58002007-10-16 14:30:01 +02001251/* unsolicited event for HP jack sensing */
1252static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1253{
1254 if (codec->vendor_id == 0x10ec0880)
1255 res >>= 28;
1256 else
1257 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001258 switch (res) {
1259 case ALC880_HP_EVENT:
1260 alc_automute_pin(codec);
1261 break;
1262 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001263 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001264 break;
1265 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001266}
1267
1268static void alc_inithook(struct hda_codec *codec)
1269{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001270 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001271 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001272}
1273
Kailang Yangf9423e72008-05-27 12:32:25 +02001274/* additional initialization for ALC888 variants */
1275static void alc888_coef_init(struct hda_codec *codec)
1276{
1277 unsigned int tmp;
1278
1279 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1280 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1281 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001282 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001283 /* alc888S-VC */
1284 snd_hda_codec_read(codec, 0x20, 0,
1285 AC_VERB_SET_PROC_COEF, 0x830);
1286 else
1287 /* alc888-VB */
1288 snd_hda_codec_read(codec, 0x20, 0,
1289 AC_VERB_SET_PROC_COEF, 0x3030);
1290}
1291
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001292static void alc889_coef_init(struct hda_codec *codec)
1293{
1294 unsigned int tmp;
1295
1296 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1297 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1298 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1299 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1300}
1301
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001302/* turn on/off EAPD control (only if available) */
1303static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1304{
1305 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1306 return;
1307 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1308 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1309 on ? 2 : 0);
1310}
1311
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001312static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001313{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001314 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001315
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001316 switch (type) {
1317 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001318 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1319 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001320 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001321 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1322 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001323 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001324 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1325 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001326 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001327 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001328 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001329 set_eapd(codec, 0x0f, 1);
1330 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001331 break;
1332 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001333 case 0x10ec0267:
1334 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001335 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001336 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001337 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001338 case 0x10ec0660:
1339 case 0x10ec0662:
1340 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001341 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001342 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001343 set_eapd(codec, 0x14, 1);
1344 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001346 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001347 switch (codec->vendor_id) {
1348 case 0x10ec0260:
1349 snd_hda_codec_write(codec, 0x1a, 0,
1350 AC_VERB_SET_COEF_INDEX, 7);
1351 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1352 AC_VERB_GET_PROC_COEF, 0);
1353 snd_hda_codec_write(codec, 0x1a, 0,
1354 AC_VERB_SET_COEF_INDEX, 7);
1355 snd_hda_codec_write(codec, 0x1a, 0,
1356 AC_VERB_SET_PROC_COEF,
1357 tmp | 0x2010);
1358 break;
1359 case 0x10ec0262:
1360 case 0x10ec0880:
1361 case 0x10ec0882:
1362 case 0x10ec0883:
1363 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001364 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001365 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001366 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001367 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001368 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001369 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001370 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001371#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001372 case 0x10ec0267:
1373 case 0x10ec0268:
1374 snd_hda_codec_write(codec, 0x20, 0,
1375 AC_VERB_SET_COEF_INDEX, 7);
1376 tmp = snd_hda_codec_read(codec, 0x20, 0,
1377 AC_VERB_GET_PROC_COEF, 0);
1378 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001379 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001380 snd_hda_codec_write(codec, 0x20, 0,
1381 AC_VERB_SET_PROC_COEF,
1382 tmp | 0x3000);
1383 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001384#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001385 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001386 break;
1387 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001388}
Kailang Yangea1fb292008-08-26 12:58:38 +02001389
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001390static void alc_init_auto_hp(struct hda_codec *codec)
1391{
1392 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001393 struct auto_pin_cfg *cfg = &spec->autocfg;
1394 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001395
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001396 if (!cfg->hp_pins[0]) {
1397 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001398 return;
1399 }
1400
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001401 if (!cfg->speaker_pins[0]) {
1402 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1403 return;
1404 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1405 sizeof(cfg->speaker_pins));
1406 cfg->speaker_outs = cfg->line_outs;
1407 }
1408
1409 if (!cfg->hp_pins[0]) {
1410 memcpy(cfg->hp_pins, cfg->line_out_pins,
1411 sizeof(cfg->hp_pins));
1412 cfg->hp_outs = cfg->line_outs;
1413 }
1414
1415 for (i = 0; i < cfg->hp_outs; i++) {
1416 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1417 cfg->hp_pins[i]);
1418 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001419 AC_VERB_SET_UNSOLICITED_ENABLE,
1420 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001421 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001422 spec->unsol_event = alc_sku_unsol_event;
1423}
1424
Takashi Iwai6c819492009-08-10 18:47:44 +02001425static void alc_init_auto_mic(struct hda_codec *codec)
1426{
1427 struct alc_spec *spec = codec->spec;
1428 struct auto_pin_cfg *cfg = &spec->autocfg;
1429 hda_nid_t fixed, ext;
1430 int i;
1431
1432 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001433 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001434 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001435 return;
1436
1437 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001438 for (i = 0; i < cfg->num_inputs; i++) {
1439 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001440 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001441 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001442 switch (snd_hda_get_input_pin_attr(defcfg)) {
1443 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001444 if (fixed)
1445 return; /* already occupied */
1446 fixed = nid;
1447 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001448 case INPUT_PIN_ATTR_UNUSED:
1449 return; /* invalid entry */
1450 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001451 if (ext)
1452 return; /* already occupied */
1453 ext = nid;
1454 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001455 }
1456 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001457 if (!ext || !fixed)
1458 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001459 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1460 return; /* no unsol support */
1461 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1462 ext, fixed);
1463 spec->ext_mic.pin = ext;
1464 spec->int_mic.pin = fixed;
1465 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1466 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1467 spec->auto_mic = 1;
1468 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1469 AC_VERB_SET_UNSOLICITED_ENABLE,
1470 AC_USRSP_EN | ALC880_MIC_EVENT);
1471 spec->unsol_event = alc_sku_unsol_event;
1472}
1473
David Henningsson90622912010-10-14 14:50:18 +02001474/* Could be any non-zero and even value. When used as fixup, tells
1475 * the driver to ignore any present sku defines.
1476 */
1477#define ALC_FIXUP_SKU_IGNORE (2)
1478
Kailang Yangda00c242010-03-19 11:23:45 +01001479static int alc_auto_parse_customize_define(struct hda_codec *codec)
1480{
1481 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001482 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001483 struct alc_spec *spec = codec->spec;
1484
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001485 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1486
David Henningsson90622912010-10-14 14:50:18 +02001487 if (spec->cdefine.fixup) {
1488 ass = spec->cdefine.sku_cfg;
1489 if (ass == ALC_FIXUP_SKU_IGNORE)
1490 return -1;
1491 goto do_sku;
1492 }
1493
Kailang Yangda00c242010-03-19 11:23:45 +01001494 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001495 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001496 goto do_sku;
1497
1498 nid = 0x1d;
1499 if (codec->vendor_id == 0x10ec0260)
1500 nid = 0x17;
1501 ass = snd_hda_codec_get_pincfg(codec, nid);
1502
1503 if (!(ass & 1)) {
1504 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1505 codec->chip_name, ass);
1506 return -1;
1507 }
1508
1509 /* check sum */
1510 tmp = 0;
1511 for (i = 1; i < 16; i++) {
1512 if ((ass >> i) & 1)
1513 tmp++;
1514 }
1515 if (((ass >> 16) & 0xf) != tmp)
1516 return -1;
1517
1518 spec->cdefine.port_connectivity = ass >> 30;
1519 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1520 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1521 spec->cdefine.customization = ass >> 8;
1522do_sku:
1523 spec->cdefine.sku_cfg = ass;
1524 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1525 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1526 spec->cdefine.swap = (ass & 0x2) >> 1;
1527 spec->cdefine.override = ass & 0x1;
1528
1529 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1530 nid, spec->cdefine.sku_cfg);
1531 snd_printd("SKU: port_connectivity=0x%x\n",
1532 spec->cdefine.port_connectivity);
1533 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1534 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1535 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1536 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1537 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1538 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1539 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1540
1541 return 0;
1542}
1543
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001544/* check subsystem ID and set up device-specific initialization;
1545 * return 1 if initialized, 0 if invalid SSID
1546 */
1547/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1548 * 31 ~ 16 : Manufacture ID
1549 * 15 ~ 8 : SKU ID
1550 * 7 ~ 0 : Assembly ID
1551 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1552 */
1553static int alc_subsystem_id(struct hda_codec *codec,
1554 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001555 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001556{
1557 unsigned int ass, tmp, i;
1558 unsigned nid;
1559 struct alc_spec *spec = codec->spec;
1560
David Henningsson90622912010-10-14 14:50:18 +02001561 if (spec->cdefine.fixup) {
1562 ass = spec->cdefine.sku_cfg;
1563 if (ass == ALC_FIXUP_SKU_IGNORE)
1564 return 0;
1565 goto do_sku;
1566 }
1567
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001568 ass = codec->subsystem_id & 0xffff;
1569 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1570 goto do_sku;
1571
1572 /* invalid SSID, check the special NID pin defcfg instead */
1573 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001574 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001575 * 29~21 : reserve
1576 * 20 : PCBEEP input
1577 * 19~16 : Check sum (15:1)
1578 * 15~1 : Custom
1579 * 0 : override
1580 */
1581 nid = 0x1d;
1582 if (codec->vendor_id == 0x10ec0260)
1583 nid = 0x17;
1584 ass = snd_hda_codec_get_pincfg(codec, nid);
1585 snd_printd("realtek: No valid SSID, "
1586 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001587 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001588 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001589 return 0;
1590 if ((ass >> 30) != 1) /* no physical connection */
1591 return 0;
1592
1593 /* check sum */
1594 tmp = 0;
1595 for (i = 1; i < 16; i++) {
1596 if ((ass >> i) & 1)
1597 tmp++;
1598 }
1599 if (((ass >> 16) & 0xf) != tmp)
1600 return 0;
1601do_sku:
1602 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1603 ass & 0xffff, codec->vendor_id);
1604 /*
1605 * 0 : override
1606 * 1 : Swap Jack
1607 * 2 : 0 --> Desktop, 1 --> Laptop
1608 * 3~5 : External Amplifier control
1609 * 7~6 : Reserved
1610 */
1611 tmp = (ass & 0x38) >> 3; /* external Amp control */
1612 switch (tmp) {
1613 case 1:
1614 spec->init_amp = ALC_INIT_GPIO1;
1615 break;
1616 case 3:
1617 spec->init_amp = ALC_INIT_GPIO2;
1618 break;
1619 case 7:
1620 spec->init_amp = ALC_INIT_GPIO3;
1621 break;
1622 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001623 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001624 spec->init_amp = ALC_INIT_DEFAULT;
1625 break;
1626 }
1627
1628 /* is laptop or Desktop and enable the function "Mute internal speaker
1629 * when the external headphone out jack is plugged"
1630 */
1631 if (!(ass & 0x8000))
1632 return 1;
1633 /*
1634 * 10~8 : Jack location
1635 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1636 * 14~13: Resvered
1637 * 15 : 1 --> enable the function "Mute internal speaker
1638 * when the external headphone out jack is plugged"
1639 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001640 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001641 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001642 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1643 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001644 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001645 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001646 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001647 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001648 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001649 else if (tmp == 3)
1650 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001651 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001652 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001653 for (i = 0; i < spec->autocfg.line_outs; i++)
1654 if (spec->autocfg.line_out_pins[i] == nid)
1655 return 1;
1656 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001657 }
1658
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001659 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001660 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001661 return 1;
1662}
Kailang Yangea1fb292008-08-26 12:58:38 +02001663
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001664static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001665 hda_nid_t porta, hda_nid_t porte,
1666 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001667{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001668 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001669 struct alc_spec *spec = codec->spec;
1670 snd_printd("realtek: "
1671 "Enable default setup for auto mode as fallback\n");
1672 spec->init_amp = ALC_INIT_DEFAULT;
1673 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001674 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001675 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001676}
1677
Takashi Iwai41e41f12005-06-08 14:48:49 +02001678/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001679 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001680 */
1681
1682struct alc_pincfg {
1683 hda_nid_t nid;
1684 u32 val;
1685};
1686
Todd Broche1eb5f12010-12-06 11:19:51 -08001687struct alc_model_fixup {
1688 const int id;
1689 const char *name;
1690};
1691
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001692struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001693 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001694 bool chained;
1695 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001696 union {
1697 unsigned int sku;
1698 const struct alc_pincfg *pins;
1699 const struct hda_verb *verbs;
1700 void (*func)(struct hda_codec *codec,
1701 const struct alc_fixup *fix,
1702 int action);
1703 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001704};
1705
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001706enum {
1707 ALC_FIXUP_INVALID,
1708 ALC_FIXUP_SKU,
1709 ALC_FIXUP_PINS,
1710 ALC_FIXUP_VERBS,
1711 ALC_FIXUP_FUNC,
1712};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001713
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001714enum {
1715 ALC_FIXUP_ACT_PRE_PROBE,
1716 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001717 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001718};
1719
1720static void alc_apply_fixup(struct hda_codec *codec, int action)
1721{
1722 struct alc_spec *spec = codec->spec;
1723 int id = spec->fixup_id;
1724 const char *modelname = spec->fixup_name;
1725 int depth = 0;
1726
1727 if (!spec->fixup_list)
1728 return;
1729
1730 while (id >= 0) {
1731 const struct alc_fixup *fix = spec->fixup_list + id;
1732 const struct alc_pincfg *cfg;
1733
1734 switch (fix->type) {
1735 case ALC_FIXUP_SKU:
1736 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1737 break;;
1738 snd_printdd(KERN_INFO "hda_codec: %s: "
1739 "Apply sku override for %s\n",
1740 codec->chip_name, modelname);
1741 spec->cdefine.sku_cfg = fix->v.sku;
1742 spec->cdefine.fixup = 1;
1743 break;
1744 case ALC_FIXUP_PINS:
1745 cfg = fix->v.pins;
1746 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1747 break;
1748 snd_printdd(KERN_INFO "hda_codec: %s: "
1749 "Apply pincfg for %s\n",
1750 codec->chip_name, modelname);
1751 for (; cfg->nid; cfg++)
1752 snd_hda_codec_set_pincfg(codec, cfg->nid,
1753 cfg->val);
1754 break;
1755 case ALC_FIXUP_VERBS:
1756 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1757 break;
1758 snd_printdd(KERN_INFO "hda_codec: %s: "
1759 "Apply fix-verbs for %s\n",
1760 codec->chip_name, modelname);
1761 add_verb(codec->spec, fix->v.verbs);
1762 break;
1763 case ALC_FIXUP_FUNC:
1764 if (!fix->v.func)
1765 break;
1766 snd_printdd(KERN_INFO "hda_codec: %s: "
1767 "Apply fix-func for %s\n",
1768 codec->chip_name, modelname);
1769 fix->v.func(codec, fix, action);
1770 break;
1771 default:
1772 snd_printk(KERN_ERR "hda_codec: %s: "
1773 "Invalid fixup type %d\n",
1774 codec->chip_name, fix->type);
1775 break;
1776 }
1777 if (!fix[id].chained)
1778 break;
1779 if (++depth > 10)
1780 break;
1781 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001782 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001783}
1784
Todd Broche1eb5f12010-12-06 11:19:51 -08001785static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001786 const struct alc_model_fixup *models,
1787 const struct snd_pci_quirk *quirk,
1788 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001789{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001790 struct alc_spec *spec = codec->spec;
1791 int id = -1;
1792 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001793
Todd Broche1eb5f12010-12-06 11:19:51 -08001794 if (codec->modelname && models) {
1795 while (models->name) {
1796 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001797 id = models->id;
1798 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001799 break;
1800 }
1801 models++;
1802 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001803 }
1804 if (id < 0) {
1805 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1806 if (quirk) {
1807 id = quirk->value;
1808#ifdef CONFIG_SND_DEBUG_VERBOSE
1809 name = quirk->name;
1810#endif
1811 }
1812 }
1813
1814 spec->fixup_id = id;
1815 if (id >= 0) {
1816 spec->fixup_list = fixlist;
1817 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001818 }
1819}
1820
Kailang Yang274693f2009-12-03 10:07:50 +01001821static int alc_read_coef_idx(struct hda_codec *codec,
1822 unsigned int coef_idx)
1823{
1824 unsigned int val;
1825 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1826 coef_idx);
1827 val = snd_hda_codec_read(codec, 0x20, 0,
1828 AC_VERB_GET_PROC_COEF, 0);
1829 return val;
1830}
1831
Kailang Yang977ddd62010-09-15 10:02:29 +02001832static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1833 unsigned int coef_val)
1834{
1835 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1836 coef_idx);
1837 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1838 coef_val);
1839}
1840
Takashi Iwai757899a2010-07-30 10:48:14 +02001841/* set right pin controls for digital I/O */
1842static void alc_auto_init_digital(struct hda_codec *codec)
1843{
1844 struct alc_spec *spec = codec->spec;
1845 int i;
1846 hda_nid_t pin;
1847
1848 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1849 pin = spec->autocfg.dig_out_pins[i];
1850 if (pin) {
1851 snd_hda_codec_write(codec, pin, 0,
1852 AC_VERB_SET_PIN_WIDGET_CONTROL,
1853 PIN_OUT);
1854 }
1855 }
1856 pin = spec->autocfg.dig_in_pin;
1857 if (pin)
1858 snd_hda_codec_write(codec, pin, 0,
1859 AC_VERB_SET_PIN_WIDGET_CONTROL,
1860 PIN_IN);
1861}
1862
1863/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1864static void alc_auto_parse_digital(struct hda_codec *codec)
1865{
1866 struct alc_spec *spec = codec->spec;
1867 int i, err;
1868 hda_nid_t dig_nid;
1869
1870 /* support multiple SPDIFs; the secondary is set up as a slave */
1871 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1872 err = snd_hda_get_connections(codec,
1873 spec->autocfg.dig_out_pins[i],
1874 &dig_nid, 1);
1875 if (err < 0)
1876 continue;
1877 if (!i) {
1878 spec->multiout.dig_out_nid = dig_nid;
1879 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1880 } else {
1881 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1882 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1883 break;
1884 spec->slave_dig_outs[i - 1] = dig_nid;
1885 }
1886 }
1887
1888 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001889 dig_nid = codec->start_nid;
1890 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1891 unsigned int wcaps = get_wcaps(codec, dig_nid);
1892 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1893 continue;
1894 if (!(wcaps & AC_WCAP_DIGITAL))
1895 continue;
1896 if (!(wcaps & AC_WCAP_CONN_LIST))
1897 continue;
1898 err = get_connection_index(codec, dig_nid,
1899 spec->autocfg.dig_in_pin);
1900 if (err >= 0) {
1901 spec->dig_in_nid = dig_nid;
1902 break;
1903 }
1904 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001905 }
1906}
1907
Takashi Iwaif95474e2007-07-10 00:47:43 +02001908/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001909 * ALC888
1910 */
1911
1912/*
1913 * 2ch mode
1914 */
1915static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1916/* Mic-in jack as mic in */
1917 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1918 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1919/* Line-in jack as Line in */
1920 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1921 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1922/* Line-Out as Front */
1923 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1924 { } /* end */
1925};
1926
1927/*
1928 * 4ch mode
1929 */
1930static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1931/* Mic-in jack as mic in */
1932 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1933 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1934/* Line-in jack as Surround */
1935 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1936 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1937/* Line-Out as Front */
1938 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1939 { } /* end */
1940};
1941
1942/*
1943 * 6ch mode
1944 */
1945static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1946/* Mic-in jack as CLFE */
1947 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1948 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1949/* Line-in jack as Surround */
1950 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1951 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1952/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1953 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1954 { } /* end */
1955};
1956
1957/*
1958 * 8ch mode
1959 */
1960static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1961/* Mic-in jack as CLFE */
1962 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1963 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1964/* Line-in jack as Surround */
1965 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1966 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1967/* Line-Out as Side */
1968 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1969 { } /* end */
1970};
1971
1972static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1973 { 2, alc888_4ST_ch2_intel_init },
1974 { 4, alc888_4ST_ch4_intel_init },
1975 { 6, alc888_4ST_ch6_intel_init },
1976 { 8, alc888_4ST_ch8_intel_init },
1977};
1978
1979/*
1980 * ALC888 Fujitsu Siemens Amillo xa3530
1981 */
1982
1983static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1984/* Front Mic: set to PIN_IN (empty by default) */
1985 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1986/* Connect Internal HP to Front */
1987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1989 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1990/* Connect Bass HP to Front */
1991 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1992 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1994/* Connect Line-Out side jack (SPDIF) to Side */
1995 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1996 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1997 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1998/* Connect Mic jack to CLFE */
1999 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2000 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2001 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
2002/* Connect Line-in jack to Surround */
2003 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2004 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2005 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
2006/* Connect HP out jack to Front */
2007 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2008 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2009 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2010/* Enable unsolicited event for HP jack and Line-out jack */
2011 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2012 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2013 {}
2014};
2015
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002016static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002017{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02002018 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002019}
2020
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002021static void alc_automute_amp_unsol_event(struct hda_codec *codec,
2022 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002023{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002024 if (codec->vendor_id == 0x10ec0880)
2025 res >>= 28;
2026 else
2027 res >>= 26;
2028 if (res == ALC880_HP_EVENT)
2029 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002030}
2031
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002032static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02002033{
2034 struct alc_spec *spec = codec->spec;
2035
2036 spec->autocfg.hp_pins[0] = 0x15;
2037 spec->autocfg.speaker_pins[0] = 0x14;
2038 spec->autocfg.speaker_pins[1] = 0x16;
2039 spec->autocfg.speaker_pins[2] = 0x17;
2040 spec->autocfg.speaker_pins[3] = 0x19;
2041 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02002042}
2043
2044static void alc889_intel_init_hook(struct hda_codec *codec)
2045{
2046 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002047 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02002048}
2049
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002050static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002051{
2052 struct alc_spec *spec = codec->spec;
2053
2054 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
2055 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
2056 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
2057 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002058}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002059
2060/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002061 * ALC888 Acer Aspire 4930G model
2062 */
2063
2064static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
2065/* Front Mic: set to PIN_IN (empty by default) */
2066 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2067/* Unselect Front Mic by default in input mixer 3 */
2068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002069/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002070 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2071/* Connect Internal HP to front */
2072 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2073 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2074 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2075/* Connect HP out to front */
2076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002079 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002080 { }
2081};
2082
Hector Martin3b315d72009-06-02 10:54:19 +02002083/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002084 * ALC888 Acer Aspire 6530G model
2085 */
2086
2087static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002088/* Route to built-in subwoofer as well as speakers */
2089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002093/* Bias voltage on for external mic port */
2094 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002095/* Front Mic: set to PIN_IN (empty by default) */
2096 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2097/* Unselect Front Mic by default in input mixer 3 */
2098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002099/* Enable unsolicited event for HP jack */
2100 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2101/* Enable speaker output */
2102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2103 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002104 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002105/* Enable headphone output */
2106 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2107 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2108 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002109 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002110 { }
2111};
2112
2113/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002114 *ALC888 Acer Aspire 7730G model
2115 */
2116
2117static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2118/* Bias voltage on for external mic port */
2119 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2120/* Front Mic: set to PIN_IN (empty by default) */
2121 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2122/* Unselect Front Mic by default in input mixer 3 */
2123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2124/* Enable unsolicited event for HP jack */
2125 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2126/* Enable speaker output */
2127 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2128 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2129 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2130/* Enable headphone output */
2131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2134 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2135/*Enable internal subwoofer */
2136 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2137 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2138 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2139 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2140 { }
2141};
2142
2143/*
Hector Martin018df412009-06-04 00:13:40 +02002144 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002145 */
2146
Hector Martin018df412009-06-04 00:13:40 +02002147static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002148/* Front Mic: set to PIN_IN (empty by default) */
2149 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2150/* Unselect Front Mic by default in input mixer 3 */
2151 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2152/* Enable unsolicited event for HP jack */
2153 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2154/* Connect Internal Front to Front */
2155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2156 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2157 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2158/* Connect Internal Rear to Rear */
2159 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2160 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2161 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2162/* Connect Internal CLFE to CLFE */
2163 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2164 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2165 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2166/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002168 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2169 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2170/* Enable all DACs */
2171/* DAC DISABLE/MUTE 1? */
2172/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2173 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2174 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2175/* DAC DISABLE/MUTE 2? */
2176/* some bit here disables the other DACs. Init=0x4900 */
2177 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2178 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002179/* DMIC fix
2180 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2181 * which makes the stereo useless. However, either the mic or the ALC889
2182 * makes the signal become a difference/sum signal instead of standard
2183 * stereo, which is annoying. So instead we flip this bit which makes the
2184 * codec replicate the sum signal to both channels, turning it into a
2185 * normal mono mic.
2186 */
2187/* DMIC_CONTROL? Init value = 0x0001 */
2188 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2189 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002190 { }
2191};
2192
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002193static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002194 /* Front mic only available on one ADC */
2195 {
2196 .num_items = 4,
2197 .items = {
2198 { "Mic", 0x0 },
2199 { "Line", 0x2 },
2200 { "CD", 0x4 },
2201 { "Front Mic", 0xb },
2202 },
2203 },
2204 {
2205 .num_items = 3,
2206 .items = {
2207 { "Mic", 0x0 },
2208 { "Line", 0x2 },
2209 { "CD", 0x4 },
2210 },
2211 }
2212};
2213
Tony Vroond2fd4b02009-06-21 00:40:10 +01002214static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2215 /* Interal mic only available on one ADC */
2216 {
Tony Vroon684a8842009-06-26 09:27:50 +01002217 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002218 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002219 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002220 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002221 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002222 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002223 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002224 },
2225 },
2226 {
Tony Vroon684a8842009-06-26 09:27:50 +01002227 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002228 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002229 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002230 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002231 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002232 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002233 },
2234 }
2235};
2236
Hector Martin018df412009-06-04 00:13:40 +02002237static struct hda_input_mux alc889_capture_sources[3] = {
2238 /* Digital mic only available on first "ADC" */
2239 {
2240 .num_items = 5,
2241 .items = {
2242 { "Mic", 0x0 },
2243 { "Line", 0x2 },
2244 { "CD", 0x4 },
2245 { "Front Mic", 0xb },
2246 { "Input Mix", 0xa },
2247 },
2248 },
2249 {
2250 .num_items = 4,
2251 .items = {
2252 { "Mic", 0x0 },
2253 { "Line", 0x2 },
2254 { "CD", 0x4 },
2255 { "Input Mix", 0xa },
2256 },
2257 },
2258 {
2259 .num_items = 4,
2260 .items = {
2261 { "Mic", 0x0 },
2262 { "Line", 0x2 },
2263 { "CD", 0x4 },
2264 { "Input Mix", 0xa },
2265 },
2266 }
2267};
2268
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002269static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002270 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2271 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2272 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2273 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2274 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2275 HDA_OUTPUT),
2276 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2277 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2278 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2279 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2280 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2281 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2282 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2283 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2284 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002286 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002287 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002288 { } /* end */
2289};
2290
Hector Martin556eea92009-12-20 22:51:23 +01002291static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2292 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2293 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2294 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2295 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2296 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2297 HDA_OUTPUT),
2298 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2299 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2300 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2301 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2302 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002304 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002305 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2306 { } /* end */
2307};
2308
2309
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002310static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002311{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002312 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002313
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002314 spec->autocfg.hp_pins[0] = 0x15;
2315 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002316 spec->autocfg.speaker_pins[1] = 0x16;
2317 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002318}
2319
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002320static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002321{
2322 struct alc_spec *spec = codec->spec;
2323
2324 spec->autocfg.hp_pins[0] = 0x15;
2325 spec->autocfg.speaker_pins[0] = 0x14;
2326 spec->autocfg.speaker_pins[1] = 0x16;
2327 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002328}
2329
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002330static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2331{
2332 struct alc_spec *spec = codec->spec;
2333
2334 spec->autocfg.hp_pins[0] = 0x15;
2335 spec->autocfg.speaker_pins[0] = 0x14;
2336 spec->autocfg.speaker_pins[1] = 0x16;
2337 spec->autocfg.speaker_pins[2] = 0x17;
2338}
2339
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002340static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002341{
2342 struct alc_spec *spec = codec->spec;
2343
2344 spec->autocfg.hp_pins[0] = 0x15;
2345 spec->autocfg.speaker_pins[0] = 0x14;
2346 spec->autocfg.speaker_pins[1] = 0x16;
2347 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002348}
2349
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002350/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002351 * ALC880 3-stack model
2352 *
2353 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002354 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2355 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 */
2357
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002358static hda_nid_t alc880_dac_nids[4] = {
2359 /* front, rear, clfe, rear_surr */
2360 0x02, 0x05, 0x04, 0x03
2361};
2362
2363static hda_nid_t alc880_adc_nids[3] = {
2364 /* ADC0-2 */
2365 0x07, 0x08, 0x09,
2366};
2367
2368/* The datasheet says the node 0x07 is connected from inputs,
2369 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002370 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002372static hda_nid_t alc880_adc_nids_alt[2] = {
2373 /* ADC1-2 */
2374 0x08, 0x09,
2375};
2376
2377#define ALC880_DIGOUT_NID 0x06
2378#define ALC880_DIGIN_NID 0x0a
2379
2380static struct hda_input_mux alc880_capture_source = {
2381 .num_items = 4,
2382 .items = {
2383 { "Mic", 0x0 },
2384 { "Front Mic", 0x3 },
2385 { "Line", 0x2 },
2386 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002387 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002388};
2389
2390/* channel source setting (2/6 channel selection for 3-stack) */
2391/* 2ch mode */
2392static struct hda_verb alc880_threestack_ch2_init[] = {
2393 /* set line-in to input, mute it */
2394 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2395 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2396 /* set mic-in to input vref 80%, mute it */
2397 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2398 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002399 { } /* end */
2400};
2401
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002402/* 6ch mode */
2403static struct hda_verb alc880_threestack_ch6_init[] = {
2404 /* set line-in to output, unmute it */
2405 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2406 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2407 /* set mic-in to output, unmute it */
2408 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2409 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2410 { } /* end */
2411};
2412
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002413static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002414 { 2, alc880_threestack_ch2_init },
2415 { 6, alc880_threestack_ch6_init },
2416};
2417
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002418static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002419 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002420 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002421 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002422 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002423 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2424 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002425 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2426 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2428 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2429 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2430 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002436 {
2437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2438 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002439 .info = alc_ch_mode_info,
2440 .get = alc_ch_mode_get,
2441 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002442 },
2443 { } /* end */
2444};
2445
2446/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002447static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2448 struct snd_ctl_elem_info *uinfo)
2449{
2450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2451 struct alc_spec *spec = codec->spec;
2452 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002453
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002454 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002455 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2456 HDA_INPUT);
2457 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002458 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002459 return err;
2460}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002462static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2463 unsigned int size, unsigned int __user *tlv)
2464{
2465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2466 struct alc_spec *spec = codec->spec;
2467 int err;
2468
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002469 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002470 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2471 HDA_INPUT);
2472 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002473 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002474 return err;
2475}
2476
2477typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2478 struct snd_ctl_elem_value *ucontrol);
2479
2480static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2481 struct snd_ctl_elem_value *ucontrol,
2482 getput_call_t func)
2483{
2484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2485 struct alc_spec *spec = codec->spec;
2486 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2487 int err;
2488
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002489 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002490 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2491 3, 0, HDA_INPUT);
2492 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002493 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002494 return err;
2495}
2496
2497static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2498 struct snd_ctl_elem_value *ucontrol)
2499{
2500 return alc_cap_getput_caller(kcontrol, ucontrol,
2501 snd_hda_mixer_amp_volume_get);
2502}
2503
2504static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2505 struct snd_ctl_elem_value *ucontrol)
2506{
2507 return alc_cap_getput_caller(kcontrol, ucontrol,
2508 snd_hda_mixer_amp_volume_put);
2509}
2510
2511/* capture mixer elements */
2512#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2513
2514static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2515 struct snd_ctl_elem_value *ucontrol)
2516{
2517 return alc_cap_getput_caller(kcontrol, ucontrol,
2518 snd_hda_mixer_amp_switch_get);
2519}
2520
2521static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2522 struct snd_ctl_elem_value *ucontrol)
2523{
2524 return alc_cap_getput_caller(kcontrol, ucontrol,
2525 snd_hda_mixer_amp_switch_put);
2526}
2527
Takashi Iwaia23b6882009-03-23 15:21:36 +01002528#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002529 { \
2530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2531 .name = "Capture Switch", \
2532 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2533 .count = num, \
2534 .info = alc_cap_sw_info, \
2535 .get = alc_cap_sw_get, \
2536 .put = alc_cap_sw_put, \
2537 }, \
2538 { \
2539 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2540 .name = "Capture Volume", \
2541 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2542 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2543 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2544 .count = num, \
2545 .info = alc_cap_vol_info, \
2546 .get = alc_cap_vol_get, \
2547 .put = alc_cap_vol_put, \
2548 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002549 }
2550
2551#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002552 { \
2553 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2554 /* .name = "Capture Source", */ \
2555 .name = "Input Source", \
2556 .count = num, \
2557 .info = alc_mux_enum_info, \
2558 .get = alc_mux_enum_get, \
2559 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002560 }
2561
2562#define DEFINE_CAPMIX(num) \
2563static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2564 _DEFINE_CAPMIX(num), \
2565 _DEFINE_CAPSRC(num), \
2566 { } /* end */ \
2567}
2568
2569#define DEFINE_CAPMIX_NOSRC(num) \
2570static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2571 _DEFINE_CAPMIX(num), \
2572 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002573}
2574
2575/* up to three ADCs */
2576DEFINE_CAPMIX(1);
2577DEFINE_CAPMIX(2);
2578DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002579DEFINE_CAPMIX_NOSRC(1);
2580DEFINE_CAPMIX_NOSRC(2);
2581DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002582
2583/*
2584 * ALC880 5-stack model
2585 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002586 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2587 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2589 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2590 */
2591
2592/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002593static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002594 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002595 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 { } /* end */
2597};
2598
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002599/* channel source setting (6/8 channel selection for 5-stack) */
2600/* 6ch mode */
2601static struct hda_verb alc880_fivestack_ch6_init[] = {
2602 /* set line-in to input, mute it */
2603 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2604 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002605 { } /* end */
2606};
2607
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608/* 8ch mode */
2609static struct hda_verb alc880_fivestack_ch8_init[] = {
2610 /* set line-in to output, unmute it */
2611 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2612 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2613 { } /* end */
2614};
2615
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002616static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617 { 6, alc880_fivestack_ch6_init },
2618 { 8, alc880_fivestack_ch8_init },
2619};
2620
2621
2622/*
2623 * ALC880 6-stack model
2624 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002625 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2626 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002627 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2628 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2629 */
2630
2631static hda_nid_t alc880_6st_dac_nids[4] = {
2632 /* front, rear, clfe, rear_surr */
2633 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002634};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002635
2636static struct hda_input_mux alc880_6stack_capture_source = {
2637 .num_items = 4,
2638 .items = {
2639 { "Mic", 0x0 },
2640 { "Front Mic", 0x1 },
2641 { "Line", 0x2 },
2642 { "CD", 0x4 },
2643 },
2644};
2645
2646/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002647static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648 { 8, NULL },
2649};
2650
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002651static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002652 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002653 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002654 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002655 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002656 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2657 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002658 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2659 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002661 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2665 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2668 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2669 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 {
2671 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2672 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002673 .info = alc_ch_mode_info,
2674 .get = alc_ch_mode_get,
2675 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002676 },
2677 { } /* end */
2678};
2679
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680
2681/*
2682 * ALC880 W810 model
2683 *
2684 * W810 has rear IO for:
2685 * Front (DAC 02)
2686 * Surround (DAC 03)
2687 * Center/LFE (DAC 04)
2688 * Digital out (06)
2689 *
2690 * The system also has a pair of internal speakers, and a headphone jack.
2691 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002692 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002693 * There is a variable resistor to control the speaker or headphone
2694 * volume. This is a hardware-only device without a software API.
2695 *
2696 * Plugging headphones in will disable the internal speakers. This is
2697 * implemented in hardware, not via the driver using jack sense. In
2698 * a similar fashion, plugging into the rear socket marked "front" will
2699 * disable both the speakers and headphones.
2700 *
2701 * For input, there's a microphone jack, and an "audio in" jack.
2702 * These may not do anything useful with this driver yet, because I
2703 * haven't setup any initialization verbs for these yet...
2704 */
2705
2706static hda_nid_t alc880_w810_dac_nids[3] = {
2707 /* front, rear/surround, clfe */
2708 0x02, 0x03, 0x04
2709};
2710
2711/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002712static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002713 { 6, NULL }
2714};
2715
2716/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002717static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002718 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002719 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002720 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002721 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2723 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002724 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2725 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002726 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2727 { } /* end */
2728};
2729
2730
2731/*
2732 * Z710V model
2733 *
2734 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002735 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2736 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002737 */
2738
2739static hda_nid_t alc880_z71v_dac_nids[1] = {
2740 0x02
2741};
2742#define ALC880_Z71V_HP_DAC 0x03
2743
2744/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002745static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746 { 2, NULL }
2747};
2748
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002749static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002751 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002752 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002753 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2758 { } /* end */
2759};
2760
2761
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002762/*
2763 * ALC880 F1734 model
2764 *
2765 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2766 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2767 */
2768
2769static hda_nid_t alc880_f1734_dac_nids[1] = {
2770 0x03
2771};
2772#define ALC880_F1734_HP_DAC 0x02
2773
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002774static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002775 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002776 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002777 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2778 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002779 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2780 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002783 { } /* end */
2784};
2785
Takashi Iwai937b4162008-02-11 14:52:36 +01002786static struct hda_input_mux alc880_f1734_capture_source = {
2787 .num_items = 2,
2788 .items = {
2789 { "Mic", 0x1 },
2790 { "CD", 0x4 },
2791 },
2792};
2793
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002794
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795/*
2796 * ALC880 ASUS model
2797 *
2798 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2799 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2800 * Mic = 0x18, Line = 0x1a
2801 */
2802
2803#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2804#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2805
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002806static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002807 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002808 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002809 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002810 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002811 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2812 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002813 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2814 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002821 {
2822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2823 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002824 .info = alc_ch_mode_info,
2825 .get = alc_ch_mode_get,
2826 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002827 },
2828 { } /* end */
2829};
2830
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002831/*
2832 * ALC880 ASUS W1V model
2833 *
2834 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2835 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2836 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2837 */
2838
2839/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002840static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002841 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2842 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002843 { } /* end */
2844};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002845
Kailang Yangdf694da2005-12-05 19:42:22 +01002846/* TCL S700 */
2847static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2848 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2849 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2851 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2852 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2855 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2856 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002857 { } /* end */
2858};
2859
Kailang Yangccc656c2006-10-17 12:32:26 +02002860/* Uniwill */
2861static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002862 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2863 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2864 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2865 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002866 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2867 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2868 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2869 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2870 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2871 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2872 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2873 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2876 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002878 {
2879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2880 .name = "Channel Mode",
2881 .info = alc_ch_mode_info,
2882 .get = alc_ch_mode_get,
2883 .put = alc_ch_mode_put,
2884 },
2885 { } /* end */
2886};
2887
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002888static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2889 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2890 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2891 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2892 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002897 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2898 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002899 { } /* end */
2900};
2901
Kailang Yangccc656c2006-10-17 12:32:26 +02002902static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002903 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2904 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2905 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2906 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2909 { } /* end */
2910};
2911
Linus Torvalds1da177e2005-04-16 15:20:36 -07002912/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002913 * virtual master controls
2914 */
2915
2916/*
2917 * slave controls for virtual master
2918 */
2919static const char *alc_slave_vols[] = {
2920 "Front Playback Volume",
2921 "Surround Playback Volume",
2922 "Center Playback Volume",
2923 "LFE Playback Volume",
2924 "Side Playback Volume",
2925 "Headphone Playback Volume",
2926 "Speaker Playback Volume",
2927 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002928 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002929 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002930 NULL,
2931};
2932
2933static const char *alc_slave_sws[] = {
2934 "Front Playback Switch",
2935 "Surround Playback Switch",
2936 "Center Playback Switch",
2937 "LFE Playback Switch",
2938 "Side Playback Switch",
2939 "Headphone Playback Switch",
2940 "Speaker Playback Switch",
2941 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002942 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002943 "Line-Out Playback Switch",
2944 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002945 NULL,
2946};
2947
2948/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002949 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002951
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002952#define NID_MAPPING (-1)
2953
2954#define SUBDEV_SPEAKER_ (0 << 6)
2955#define SUBDEV_HP_ (1 << 6)
2956#define SUBDEV_LINE_ (2 << 6)
2957#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2958#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2959#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2960
Takashi Iwai603c4012008-07-30 15:01:44 +02002961static void alc_free_kctls(struct hda_codec *codec);
2962
Takashi Iwai67d634c2009-11-16 15:35:59 +01002963#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002964/* additional beep mixers; the actual parameters are overwritten at build */
2965static struct snd_kcontrol_new alc_beep_mixer[] = {
2966 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002967 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002968 { } /* end */
2969};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002970#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002971
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972static int alc_build_controls(struct hda_codec *codec)
2973{
2974 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002975 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002976 struct snd_kcontrol_new *knew;
2977 int i, j, err;
2978 unsigned int u;
2979 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002980
2981 for (i = 0; i < spec->num_mixers; i++) {
2982 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2983 if (err < 0)
2984 return err;
2985 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002986 if (spec->cap_mixer) {
2987 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2988 if (err < 0)
2989 return err;
2990 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002991 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002992 err = snd_hda_create_spdif_out_ctls(codec,
2993 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994 if (err < 0)
2995 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002996 if (!spec->no_analog) {
2997 err = snd_hda_create_spdif_share_sw(codec,
2998 &spec->multiout);
2999 if (err < 0)
3000 return err;
3001 spec->multiout.share_spdif = 1;
3002 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003 }
3004 if (spec->dig_in_nid) {
3005 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
3006 if (err < 0)
3007 return err;
3008 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01003009
Takashi Iwai67d634c2009-11-16 15:35:59 +01003010#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003011 /* create beep controls if needed */
3012 if (spec->beep_amp) {
3013 struct snd_kcontrol_new *knew;
3014 for (knew = alc_beep_mixer; knew->name; knew++) {
3015 struct snd_kcontrol *kctl;
3016 kctl = snd_ctl_new1(knew, codec);
3017 if (!kctl)
3018 return -ENOMEM;
3019 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003020 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003021 if (err < 0)
3022 return err;
3023 }
3024 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01003025#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003026
Takashi Iwai2134ea42008-01-10 16:53:55 +01003027 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003028 if (!spec->no_analog &&
3029 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003030 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01003031 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003032 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003033 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003034 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003035 if (err < 0)
3036 return err;
3037 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003038 if (!spec->no_analog &&
3039 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003040 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
3041 NULL, alc_slave_sws);
3042 if (err < 0)
3043 return err;
3044 }
3045
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003046 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02003047 if (spec->capsrc_nids || spec->adc_nids) {
3048 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3049 if (!kctl)
3050 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3051 for (i = 0; kctl && i < kctl->count; i++) {
3052 hda_nid_t *nids = spec->capsrc_nids;
3053 if (!nids)
3054 nids = spec->adc_nids;
3055 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3056 if (err < 0)
3057 return err;
3058 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003059 }
3060 if (spec->cap_mixer) {
3061 const char *kname = kctl ? kctl->id.name : NULL;
3062 for (knew = spec->cap_mixer; knew->name; knew++) {
3063 if (kname && strcmp(knew->name, kname) == 0)
3064 continue;
3065 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3066 for (i = 0; kctl && i < kctl->count; i++) {
3067 err = snd_hda_add_nid(codec, kctl, i,
3068 spec->adc_nids[i]);
3069 if (err < 0)
3070 return err;
3071 }
3072 }
3073 }
3074
3075 /* other nid->control mapping */
3076 for (i = 0; i < spec->num_mixers; i++) {
3077 for (knew = spec->mixers[i]; knew->name; knew++) {
3078 if (knew->iface != NID_MAPPING)
3079 continue;
3080 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3081 if (kctl == NULL)
3082 continue;
3083 u = knew->subdevice;
3084 for (j = 0; j < 4; j++, u >>= 8) {
3085 nid = u & 0x3f;
3086 if (nid == 0)
3087 continue;
3088 switch (u & 0xc0) {
3089 case SUBDEV_SPEAKER_:
3090 nid = spec->autocfg.speaker_pins[nid];
3091 break;
3092 case SUBDEV_LINE_:
3093 nid = spec->autocfg.line_out_pins[nid];
3094 break;
3095 case SUBDEV_HP_:
3096 nid = spec->autocfg.hp_pins[nid];
3097 break;
3098 default:
3099 continue;
3100 }
3101 err = snd_hda_add_nid(codec, kctl, 0, nid);
3102 if (err < 0)
3103 return err;
3104 }
3105 u = knew->private_value;
3106 for (j = 0; j < 4; j++, u >>= 8) {
3107 nid = u & 0xff;
3108 if (nid == 0)
3109 continue;
3110 err = snd_hda_add_nid(codec, kctl, 0, nid);
3111 if (err < 0)
3112 return err;
3113 }
3114 }
3115 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003116
3117 alc_free_kctls(codec); /* no longer needed */
3118
Linus Torvalds1da177e2005-04-16 15:20:36 -07003119 return 0;
3120}
3121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122
Linus Torvalds1da177e2005-04-16 15:20:36 -07003123/*
3124 * initialize the codec volumes, etc
3125 */
3126
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127/*
3128 * generic initialization of ADC, input mixers and output mixers
3129 */
3130static struct hda_verb alc880_volume_init_verbs[] = {
3131 /*
3132 * Unmute ADC0-2 and set the default input to mic-in
3133 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003134 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003136 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003138 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003140
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003141 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3142 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003143 * Note: PASD motherboards uses the Line In 2 as the input for front
3144 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003145 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003146 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3153 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003155 /*
3156 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003157 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003158 /* set vol=0 to output mixers */
3159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3160 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3161 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3163 /* set up input amps for analog loopback */
3164 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003165 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3166 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003169 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003171 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3172 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003173
3174 { }
3175};
3176
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177/*
3178 * 3-stack pin configuration:
3179 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3180 */
3181static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3182 /*
3183 * preset connection lists of input pins
3184 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3185 */
3186 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3187 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3188 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3189
3190 /*
3191 * Set pin mode and muting
3192 */
3193 /* set front pin widgets 0x14 for output */
3194 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3195 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3196 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3197 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3198 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3199 /* Mic2 (as headphone out) for HP output */
3200 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3201 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3202 /* Line In pin widget for input */
3203 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3204 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3205 /* Line2 (as front mic) pin widget for input and vref at 80% */
3206 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3207 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3208 /* CD pin widget for input */
3209 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3210
3211 { }
3212};
3213
3214/*
3215 * 5-stack pin configuration:
3216 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3217 * line-in/side = 0x1a, f-mic = 0x1b
3218 */
3219static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3220 /*
3221 * preset connection lists of input pins
3222 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3223 */
3224 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3225 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3226
3227 /*
3228 * Set pin mode and muting
3229 */
3230 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3232 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3233 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3234 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 /* unmute pins for output (no gain on this amp) */
3236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3238 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3239 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3240
Linus Torvalds1da177e2005-04-16 15:20:36 -07003241 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003242 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3244 /* Mic2 (as headphone out) for HP output */
3245 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003246 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247 /* Line In pin widget for input */
3248 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3249 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3250 /* Line2 (as front mic) pin widget for input and vref at 80% */
3251 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3252 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3253 /* CD pin widget for input */
3254 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003255
3256 { }
3257};
3258
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259/*
3260 * W810 pin configuration:
3261 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3262 */
3263static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003264 /* hphone/speaker input selector: front DAC */
3265 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3266
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3268 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3269 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3270 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3271 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3272 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3273
3274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003275 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003276
Linus Torvalds1da177e2005-04-16 15:20:36 -07003277 { }
3278};
3279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280/*
3281 * Z71V pin configuration:
3282 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3283 */
3284static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003285 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003289
Takashi Iwai16ded522005-06-10 19:58:24 +02003290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003291 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003292 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003294
3295 { }
3296};
3297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003298/*
3299 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003300 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3301 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003302 */
3303static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3304 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3305
Takashi Iwai16ded522005-06-10 19:58:24 +02003306 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003308 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003310 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003312 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3314
Takashi Iwai16ded522005-06-10 19:58:24 +02003315 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003316 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003317 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003321 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003322 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003323 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003324
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003325 { }
3326};
Takashi Iwai16ded522005-06-10 19:58:24 +02003327
Kailang Yangccc656c2006-10-17 12:32:26 +02003328/*
3329 * Uniwill pin configuration:
3330 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3331 * line = 0x1a
3332 */
3333static struct hda_verb alc880_uniwill_init_verbs[] = {
3334 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3335
3336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3337 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3340 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3341 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3342 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3343 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3350
3351 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3352 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3353 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3355 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3356 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3357 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3358 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3359 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3360
3361 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3362 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3363
3364 { }
3365};
3366
3367/*
3368* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003369* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003370 */
3371static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3372 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3373
3374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3375 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3377 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3378 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3379 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3382 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3384 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3386
3387 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3388 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3389 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3390 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3393
3394 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3395 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3396
3397 { }
3398};
3399
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003400static struct hda_verb alc880_beep_init_verbs[] = {
3401 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3402 { }
3403};
3404
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003405/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003406static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003407{
3408 unsigned int present;
3409 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003410
Wu Fengguang864f92b2009-11-18 12:38:02 +08003411 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003412 bits = present ? HDA_AMP_MUTE : 0;
3413 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003414}
3415
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003416static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003418 struct alc_spec *spec = codec->spec;
3419
3420 spec->autocfg.hp_pins[0] = 0x14;
3421 spec->autocfg.speaker_pins[0] = 0x15;
3422 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003423}
3424
3425static void alc880_uniwill_init_hook(struct hda_codec *codec)
3426{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003427 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003428 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003429}
3430
3431static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3432 unsigned int res)
3433{
3434 /* Looks like the unsol event is incompatible with the standard
3435 * definition. 4bit tag is placed at 28 bit!
3436 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003437 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003438 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003439 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003440 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003441 default:
3442 alc_automute_amp_unsol_event(codec, res);
3443 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003444 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003445}
3446
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003447static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003448{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003449 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003450
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003451 spec->autocfg.hp_pins[0] = 0x14;
3452 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003453}
3454
3455static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3456{
3457 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003458
Kailang Yangccc656c2006-10-17 12:32:26 +02003459 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003460 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3461 present &= HDA_AMP_VOLMASK;
3462 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3463 HDA_AMP_VOLMASK, present);
3464 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3465 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003466}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003467
Kailang Yangccc656c2006-10-17 12:32:26 +02003468static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3469 unsigned int res)
3470{
3471 /* Looks like the unsol event is incompatible with the standard
3472 * definition. 4bit tag is placed at 28 bit!
3473 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003474 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003475 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003476 else
3477 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003478}
3479
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003480/*
3481 * F1734 pin configuration:
3482 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3483 */
3484static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003485 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003486 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3487 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3488 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3489 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3490
3491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3492 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3495
3496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003498 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003499 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3501 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3503 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3504 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003505
Takashi Iwai937b4162008-02-11 14:52:36 +01003506 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3507 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3508
Takashi Iwai16ded522005-06-10 19:58:24 +02003509 { }
3510};
3511
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003512/*
3513 * ASUS pin configuration:
3514 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3515 */
3516static struct hda_verb alc880_pin_asus_init_verbs[] = {
3517 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3518 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3519 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3520 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3521
3522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3525 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3526 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3528 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3529 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3530
3531 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3532 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3533 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3534 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3535 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3536 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3537 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3539 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003540
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003541 { }
3542};
3543
3544/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003545#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3546#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003547#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003548
Kailang Yangdf694da2005-12-05 19:42:22 +01003549/* Clevo m520g init */
3550static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3551 /* headphone output */
3552 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3553 /* line-out */
3554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3555 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3556 /* Line-in */
3557 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3558 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3559 /* CD */
3560 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3561 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3562 /* Mic1 (rear panel) */
3563 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3564 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3565 /* Mic2 (front panel) */
3566 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3567 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3568 /* headphone */
3569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3571 /* change to EAPD mode */
3572 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3573 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3574
3575 { }
3576};
3577
3578static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003579 /* change to EAPD mode */
3580 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3581 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3582
Kailang Yangdf694da2005-12-05 19:42:22 +01003583 /* Headphone output */
3584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3585 /* Front output*/
3586 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3587 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3588
3589 /* Line In pin widget for input */
3590 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3591 /* CD pin widget for input */
3592 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3593 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3594 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3595
3596 /* change to EAPD mode */
3597 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3598 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3599
3600 { }
3601};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003602
3603/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003604 * LG m1 express dual
3605 *
3606 * Pin assignment:
3607 * Rear Line-In/Out (blue): 0x14
3608 * Build-in Mic-In: 0x15
3609 * Speaker-out: 0x17
3610 * HP-Out (green): 0x1b
3611 * Mic-In/Out (red): 0x19
3612 * SPDIF-Out: 0x1e
3613 */
3614
3615/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3616static hda_nid_t alc880_lg_dac_nids[3] = {
3617 0x05, 0x02, 0x03
3618};
3619
3620/* seems analog CD is not working */
3621static struct hda_input_mux alc880_lg_capture_source = {
3622 .num_items = 3,
3623 .items = {
3624 { "Mic", 0x1 },
3625 { "Line", 0x5 },
3626 { "Internal Mic", 0x6 },
3627 },
3628};
3629
3630/* 2,4,6 channel modes */
3631static struct hda_verb alc880_lg_ch2_init[] = {
3632 /* set line-in and mic-in to input */
3633 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3634 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3635 { }
3636};
3637
3638static struct hda_verb alc880_lg_ch4_init[] = {
3639 /* set line-in to out and mic-in to input */
3640 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3641 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3642 { }
3643};
3644
3645static struct hda_verb alc880_lg_ch6_init[] = {
3646 /* set line-in and mic-in to output */
3647 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3648 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3649 { }
3650};
3651
3652static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3653 { 2, alc880_lg_ch2_init },
3654 { 4, alc880_lg_ch4_init },
3655 { 6, alc880_lg_ch6_init },
3656};
3657
3658static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003659 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3660 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003661 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3662 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3663 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3664 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3665 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3666 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3671 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3672 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3673 {
3674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3675 .name = "Channel Mode",
3676 .info = alc_ch_mode_info,
3677 .get = alc_ch_mode_get,
3678 .put = alc_ch_mode_put,
3679 },
3680 { } /* end */
3681};
3682
3683static struct hda_verb alc880_lg_init_verbs[] = {
3684 /* set capture source to mic-in */
3685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3686 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3687 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3688 /* mute all amp mixer inputs */
3689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003692 /* line-in to input */
3693 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3694 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3695 /* built-in mic */
3696 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3697 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3698 /* speaker-out */
3699 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3701 /* mic-in to input */
3702 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3703 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3704 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3705 /* HP-out */
3706 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3707 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3708 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3709 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003710 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003711 { }
3712};
3713
3714/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003715static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003716{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003717 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003718
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003719 spec->autocfg.hp_pins[0] = 0x1b;
3720 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003721}
3722
3723/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003724 * LG LW20
3725 *
3726 * Pin assignment:
3727 * Speaker-out: 0x14
3728 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003729 * Built-in Mic-In: 0x19
3730 * Line-In: 0x1b
3731 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003732 * SPDIF-Out: 0x1e
3733 */
3734
Takashi Iwaid6815182006-03-23 16:06:23 +01003735static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003736 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003737 .items = {
3738 { "Mic", 0x0 },
3739 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003740 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003741 },
3742};
3743
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003744#define alc880_lg_lw_modes alc880_threestack_modes
3745
Takashi Iwaid6815182006-03-23 16:06:23 +01003746static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003747 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3748 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3749 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3750 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3751 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3752 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3753 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3754 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3755 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3756 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003757 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3758 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3759 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3760 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003761 {
3762 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3763 .name = "Channel Mode",
3764 .info = alc_ch_mode_info,
3765 .get = alc_ch_mode_get,
3766 .put = alc_ch_mode_put,
3767 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003768 { } /* end */
3769};
3770
3771static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003772 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3773 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3774 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3775
Takashi Iwaid6815182006-03-23 16:06:23 +01003776 /* set capture source to mic-in */
3777 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3778 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3779 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003780 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003781 /* speaker-out */
3782 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3783 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3784 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003785 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3786 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3787 /* mic-in to input */
3788 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3789 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3790 /* built-in mic */
3791 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3792 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3793 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003794 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003795 { }
3796};
3797
3798/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003799static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003800{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003801 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003802
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003803 spec->autocfg.hp_pins[0] = 0x1b;
3804 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003805}
3806
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003807static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3808 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3809 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3811 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3812 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3813 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3814 { } /* end */
3815};
3816
3817static struct hda_input_mux alc880_medion_rim_capture_source = {
3818 .num_items = 2,
3819 .items = {
3820 { "Mic", 0x0 },
3821 { "Internal Mic", 0x1 },
3822 },
3823};
3824
3825static struct hda_verb alc880_medion_rim_init_verbs[] = {
3826 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3827
3828 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3829 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3830
3831 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3832 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3833 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3834 /* Mic2 (as headphone out) for HP output */
3835 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3836 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3837 /* Internal Speaker */
3838 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3839 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3840
3841 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3842 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3843
3844 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3845 { }
3846};
3847
3848/* toggle speaker-output according to the hp-jack state */
3849static void alc880_medion_rim_automute(struct hda_codec *codec)
3850{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003851 struct alc_spec *spec = codec->spec;
3852 alc_automute_amp(codec);
3853 /* toggle EAPD */
3854 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003855 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3856 else
3857 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3858}
3859
3860static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3861 unsigned int res)
3862{
3863 /* Looks like the unsol event is incompatible with the standard
3864 * definition. 4bit tag is placed at 28 bit!
3865 */
3866 if ((res >> 28) == ALC880_HP_EVENT)
3867 alc880_medion_rim_automute(codec);
3868}
3869
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003870static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003871{
3872 struct alc_spec *spec = codec->spec;
3873
3874 spec->autocfg.hp_pins[0] = 0x14;
3875 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003876}
3877
Takashi Iwaicb53c622007-08-10 17:21:45 +02003878#ifdef CONFIG_SND_HDA_POWER_SAVE
3879static struct hda_amp_list alc880_loopbacks[] = {
3880 { 0x0b, HDA_INPUT, 0 },
3881 { 0x0b, HDA_INPUT, 1 },
3882 { 0x0b, HDA_INPUT, 2 },
3883 { 0x0b, HDA_INPUT, 3 },
3884 { 0x0b, HDA_INPUT, 4 },
3885 { } /* end */
3886};
3887
3888static struct hda_amp_list alc880_lg_loopbacks[] = {
3889 { 0x0b, HDA_INPUT, 1 },
3890 { 0x0b, HDA_INPUT, 6 },
3891 { 0x0b, HDA_INPUT, 7 },
3892 { } /* end */
3893};
3894#endif
3895
Takashi Iwaid6815182006-03-23 16:06:23 +01003896/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003897 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003898 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003899
Linus Torvalds1da177e2005-04-16 15:20:36 -07003900static int alc_init(struct hda_codec *codec)
3901{
3902 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003903 unsigned int i;
3904
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003905 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003906 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003907
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003908 for (i = 0; i < spec->num_init_verbs; i++)
3909 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003910
3911 if (spec->init_hook)
3912 spec->init_hook(codec);
3913
Takashi Iwai58701122011-01-13 15:41:45 +01003914 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
3915
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003916 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003917 return 0;
3918}
3919
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003920static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3921{
3922 struct alc_spec *spec = codec->spec;
3923
3924 if (spec->unsol_event)
3925 spec->unsol_event(codec, res);
3926}
3927
Takashi Iwaicb53c622007-08-10 17:21:45 +02003928#ifdef CONFIG_SND_HDA_POWER_SAVE
3929static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3930{
3931 struct alc_spec *spec = codec->spec;
3932 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3933}
3934#endif
3935
Linus Torvalds1da177e2005-04-16 15:20:36 -07003936/*
3937 * Analog playback callbacks
3938 */
3939static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3940 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003941 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003942{
3943 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003944 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3945 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003946}
3947
3948static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3949 struct hda_codec *codec,
3950 unsigned int stream_tag,
3951 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003952 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003953{
3954 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003955 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3956 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003957}
3958
3959static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3960 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003961 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003962{
3963 struct alc_spec *spec = codec->spec;
3964 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3965}
3966
3967/*
3968 * Digital out
3969 */
3970static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3971 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003972 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003973{
3974 struct alc_spec *spec = codec->spec;
3975 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3976}
3977
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003978static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3979 struct hda_codec *codec,
3980 unsigned int stream_tag,
3981 unsigned int format,
3982 struct snd_pcm_substream *substream)
3983{
3984 struct alc_spec *spec = codec->spec;
3985 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3986 stream_tag, format, substream);
3987}
3988
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003989static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3990 struct hda_codec *codec,
3991 struct snd_pcm_substream *substream)
3992{
3993 struct alc_spec *spec = codec->spec;
3994 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3995}
3996
Linus Torvalds1da177e2005-04-16 15:20:36 -07003997static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3998 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003999 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004000{
4001 struct alc_spec *spec = codec->spec;
4002 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
4003}
4004
4005/*
4006 * Analog capture
4007 */
Takashi Iwai63300792008-01-24 15:31:36 +01004008static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004009 struct hda_codec *codec,
4010 unsigned int stream_tag,
4011 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004012 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004013{
4014 struct alc_spec *spec = codec->spec;
4015
Takashi Iwai63300792008-01-24 15:31:36 +01004016 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07004017 stream_tag, 0, format);
4018 return 0;
4019}
4020
Takashi Iwai63300792008-01-24 15:31:36 +01004021static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004022 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004023 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004024{
4025 struct alc_spec *spec = codec->spec;
4026
Takashi Iwai888afa12008-03-18 09:57:50 +01004027 snd_hda_codec_cleanup_stream(codec,
4028 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004029 return 0;
4030}
4031
Takashi Iwai840b64c2010-07-13 22:49:01 +02004032/* analog capture with dynamic dual-adc changes */
4033static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
4034 struct hda_codec *codec,
4035 unsigned int stream_tag,
4036 unsigned int format,
4037 struct snd_pcm_substream *substream)
4038{
4039 struct alc_spec *spec = codec->spec;
4040 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
4041 spec->cur_adc_stream_tag = stream_tag;
4042 spec->cur_adc_format = format;
4043 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
4044 return 0;
4045}
4046
4047static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
4048 struct hda_codec *codec,
4049 struct snd_pcm_substream *substream)
4050{
4051 struct alc_spec *spec = codec->spec;
4052 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4053 spec->cur_adc = 0;
4054 return 0;
4055}
4056
4057static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4058 .substreams = 1,
4059 .channels_min = 2,
4060 .channels_max = 2,
4061 .nid = 0, /* fill later */
4062 .ops = {
4063 .prepare = dualmic_capture_pcm_prepare,
4064 .cleanup = dualmic_capture_pcm_cleanup
4065 },
4066};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004067
4068/*
4069 */
4070static struct hda_pcm_stream alc880_pcm_analog_playback = {
4071 .substreams = 1,
4072 .channels_min = 2,
4073 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004074 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004075 .ops = {
4076 .open = alc880_playback_pcm_open,
4077 .prepare = alc880_playback_pcm_prepare,
4078 .cleanup = alc880_playback_pcm_cleanup
4079 },
4080};
4081
4082static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004083 .substreams = 1,
4084 .channels_min = 2,
4085 .channels_max = 2,
4086 /* NID is set in alc_build_pcms */
4087};
4088
4089static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4090 .substreams = 1,
4091 .channels_min = 2,
4092 .channels_max = 2,
4093 /* NID is set in alc_build_pcms */
4094};
4095
4096static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4097 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004098 .channels_min = 2,
4099 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004100 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004101 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004102 .prepare = alc880_alt_capture_pcm_prepare,
4103 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004104 },
4105};
4106
4107static struct hda_pcm_stream alc880_pcm_digital_playback = {
4108 .substreams = 1,
4109 .channels_min = 2,
4110 .channels_max = 2,
4111 /* NID is set in alc_build_pcms */
4112 .ops = {
4113 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004114 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004115 .prepare = alc880_dig_playback_pcm_prepare,
4116 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004117 },
4118};
4119
4120static struct hda_pcm_stream alc880_pcm_digital_capture = {
4121 .substreams = 1,
4122 .channels_min = 2,
4123 .channels_max = 2,
4124 /* NID is set in alc_build_pcms */
4125};
4126
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004127/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004128static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004129 .substreams = 0,
4130 .channels_min = 0,
4131 .channels_max = 0,
4132};
4133
Linus Torvalds1da177e2005-04-16 15:20:36 -07004134static int alc_build_pcms(struct hda_codec *codec)
4135{
4136 struct alc_spec *spec = codec->spec;
4137 struct hda_pcm *info = spec->pcm_rec;
4138 int i;
4139
4140 codec->num_pcms = 1;
4141 codec->pcm_info = info;
4142
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004143 if (spec->no_analog)
4144 goto skip_analog;
4145
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004146 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4147 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004148 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004149
Takashi Iwai4a471b72005-12-07 13:56:29 +01004150 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004151 if (snd_BUG_ON(!spec->multiout.dac_nids))
4152 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004153 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4154 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4155 }
4156 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004157 if (snd_BUG_ON(!spec->adc_nids))
4158 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004159 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4160 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4161 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004162
Takashi Iwai4a471b72005-12-07 13:56:29 +01004163 if (spec->channel_mode) {
4164 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4165 for (i = 0; i < spec->num_channel_mode; i++) {
4166 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4167 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4168 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004169 }
4170 }
4171
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004172 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004173 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004174 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004175 snprintf(spec->stream_name_digital,
4176 sizeof(spec->stream_name_digital),
4177 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004178 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004179 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004180 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004181 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004182 if (spec->dig_out_type)
4183 info->pcm_type = spec->dig_out_type;
4184 else
4185 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004186 if (spec->multiout.dig_out_nid &&
4187 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004188 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4189 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4190 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004191 if (spec->dig_in_nid &&
4192 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004193 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4194 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4195 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004196 /* FIXME: do we need this for all Realtek codec models? */
4197 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004198 }
4199
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004200 if (spec->no_analog)
4201 return 0;
4202
Takashi Iwaie08a0072006-09-07 17:52:14 +02004203 /* If the use of more than one ADC is requested for the current
4204 * model, configure a second analog capture-only PCM.
4205 */
4206 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004207 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4208 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004209 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004210 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004211 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004212 if (spec->alt_dac_nid) {
4213 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4214 *spec->stream_analog_alt_playback;
4215 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4216 spec->alt_dac_nid;
4217 } else {
4218 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4219 alc_pcm_null_stream;
4220 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4221 }
4222 if (spec->num_adc_nids > 1) {
4223 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4224 *spec->stream_analog_alt_capture;
4225 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4226 spec->adc_nids[1];
4227 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4228 spec->num_adc_nids - 1;
4229 } else {
4230 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4231 alc_pcm_null_stream;
4232 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004233 }
4234 }
4235
Linus Torvalds1da177e2005-04-16 15:20:36 -07004236 return 0;
4237}
4238
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004239static inline void alc_shutup(struct hda_codec *codec)
4240{
4241 snd_hda_shutup_pins(codec);
4242}
4243
Takashi Iwai603c4012008-07-30 15:01:44 +02004244static void alc_free_kctls(struct hda_codec *codec)
4245{
4246 struct alc_spec *spec = codec->spec;
4247
4248 if (spec->kctls.list) {
4249 struct snd_kcontrol_new *kctl = spec->kctls.list;
4250 int i;
4251 for (i = 0; i < spec->kctls.used; i++)
4252 kfree(kctl[i].name);
4253 }
4254 snd_array_free(&spec->kctls);
4255}
4256
Linus Torvalds1da177e2005-04-16 15:20:36 -07004257static void alc_free(struct hda_codec *codec)
4258{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004261 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262 return;
4263
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004264 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004265 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004266 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004267 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004268}
4269
Hector Martinf5de24b2009-12-20 22:51:31 +01004270#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004271static void alc_power_eapd(struct hda_codec *codec)
4272{
4273 /* We currently only handle front, HP */
4274 switch (codec->vendor_id) {
4275 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004276 set_eapd(codec, 0x0f, 0);
4277 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004278 break;
4279 case 0x10ec0262:
4280 case 0x10ec0267:
4281 case 0x10ec0268:
4282 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004283 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004284 case 0x10ec0272:
4285 case 0x10ec0660:
4286 case 0x10ec0662:
4287 case 0x10ec0663:
4288 case 0x10ec0862:
4289 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004290 set_eapd(codec, 0x14, 0);
4291 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004292 break;
4293 }
4294}
4295
Hector Martinf5de24b2009-12-20 22:51:31 +01004296static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4297{
4298 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004299 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004300 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004301 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004302 return 0;
4303}
4304#endif
4305
Takashi Iwaie044c392008-10-27 16:56:24 +01004306#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004307static int alc_resume(struct hda_codec *codec)
4308{
Takashi Iwaie044c392008-10-27 16:56:24 +01004309 codec->patch_ops.init(codec);
4310 snd_hda_codec_resume_amp(codec);
4311 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004312 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004313 return 0;
4314}
Takashi Iwaie044c392008-10-27 16:56:24 +01004315#endif
4316
Linus Torvalds1da177e2005-04-16 15:20:36 -07004317/*
4318 */
4319static struct hda_codec_ops alc_patch_ops = {
4320 .build_controls = alc_build_controls,
4321 .build_pcms = alc_build_pcms,
4322 .init = alc_init,
4323 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004324 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004325#ifdef SND_HDA_NEEDS_RESUME
4326 .resume = alc_resume,
4327#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004328#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004329 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004330 .check_power_status = alc_check_power_status,
4331#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004332 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004333};
4334
Kailang Yangc027ddc2010-03-19 11:33:06 +01004335/* replace the codec chip_name with the given string */
4336static int alc_codec_rename(struct hda_codec *codec, const char *name)
4337{
4338 kfree(codec->chip_name);
4339 codec->chip_name = kstrdup(name, GFP_KERNEL);
4340 if (!codec->chip_name) {
4341 alc_free(codec);
4342 return -ENOMEM;
4343 }
4344 return 0;
4345}
4346
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004347/*
4348 * Test configuration for debugging
4349 *
4350 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4351 * enum controls.
4352 */
4353#ifdef CONFIG_SND_DEBUG
4354static hda_nid_t alc880_test_dac_nids[4] = {
4355 0x02, 0x03, 0x04, 0x05
4356};
4357
4358static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004359 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004360 .items = {
4361 { "In-1", 0x0 },
4362 { "In-2", 0x1 },
4363 { "In-3", 0x2 },
4364 { "In-4", 0x3 },
4365 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004366 { "Front", 0x5 },
4367 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004368 },
4369};
4370
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004371static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004372 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004373 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004374 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004375 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004376};
4377
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004378static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4379 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004380{
4381 static char *texts[] = {
4382 "N/A", "Line Out", "HP Out",
4383 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4384 };
4385 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4386 uinfo->count = 1;
4387 uinfo->value.enumerated.items = 8;
4388 if (uinfo->value.enumerated.item >= 8)
4389 uinfo->value.enumerated.item = 7;
4390 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4391 return 0;
4392}
4393
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004394static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4395 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004396{
4397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4398 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4399 unsigned int pin_ctl, item = 0;
4400
4401 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4402 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4403 if (pin_ctl & AC_PINCTL_OUT_EN) {
4404 if (pin_ctl & AC_PINCTL_HP_EN)
4405 item = 2;
4406 else
4407 item = 1;
4408 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4409 switch (pin_ctl & AC_PINCTL_VREFEN) {
4410 case AC_PINCTL_VREF_HIZ: item = 3; break;
4411 case AC_PINCTL_VREF_50: item = 4; break;
4412 case AC_PINCTL_VREF_GRD: item = 5; break;
4413 case AC_PINCTL_VREF_80: item = 6; break;
4414 case AC_PINCTL_VREF_100: item = 7; break;
4415 }
4416 }
4417 ucontrol->value.enumerated.item[0] = item;
4418 return 0;
4419}
4420
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004421static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4422 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004423{
4424 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4425 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4426 static unsigned int ctls[] = {
4427 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4428 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4429 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4430 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4431 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4432 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4433 };
4434 unsigned int old_ctl, new_ctl;
4435
4436 old_ctl = snd_hda_codec_read(codec, nid, 0,
4437 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4438 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4439 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004440 int val;
4441 snd_hda_codec_write_cache(codec, nid, 0,
4442 AC_VERB_SET_PIN_WIDGET_CONTROL,
4443 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004444 val = ucontrol->value.enumerated.item[0] >= 3 ?
4445 HDA_AMP_MUTE : 0;
4446 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4447 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004448 return 1;
4449 }
4450 return 0;
4451}
4452
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004453static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4454 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004455{
4456 static char *texts[] = {
4457 "Front", "Surround", "CLFE", "Side"
4458 };
4459 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4460 uinfo->count = 1;
4461 uinfo->value.enumerated.items = 4;
4462 if (uinfo->value.enumerated.item >= 4)
4463 uinfo->value.enumerated.item = 3;
4464 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4465 return 0;
4466}
4467
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004468static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4469 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004470{
4471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4472 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4473 unsigned int sel;
4474
4475 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4476 ucontrol->value.enumerated.item[0] = sel & 3;
4477 return 0;
4478}
4479
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004480static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4481 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004482{
4483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4484 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4485 unsigned int sel;
4486
4487 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4488 if (ucontrol->value.enumerated.item[0] != sel) {
4489 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004490 snd_hda_codec_write_cache(codec, nid, 0,
4491 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004492 return 1;
4493 }
4494 return 0;
4495}
4496
4497#define PIN_CTL_TEST(xname,nid) { \
4498 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4499 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004500 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004501 .info = alc_test_pin_ctl_info, \
4502 .get = alc_test_pin_ctl_get, \
4503 .put = alc_test_pin_ctl_put, \
4504 .private_value = nid \
4505 }
4506
4507#define PIN_SRC_TEST(xname,nid) { \
4508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4509 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004510 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004511 .info = alc_test_pin_src_info, \
4512 .get = alc_test_pin_src_get, \
4513 .put = alc_test_pin_src_put, \
4514 .private_value = nid \
4515 }
4516
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004517static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004518 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4519 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4520 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4521 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004522 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4523 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4524 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4525 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004526 PIN_CTL_TEST("Front Pin Mode", 0x14),
4527 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4528 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4529 PIN_CTL_TEST("Side Pin Mode", 0x17),
4530 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4531 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4532 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4533 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4534 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4535 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4536 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4537 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4538 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4539 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4540 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4541 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4542 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4543 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4544 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4545 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4546 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4547 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004548 {
4549 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4550 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004551 .info = alc_ch_mode_info,
4552 .get = alc_ch_mode_get,
4553 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004554 },
4555 { } /* end */
4556};
4557
4558static struct hda_verb alc880_test_init_verbs[] = {
4559 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4562 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4564 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4566 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4567 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004568 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004569 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4570 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4571 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4572 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004573 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004574 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4576 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4577 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004578 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004579 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4580 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4581 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004583 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004584 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4585 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004586 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4587 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4588 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004589 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004590 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4591 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4592 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4593 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004594 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004596 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004597 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004598 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004599 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004600 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004601 /* Analog input/passthru */
4602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4605 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4606 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004607 { }
4608};
4609#endif
4610
Linus Torvalds1da177e2005-04-16 15:20:36 -07004611/*
4612 */
4613
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004614static const char *alc880_models[ALC880_MODEL_LAST] = {
4615 [ALC880_3ST] = "3stack",
4616 [ALC880_TCL_S700] = "tcl",
4617 [ALC880_3ST_DIG] = "3stack-digout",
4618 [ALC880_CLEVO] = "clevo",
4619 [ALC880_5ST] = "5stack",
4620 [ALC880_5ST_DIG] = "5stack-digout",
4621 [ALC880_W810] = "w810",
4622 [ALC880_Z71V] = "z71v",
4623 [ALC880_6ST] = "6stack",
4624 [ALC880_6ST_DIG] = "6stack-digout",
4625 [ALC880_ASUS] = "asus",
4626 [ALC880_ASUS_W1V] = "asus-w1v",
4627 [ALC880_ASUS_DIG] = "asus-dig",
4628 [ALC880_ASUS_DIG2] = "asus-dig2",
4629 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004630 [ALC880_UNIWILL_P53] = "uniwill-p53",
4631 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004632 [ALC880_F1734] = "F1734",
4633 [ALC880_LG] = "lg",
4634 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004635 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004636#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004637 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004638#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004639 [ALC880_AUTO] = "auto",
4640};
4641
4642static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004643 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004644 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4645 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4646 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4647 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4648 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4649 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4650 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4651 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004652 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4653 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004654 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4655 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4656 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4657 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4658 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4659 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4660 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4661 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4662 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4663 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004664 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004665 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4666 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4667 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004668 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004669 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004670 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4671 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004672 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4673 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004674 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4675 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4676 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4677 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004678 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4679 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004680 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004681 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004682 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004683 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004684 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4685 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004686 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004687 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004688 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004689 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004690 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004691 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004692 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004693 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004694 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004695 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004696 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004697 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004698 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004699 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4700 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4701 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4702 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004703 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4704 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004705 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004706 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004707 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4708 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004709 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4710 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4711 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004712 /* default Intel */
4713 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004714 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4715 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004716 {}
4717};
4718
Takashi Iwai16ded522005-06-10 19:58:24 +02004719/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004720 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004721 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004722static struct alc_config_preset alc880_presets[] = {
4723 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004724 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004725 .init_verbs = { alc880_volume_init_verbs,
4726 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004727 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004728 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004729 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4730 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004731 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004732 .input_mux = &alc880_capture_source,
4733 },
4734 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004735 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004736 .init_verbs = { alc880_volume_init_verbs,
4737 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004738 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004739 .dac_nids = alc880_dac_nids,
4740 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004741 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4742 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004743 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004744 .input_mux = &alc880_capture_source,
4745 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004746 [ALC880_TCL_S700] = {
4747 .mixers = { alc880_tcl_s700_mixer },
4748 .init_verbs = { alc880_volume_init_verbs,
4749 alc880_pin_tcl_S700_init_verbs,
4750 alc880_gpio2_init_verbs },
4751 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4752 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004753 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4754 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004755 .hp_nid = 0x03,
4756 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4757 .channel_mode = alc880_2_jack_modes,
4758 .input_mux = &alc880_capture_source,
4759 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004760 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004761 .mixers = { alc880_three_stack_mixer,
4762 alc880_five_stack_mixer},
4763 .init_verbs = { alc880_volume_init_verbs,
4764 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004765 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4766 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004767 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4768 .channel_mode = alc880_fivestack_modes,
4769 .input_mux = &alc880_capture_source,
4770 },
4771 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004772 .mixers = { alc880_three_stack_mixer,
4773 alc880_five_stack_mixer },
4774 .init_verbs = { alc880_volume_init_verbs,
4775 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004776 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4777 .dac_nids = alc880_dac_nids,
4778 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004779 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4780 .channel_mode = alc880_fivestack_modes,
4781 .input_mux = &alc880_capture_source,
4782 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004783 [ALC880_6ST] = {
4784 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004785 .init_verbs = { alc880_volume_init_verbs,
4786 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004787 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4788 .dac_nids = alc880_6st_dac_nids,
4789 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4790 .channel_mode = alc880_sixstack_modes,
4791 .input_mux = &alc880_6stack_capture_source,
4792 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004793 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004794 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004795 .init_verbs = { alc880_volume_init_verbs,
4796 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004797 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4798 .dac_nids = alc880_6st_dac_nids,
4799 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004800 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4801 .channel_mode = alc880_sixstack_modes,
4802 .input_mux = &alc880_6stack_capture_source,
4803 },
4804 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004805 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004806 .init_verbs = { alc880_volume_init_verbs,
4807 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004808 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004809 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4810 .dac_nids = alc880_w810_dac_nids,
4811 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004812 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4813 .channel_mode = alc880_w810_modes,
4814 .input_mux = &alc880_capture_source,
4815 },
4816 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004817 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004818 .init_verbs = { alc880_volume_init_verbs,
4819 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004820 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4821 .dac_nids = alc880_z71v_dac_nids,
4822 .dig_out_nid = ALC880_DIGOUT_NID,
4823 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004824 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4825 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004826 .input_mux = &alc880_capture_source,
4827 },
4828 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004829 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004830 .init_verbs = { alc880_volume_init_verbs,
4831 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004832 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4833 .dac_nids = alc880_f1734_dac_nids,
4834 .hp_nid = 0x02,
4835 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4836 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004837 .input_mux = &alc880_f1734_capture_source,
4838 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004839 .setup = alc880_uniwill_p53_setup,
4840 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004841 },
4842 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004843 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004844 .init_verbs = { alc880_volume_init_verbs,
4845 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004846 alc880_gpio1_init_verbs },
4847 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4848 .dac_nids = alc880_asus_dac_nids,
4849 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4850 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004851 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004852 .input_mux = &alc880_capture_source,
4853 },
4854 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004855 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004856 .init_verbs = { alc880_volume_init_verbs,
4857 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004858 alc880_gpio1_init_verbs },
4859 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4860 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004861 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004862 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4863 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004864 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004865 .input_mux = &alc880_capture_source,
4866 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004867 [ALC880_ASUS_DIG2] = {
4868 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004869 .init_verbs = { alc880_volume_init_verbs,
4870 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004871 alc880_gpio2_init_verbs }, /* use GPIO2 */
4872 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4873 .dac_nids = alc880_asus_dac_nids,
4874 .dig_out_nid = ALC880_DIGOUT_NID,
4875 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4876 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004877 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004878 .input_mux = &alc880_capture_source,
4879 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004880 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004881 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004882 .init_verbs = { alc880_volume_init_verbs,
4883 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004884 alc880_gpio1_init_verbs },
4885 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4886 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004887 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004888 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4889 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004890 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004891 .input_mux = &alc880_capture_source,
4892 },
4893 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004894 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004895 .init_verbs = { alc880_volume_init_verbs,
4896 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004897 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4898 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004899 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004900 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4901 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004902 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004903 .input_mux = &alc880_capture_source,
4904 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004905 [ALC880_UNIWILL] = {
4906 .mixers = { alc880_uniwill_mixer },
4907 .init_verbs = { alc880_volume_init_verbs,
4908 alc880_uniwill_init_verbs },
4909 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4910 .dac_nids = alc880_asus_dac_nids,
4911 .dig_out_nid = ALC880_DIGOUT_NID,
4912 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4913 .channel_mode = alc880_threestack_modes,
4914 .need_dac_fix = 1,
4915 .input_mux = &alc880_capture_source,
4916 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004917 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004918 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004919 },
4920 [ALC880_UNIWILL_P53] = {
4921 .mixers = { alc880_uniwill_p53_mixer },
4922 .init_verbs = { alc880_volume_init_verbs,
4923 alc880_uniwill_p53_init_verbs },
4924 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4925 .dac_nids = alc880_asus_dac_nids,
4926 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004927 .channel_mode = alc880_threestack_modes,
4928 .input_mux = &alc880_capture_source,
4929 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004930 .setup = alc880_uniwill_p53_setup,
4931 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004932 },
4933 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004934 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004935 .init_verbs = { alc880_volume_init_verbs,
4936 alc880_uniwill_p53_init_verbs,
4937 alc880_beep_init_verbs },
4938 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4939 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004940 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004941 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4942 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004943 .input_mux = &alc880_capture_source,
4944 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004945 .setup = alc880_uniwill_p53_setup,
4946 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004947 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004948 [ALC880_CLEVO] = {
4949 .mixers = { alc880_three_stack_mixer },
4950 .init_verbs = { alc880_volume_init_verbs,
4951 alc880_pin_clevo_init_verbs },
4952 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4953 .dac_nids = alc880_dac_nids,
4954 .hp_nid = 0x03,
4955 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4956 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004957 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004958 .input_mux = &alc880_capture_source,
4959 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004960 [ALC880_LG] = {
4961 .mixers = { alc880_lg_mixer },
4962 .init_verbs = { alc880_volume_init_verbs,
4963 alc880_lg_init_verbs },
4964 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4965 .dac_nids = alc880_lg_dac_nids,
4966 .dig_out_nid = ALC880_DIGOUT_NID,
4967 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4968 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004969 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004970 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004971 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004972 .setup = alc880_lg_setup,
4973 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004974#ifdef CONFIG_SND_HDA_POWER_SAVE
4975 .loopbacks = alc880_lg_loopbacks,
4976#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004977 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004978 [ALC880_LG_LW] = {
4979 .mixers = { alc880_lg_lw_mixer },
4980 .init_verbs = { alc880_volume_init_verbs,
4981 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004982 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004983 .dac_nids = alc880_dac_nids,
4984 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004985 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4986 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004987 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004988 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004989 .setup = alc880_lg_lw_setup,
4990 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004991 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004992 [ALC880_MEDION_RIM] = {
4993 .mixers = { alc880_medion_rim_mixer },
4994 .init_verbs = { alc880_volume_init_verbs,
4995 alc880_medion_rim_init_verbs,
4996 alc_gpio2_init_verbs },
4997 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4998 .dac_nids = alc880_dac_nids,
4999 .dig_out_nid = ALC880_DIGOUT_NID,
5000 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5001 .channel_mode = alc880_2_jack_modes,
5002 .input_mux = &alc880_medion_rim_capture_source,
5003 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005004 .setup = alc880_medion_rim_setup,
5005 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005006 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005007#ifdef CONFIG_SND_DEBUG
5008 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005009 .mixers = { alc880_test_mixer },
5010 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005011 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
5012 .dac_nids = alc880_test_dac_nids,
5013 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005014 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
5015 .channel_mode = alc880_test_modes,
5016 .input_mux = &alc880_test_capture_source,
5017 },
5018#endif
5019};
5020
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005021/*
5022 * Automatic parse of I/O pins from the BIOS configuration
5023 */
5024
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005025enum {
5026 ALC_CTL_WIDGET_VOL,
5027 ALC_CTL_WIDGET_MUTE,
5028 ALC_CTL_BIND_MUTE,
5029};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005030static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005031 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
5032 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01005033 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005034};
5035
5036/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005038 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005039{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005040 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005041
Takashi Iwai603c4012008-07-30 15:01:44 +02005042 snd_array_init(&spec->kctls, sizeof(*knew), 32);
5043 knew = snd_array_new(&spec->kctls);
5044 if (!knew)
5045 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005046 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07005047 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005048 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005049 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005050 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005051 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005052 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005054 return 0;
5055}
5056
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005057static int add_control_with_pfx(struct alc_spec *spec, int type,
5058 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005059 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005060{
5061 char name[32];
5062 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005063 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005064}
5065
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005066#define add_pb_vol_ctrl(spec, type, pfx, val) \
5067 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5068#define add_pb_sw_ctrl(spec, type, pfx, val) \
5069 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5070#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5071 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5072#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5073 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005074
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005075#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5076#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5077#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5078#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005079#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5080#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5081#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5082#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5083#define ALC880_PIN_CD_NID 0x1c
5084
5085/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005086static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5087 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005088{
5089 hda_nid_t nid;
5090 int assigned[4];
5091 int i, j;
5092
5093 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005094 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005095
5096 /* check the pins hardwired to audio widget */
5097 for (i = 0; i < cfg->line_outs; i++) {
5098 nid = cfg->line_out_pins[i];
5099 if (alc880_is_fixed_pin(nid)) {
5100 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005101 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005102 assigned[idx] = 1;
5103 }
5104 }
5105 /* left pins can be connect to any audio widget */
5106 for (i = 0; i < cfg->line_outs; i++) {
5107 nid = cfg->line_out_pins[i];
5108 if (alc880_is_fixed_pin(nid))
5109 continue;
5110 /* search for an empty channel */
5111 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005112 if (!assigned[j]) {
5113 spec->multiout.dac_nids[i] =
5114 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005115 assigned[j] = 1;
5116 break;
5117 }
5118 }
5119 }
5120 spec->multiout.num_dacs = cfg->line_outs;
5121 return 0;
5122}
5123
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005124static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg,
5125 bool can_be_master)
5126{
5127 if (!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
5128 return "Master";
5129
5130 switch (cfg->line_out_type) {
5131 case AUTO_PIN_SPEAKER_OUT:
5132 return "Speaker";
5133 case AUTO_PIN_HP_OUT:
5134 return "Headphone";
5135 default:
5136 if (cfg->line_outs == 1)
5137 return "PCM";
5138 break;
5139 }
5140 return NULL;
5141}
5142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005143/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005144static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5145 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005146{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005147 static const char *chname[4] = {
5148 "Front", "Surround", NULL /*CLFE*/, "Side"
5149 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005150 const char *pfx = alc_get_line_out_pfx(cfg, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005151 hda_nid_t nid;
5152 int i, err;
5153
5154 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005155 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005156 continue;
5157 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005158 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005159 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005160 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5161 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005162 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5163 HDA_OUTPUT));
5164 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005165 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005166 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5167 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005168 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5169 HDA_OUTPUT));
5170 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005171 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005172 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5173 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005174 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5175 HDA_INPUT));
5176 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005177 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005178 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5179 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005180 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5181 HDA_INPUT));
5182 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005183 return err;
5184 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005185 const char *name = pfx;
5186 if (!name)
5187 name = chname[i];
5188 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5189 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005190 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5191 HDA_OUTPUT));
5192 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005193 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005194 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5195 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005196 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5197 HDA_INPUT));
5198 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005199 return err;
5200 }
5201 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005202 return 0;
5203}
5204
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005205/* add playback controls for speaker and HP outputs */
5206static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5207 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005208{
5209 hda_nid_t nid;
5210 int err;
5211
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005212 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005213 return 0;
5214
5215 if (alc880_is_fixed_pin(pin)) {
5216 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005217 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005218 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005219 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005220 else
5221 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005222 /* control HP volume/switch on the output mixer amp */
5223 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005224 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005225 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5226 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005227 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005228 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005229 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5230 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005231 return err;
5232 } else if (alc880_is_multi_pin(pin)) {
5233 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005234 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005235 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005236 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5237 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005238 return err;
5239 }
5240 return 0;
5241}
5242
5243/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005244static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005245 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005246 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005247{
Kailang Yangdf694da2005-12-05 19:42:22 +01005248 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005249
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005250 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005251 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5252 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005253 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005254 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005255 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5256 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005257 return err;
5258 return 0;
5259}
5260
Takashi Iwai05f5f472009-08-25 13:10:18 +02005261static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005262{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005263 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5264 return (pincap & AC_PINCAP_IN) != 0;
5265}
5266
5267/* create playback/capture controls for input pins */
5268static int alc_auto_create_input_ctls(struct hda_codec *codec,
5269 const struct auto_pin_cfg *cfg,
5270 hda_nid_t mixer,
5271 hda_nid_t cap1, hda_nid_t cap2)
5272{
5273 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005274 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005275 int i, err, idx, type_idx = 0;
5276 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005277
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005278 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005279 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005280 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005281
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005282 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005283 if (!alc_is_input_pin(codec, pin))
5284 continue;
5285
David Henningsson5322bf22011-01-05 11:03:56 +01005286 label = hda_get_autocfg_input_label(codec, cfg, i);
5287 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005288 type_idx++;
5289 else
5290 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005291 prev_label = label;
5292
Takashi Iwai05f5f472009-08-25 13:10:18 +02005293 if (mixer) {
5294 idx = get_connection_index(codec, mixer, pin);
5295 if (idx >= 0) {
5296 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005297 label, type_idx,
5298 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005299 if (err < 0)
5300 return err;
5301 }
5302 }
5303
5304 if (!cap1)
5305 continue;
5306 idx = get_connection_index(codec, cap1, pin);
5307 if (idx < 0 && cap2)
5308 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005309 if (idx >= 0)
5310 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005311 }
5312 return 0;
5313}
5314
Takashi Iwai05f5f472009-08-25 13:10:18 +02005315static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5316 const struct auto_pin_cfg *cfg)
5317{
5318 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5319}
5320
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005321static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5322 unsigned int pin_type)
5323{
5324 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5325 pin_type);
5326 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005327 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5328 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005329}
5330
Kailang Yangdf694da2005-12-05 19:42:22 +01005331static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5332 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005333 int dac_idx)
5334{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005335 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005336 /* need the manual connection? */
5337 if (alc880_is_multi_pin(nid)) {
5338 struct alc_spec *spec = codec->spec;
5339 int idx = alc880_multi_pin_idx(nid);
5340 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5341 AC_VERB_SET_CONNECT_SEL,
5342 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5343 }
5344}
5345
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005346static int get_pin_type(int line_out_type)
5347{
5348 if (line_out_type == AUTO_PIN_HP_OUT)
5349 return PIN_HP;
5350 else
5351 return PIN_OUT;
5352}
5353
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005354static void alc880_auto_init_multi_out(struct hda_codec *codec)
5355{
5356 struct alc_spec *spec = codec->spec;
5357 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005358
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005359 for (i = 0; i < spec->autocfg.line_outs; i++) {
5360 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005361 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5362 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005363 }
5364}
5365
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005366static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005367{
5368 struct alc_spec *spec = codec->spec;
5369 hda_nid_t pin;
5370
Takashi Iwai82bc9552006-03-21 11:24:42 +01005371 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005372 if (pin) /* connect to front */
5373 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005374 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005375 if (pin) /* connect to front */
5376 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5377}
5378
5379static void alc880_auto_init_analog_input(struct hda_codec *codec)
5380{
5381 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005382 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005383 int i;
5384
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005385 for (i = 0; i < cfg->num_inputs; i++) {
5386 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005387 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005388 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005389 if (nid != ALC880_PIN_CD_NID &&
5390 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005391 snd_hda_codec_write(codec, nid, 0,
5392 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005393 AMP_OUT_MUTE);
5394 }
5395 }
5396}
5397
Takashi Iwai7f311a42010-04-09 17:32:23 +02005398static void alc880_auto_init_input_src(struct hda_codec *codec)
5399{
5400 struct alc_spec *spec = codec->spec;
5401 int c;
5402
5403 for (c = 0; c < spec->num_adc_nids; c++) {
5404 unsigned int mux_idx;
5405 const struct hda_input_mux *imux;
5406 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5407 imux = &spec->input_mux[mux_idx];
5408 if (!imux->num_items && mux_idx > 0)
5409 imux = &spec->input_mux[0];
5410 if (imux)
5411 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5412 AC_VERB_SET_CONNECT_SEL,
5413 imux->items[0].index);
5414 }
5415}
5416
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005417/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005418/* return 1 if successful, 0 if the proper config is not found,
5419 * or a negative error code
5420 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005421static int alc880_parse_auto_config(struct hda_codec *codec)
5422{
5423 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005424 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005425 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005426
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005427 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5428 alc880_ignore);
5429 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005430 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005431 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005432 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005433
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005434 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5435 if (err < 0)
5436 return err;
5437 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5438 if (err < 0)
5439 return err;
5440 err = alc880_auto_create_extra_out(spec,
5441 spec->autocfg.speaker_pins[0],
5442 "Speaker");
5443 if (err < 0)
5444 return err;
5445 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5446 "Headphone");
5447 if (err < 0)
5448 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005449 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005450 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005451 return err;
5452
5453 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5454
Takashi Iwai757899a2010-07-30 10:48:14 +02005455 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005456
Takashi Iwai603c4012008-07-30 15:01:44 +02005457 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005458 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005459
Takashi Iwaid88897e2008-10-31 15:01:37 +01005460 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005461
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005462 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005463 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005464
Kailang Yang6227cdc2010-02-25 08:36:52 +01005465 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005466
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005467 return 1;
5468}
5469
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005470/* additional initialization for auto-configuration model */
5471static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005472{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005473 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005474 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005475 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005476 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005477 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005478 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005479 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005480 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005481}
5482
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005483/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5484 * one of two digital mic pins, e.g. on ALC272
5485 */
5486static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005487{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005488 struct alc_spec *spec = codec->spec;
5489 int i;
5490
5491 for (i = 0; i < spec->num_adc_nids; i++) {
5492 hda_nid_t cap = spec->capsrc_nids ?
5493 spec->capsrc_nids[i] : spec->adc_nids[i];
5494 int iidx, eidx;
5495
5496 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5497 if (iidx < 0)
5498 continue;
5499 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5500 if (eidx < 0)
5501 continue;
5502 spec->int_mic.mux_idx = iidx;
5503 spec->ext_mic.mux_idx = eidx;
5504 if (spec->capsrc_nids)
5505 spec->capsrc_nids += i;
5506 spec->adc_nids += i;
5507 spec->num_adc_nids = 1;
5508 return;
5509 }
5510 snd_printd(KERN_INFO "hda_codec: %s: "
5511 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5512 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5513 spec->auto_mic = 0; /* disable auto-mic to be sure */
5514}
5515
Takashi Iwai748cce42010-08-04 07:37:39 +02005516/* select or unmute the given capsrc route */
5517static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5518 int idx)
5519{
5520 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5521 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5522 HDA_AMP_MUTE, 0);
5523 } else {
5524 snd_hda_codec_write_cache(codec, cap, 0,
5525 AC_VERB_SET_CONNECT_SEL, idx);
5526 }
5527}
5528
Takashi Iwai840b64c2010-07-13 22:49:01 +02005529/* set the default connection to that pin */
5530static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5531{
5532 struct alc_spec *spec = codec->spec;
5533 int i;
5534
5535 for (i = 0; i < spec->num_adc_nids; i++) {
5536 hda_nid_t cap = spec->capsrc_nids ?
5537 spec->capsrc_nids[i] : spec->adc_nids[i];
5538 int idx;
5539
5540 idx = get_connection_index(codec, cap, pin);
5541 if (idx < 0)
5542 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005543 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005544 return i; /* return the found index */
5545 }
5546 return -1; /* not found */
5547}
5548
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005549/* choose the ADC/MUX containing the input pin and initialize the setup */
5550static void fixup_single_adc(struct hda_codec *codec)
5551{
5552 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005553 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005554 int i;
5555
5556 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005557 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005558 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005559 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005560 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005561 /* use only this ADC */
5562 if (spec->capsrc_nids)
5563 spec->capsrc_nids += i;
5564 spec->adc_nids += i;
5565 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005566 }
5567}
5568
Takashi Iwai840b64c2010-07-13 22:49:01 +02005569/* initialize dual adcs */
5570static void fixup_dual_adc_switch(struct hda_codec *codec)
5571{
5572 struct alc_spec *spec = codec->spec;
5573 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5574 init_capsrc_for_pin(codec, spec->int_mic.pin);
5575}
5576
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005577static void set_capture_mixer(struct hda_codec *codec)
5578{
5579 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005580 static struct snd_kcontrol_new *caps[2][3] = {
5581 { alc_capture_mixer_nosrc1,
5582 alc_capture_mixer_nosrc2,
5583 alc_capture_mixer_nosrc3 },
5584 { alc_capture_mixer1,
5585 alc_capture_mixer2,
5586 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005587 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005588 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005589 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005590 int num_adcs = spec->num_adc_nids;
5591 if (spec->dual_adc_switch)
5592 fixup_dual_adc_switch(codec);
5593 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005594 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005595 else if (spec->input_mux) {
5596 if (spec->input_mux->num_items > 1)
5597 mux = 1;
5598 else if (spec->input_mux->num_items == 1)
5599 fixup_single_adc(codec);
5600 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005601 if (spec->dual_adc_switch)
5602 num_adcs = 1;
5603 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005604 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005605}
5606
Takashi Iwai66946352010-03-29 17:21:45 +02005607/* fill adc_nids (and capsrc_nids) containing all active input pins */
5608static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5609 int num_nids)
5610{
5611 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005612 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005613 int n;
5614 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5615
5616 for (n = 0; n < num_nids; n++) {
5617 hda_nid_t adc, cap;
5618 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5619 int nconns, i, j;
5620
5621 adc = nids[n];
5622 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5623 continue;
5624 cap = adc;
5625 nconns = snd_hda_get_connections(codec, cap, conn,
5626 ARRAY_SIZE(conn));
5627 if (nconns == 1) {
5628 cap = conn[0];
5629 nconns = snd_hda_get_connections(codec, cap, conn,
5630 ARRAY_SIZE(conn));
5631 }
5632 if (nconns <= 0)
5633 continue;
5634 if (!fallback_adc) {
5635 fallback_adc = adc;
5636 fallback_cap = cap;
5637 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005638 for (i = 0; i < cfg->num_inputs; i++) {
5639 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005640 for (j = 0; j < nconns; j++) {
5641 if (conn[j] == nid)
5642 break;
5643 }
5644 if (j >= nconns)
5645 break;
5646 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005647 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005648 int num_adcs = spec->num_adc_nids;
5649 spec->private_adc_nids[num_adcs] = adc;
5650 spec->private_capsrc_nids[num_adcs] = cap;
5651 spec->num_adc_nids++;
5652 spec->adc_nids = spec->private_adc_nids;
5653 if (adc != cap)
5654 spec->capsrc_nids = spec->private_capsrc_nids;
5655 }
5656 }
5657 if (!spec->num_adc_nids) {
5658 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005659 " using fallback 0x%x\n",
5660 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005661 spec->private_adc_nids[0] = fallback_adc;
5662 spec->adc_nids = spec->private_adc_nids;
5663 if (fallback_adc != fallback_cap) {
5664 spec->private_capsrc_nids[0] = fallback_cap;
5665 spec->capsrc_nids = spec->private_adc_nids;
5666 }
5667 }
5668}
5669
Takashi Iwai67d634c2009-11-16 15:35:59 +01005670#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005671#define set_beep_amp(spec, nid, idx, dir) \
5672 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005673
5674static struct snd_pci_quirk beep_white_list[] = {
5675 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005676 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005677 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005678 {}
5679};
5680
5681static inline int has_cdefine_beep(struct hda_codec *codec)
5682{
5683 struct alc_spec *spec = codec->spec;
5684 const struct snd_pci_quirk *q;
5685 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5686 if (q)
5687 return q->value;
5688 return spec->cdefine.enable_pcbeep;
5689}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005690#else
5691#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005692#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005693#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005694
5695/*
5696 * OK, here we have finally the patch for ALC880
5697 */
5698
Linus Torvalds1da177e2005-04-16 15:20:36 -07005699static int patch_alc880(struct hda_codec *codec)
5700{
5701 struct alc_spec *spec;
5702 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005703 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005704
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005705 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005706 if (spec == NULL)
5707 return -ENOMEM;
5708
5709 codec->spec = spec;
5710
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005711 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5712 alc880_models,
5713 alc880_cfg_tbl);
5714 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005715 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5716 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005717 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005718 }
5719
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005720 if (board_config == ALC880_AUTO) {
5721 /* automatic parse from the BIOS config */
5722 err = alc880_parse_auto_config(codec);
5723 if (err < 0) {
5724 alc_free(codec);
5725 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005726 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005727 printk(KERN_INFO
5728 "hda_codec: Cannot set up configuration "
5729 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005730 board_config = ALC880_3ST;
5731 }
5732 }
5733
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005734 err = snd_hda_attach_beep_device(codec, 0x1);
5735 if (err < 0) {
5736 alc_free(codec);
5737 return err;
5738 }
5739
Kailang Yangdf694da2005-12-05 19:42:22 +01005740 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005741 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005742
Linus Torvalds1da177e2005-04-16 15:20:36 -07005743 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5744 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005745 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005746
Linus Torvalds1da177e2005-04-16 15:20:36 -07005747 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5748 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5749
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005750 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005751 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005752 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005753 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005754 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005755 if (wcap != AC_WID_AUD_IN) {
5756 spec->adc_nids = alc880_adc_nids_alt;
5757 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005758 } else {
5759 spec->adc_nids = alc880_adc_nids;
5760 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005761 }
5762 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005763 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005764 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005765
Takashi Iwai2134ea42008-01-10 16:53:55 +01005766 spec->vmaster_nid = 0x0c;
5767
Linus Torvalds1da177e2005-04-16 15:20:36 -07005768 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005769 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005770 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005771#ifdef CONFIG_SND_HDA_POWER_SAVE
5772 if (!spec->loopback.amplist)
5773 spec->loopback.amplist = alc880_loopbacks;
5774#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005775
5776 return 0;
5777}
5778
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005779
Linus Torvalds1da177e2005-04-16 15:20:36 -07005780/*
5781 * ALC260 support
5782 */
5783
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005784static hda_nid_t alc260_dac_nids[1] = {
5785 /* front */
5786 0x02,
5787};
5788
5789static hda_nid_t alc260_adc_nids[1] = {
5790 /* ADC0 */
5791 0x04,
5792};
5793
Kailang Yangdf694da2005-12-05 19:42:22 +01005794static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005795 /* ADC1 */
5796 0x05,
5797};
5798
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005799/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5800 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5801 */
5802static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005803 /* ADC0, ADC1 */
5804 0x04, 0x05
5805};
5806
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005807#define ALC260_DIGOUT_NID 0x03
5808#define ALC260_DIGIN_NID 0x06
5809
5810static struct hda_input_mux alc260_capture_source = {
5811 .num_items = 4,
5812 .items = {
5813 { "Mic", 0x0 },
5814 { "Front Mic", 0x1 },
5815 { "Line", 0x2 },
5816 { "CD", 0x4 },
5817 },
5818};
5819
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005820/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005821 * headphone jack and the internal CD lines since these are the only pins at
5822 * which audio can appear. For flexibility, also allow the option of
5823 * recording the mixer output on the second ADC (ADC0 doesn't have a
5824 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005825 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005826static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5827 {
5828 .num_items = 3,
5829 .items = {
5830 { "Mic/Line", 0x0 },
5831 { "CD", 0x4 },
5832 { "Headphone", 0x2 },
5833 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005834 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005835 {
5836 .num_items = 4,
5837 .items = {
5838 { "Mic/Line", 0x0 },
5839 { "CD", 0x4 },
5840 { "Headphone", 0x2 },
5841 { "Mixer", 0x5 },
5842 },
5843 },
5844
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005845};
5846
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005847/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5848 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005849 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005850static struct hda_input_mux alc260_acer_capture_sources[2] = {
5851 {
5852 .num_items = 4,
5853 .items = {
5854 { "Mic", 0x0 },
5855 { "Line", 0x2 },
5856 { "CD", 0x4 },
5857 { "Headphone", 0x5 },
5858 },
5859 },
5860 {
5861 .num_items = 5,
5862 .items = {
5863 { "Mic", 0x0 },
5864 { "Line", 0x2 },
5865 { "CD", 0x4 },
5866 { "Headphone", 0x6 },
5867 { "Mixer", 0x5 },
5868 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005869 },
5870};
Michael Schwingencc959482009-02-22 18:58:45 +01005871
5872/* Maxdata Favorit 100XS */
5873static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5874 {
5875 .num_items = 2,
5876 .items = {
5877 { "Line/Mic", 0x0 },
5878 { "CD", 0x4 },
5879 },
5880 },
5881 {
5882 .num_items = 3,
5883 .items = {
5884 { "Line/Mic", 0x0 },
5885 { "CD", 0x4 },
5886 { "Mixer", 0x5 },
5887 },
5888 },
5889};
5890
Linus Torvalds1da177e2005-04-16 15:20:36 -07005891/*
5892 * This is just place-holder, so there's something for alc_build_pcms to look
5893 * at when it calculates the maximum number of channels. ALC260 has no mixer
5894 * element which allows changing the channel mode, so the verb list is
5895 * never used.
5896 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005897static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005898 { 2, NULL },
5899};
5900
Kailang Yangdf694da2005-12-05 19:42:22 +01005901
5902/* Mixer combinations
5903 *
5904 * basic: base_output + input + pc_beep + capture
5905 * HP: base_output + input + capture_alt
5906 * HP_3013: hp_3013 + input + capture
5907 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005908 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005909 */
5910
5911static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005912 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005913 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005914 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5915 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5916 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5917 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5918 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005919};
Kailang Yangdf694da2005-12-05 19:42:22 +01005920
5921static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005922 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5923 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5924 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5925 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5927 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5928 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5929 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005930 { } /* end */
5931};
5932
Takashi Iwaibec15c32008-01-28 18:16:30 +01005933/* update HP, line and mono out pins according to the master switch */
5934static void alc260_hp_master_update(struct hda_codec *codec,
5935 hda_nid_t hp, hda_nid_t line,
5936 hda_nid_t mono)
5937{
5938 struct alc_spec *spec = codec->spec;
5939 unsigned int val = spec->master_sw ? PIN_HP : 0;
5940 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005941 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005942 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005943 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005944 val);
5945 /* mono (speaker) depending on the HP jack sense */
5946 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005947 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005948 val);
5949}
5950
5951static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5952 struct snd_ctl_elem_value *ucontrol)
5953{
5954 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5955 struct alc_spec *spec = codec->spec;
5956 *ucontrol->value.integer.value = spec->master_sw;
5957 return 0;
5958}
5959
5960static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5961 struct snd_ctl_elem_value *ucontrol)
5962{
5963 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5964 struct alc_spec *spec = codec->spec;
5965 int val = !!*ucontrol->value.integer.value;
5966 hda_nid_t hp, line, mono;
5967
5968 if (val == spec->master_sw)
5969 return 0;
5970 spec->master_sw = val;
5971 hp = (kcontrol->private_value >> 16) & 0xff;
5972 line = (kcontrol->private_value >> 8) & 0xff;
5973 mono = kcontrol->private_value & 0xff;
5974 alc260_hp_master_update(codec, hp, line, mono);
5975 return 1;
5976}
5977
5978static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5979 {
5980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5981 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005982 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005983 .info = snd_ctl_boolean_mono_info,
5984 .get = alc260_hp_master_sw_get,
5985 .put = alc260_hp_master_sw_put,
5986 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5987 },
5988 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5989 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5990 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5991 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5992 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5993 HDA_OUTPUT),
5994 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5995 { } /* end */
5996};
5997
5998static struct hda_verb alc260_hp_unsol_verbs[] = {
5999 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6000 {},
6001};
6002
6003static void alc260_hp_automute(struct hda_codec *codec)
6004{
6005 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006006
Wu Fengguang864f92b2009-11-18 12:38:02 +08006007 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006008 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
6009}
6010
6011static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
6012{
6013 if ((res >> 26) == ALC880_HP_EVENT)
6014 alc260_hp_automute(codec);
6015}
6016
Kailang Yangdf694da2005-12-05 19:42:22 +01006017static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006018 {
6019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6020 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006021 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006022 .info = snd_ctl_boolean_mono_info,
6023 .get = alc260_hp_master_sw_get,
6024 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006025 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01006026 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006027 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6028 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6029 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
6030 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
6031 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006033 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6034 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02006035 { } /* end */
6036};
6037
Kailang Yang3f878302008-08-26 13:02:23 +02006038static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
6039 .ops = &snd_hda_bind_vol,
6040 .values = {
6041 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6042 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
6043 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6044 0
6045 },
6046};
6047
6048static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6049 .ops = &snd_hda_bind_sw,
6050 .values = {
6051 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6052 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6053 0
6054 },
6055};
6056
6057static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6058 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6059 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6060 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6061 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6062 { } /* end */
6063};
6064
Takashi Iwaibec15c32008-01-28 18:16:30 +01006065static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6066 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6067 {},
6068};
6069
6070static void alc260_hp_3013_automute(struct hda_codec *codec)
6071{
6072 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006073
Wu Fengguang864f92b2009-11-18 12:38:02 +08006074 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006075 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006076}
6077
6078static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6079 unsigned int res)
6080{
6081 if ((res >> 26) == ALC880_HP_EVENT)
6082 alc260_hp_3013_automute(codec);
6083}
6084
Kailang Yang3f878302008-08-26 13:02:23 +02006085static void alc260_hp_3012_automute(struct hda_codec *codec)
6086{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006087 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006088
Kailang Yang3f878302008-08-26 13:02:23 +02006089 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6090 bits);
6091 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6092 bits);
6093 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6094 bits);
6095}
6096
6097static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6098 unsigned int res)
6099{
6100 if ((res >> 26) == ALC880_HP_EVENT)
6101 alc260_hp_3012_automute(codec);
6102}
6103
6104/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006105 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6106 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006107static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006108 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006109 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006110 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006111 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6112 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6113 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6114 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006115 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006116 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6117 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006118 { } /* end */
6119};
6120
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006121/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6122 * versions of the ALC260 don't act on requests to enable mic bias from NID
6123 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6124 * datasheet doesn't mention this restriction. At this stage it's not clear
6125 * whether this behaviour is intentional or is a hardware bug in chip
6126 * revisions available in early 2006. Therefore for now allow the
6127 * "Headphone Jack Mode" control to span all choices, but if it turns out
6128 * that the lack of mic bias for this NID is intentional we could change the
6129 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6130 *
6131 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6132 * don't appear to make the mic bias available from the "line" jack, even
6133 * though the NID used for this jack (0x14) can supply it. The theory is
6134 * that perhaps Acer have included blocking capacitors between the ALC260
6135 * and the output jack. If this turns out to be the case for all such
6136 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6137 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006138 *
6139 * The C20x Tablet series have a mono internal speaker which is controlled
6140 * via the chip's Mono sum widget and pin complex, so include the necessary
6141 * controls for such models. On models without a "mono speaker" the control
6142 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006143 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006144static struct snd_kcontrol_new alc260_acer_mixer[] = {
6145 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6146 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006147 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006148 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006149 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006150 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006151 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006152 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6153 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6155 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6156 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6157 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6158 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6159 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006160 { } /* end */
6161};
6162
Michael Schwingencc959482009-02-22 18:58:45 +01006163/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6164 */
6165static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6166 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6167 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6168 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6169 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6170 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6171 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6172 { } /* end */
6173};
6174
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006175/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6176 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6177 */
6178static struct snd_kcontrol_new alc260_will_mixer[] = {
6179 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6180 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6182 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6183 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6184 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6185 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6186 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6187 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6188 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006189 { } /* end */
6190};
6191
6192/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6193 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6194 */
6195static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6196 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6197 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6199 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6200 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6201 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6202 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6203 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6204 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6205 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6206 { } /* end */
6207};
6208
Kailang Yangdf694da2005-12-05 19:42:22 +01006209/*
6210 * initialization verbs
6211 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006212static struct hda_verb alc260_init_verbs[] = {
6213 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006214 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006215 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006216 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006217 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006218 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006219 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006220 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006221 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006223 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006224 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006225 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006226 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006227 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006228 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006229 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006230 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6231 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006232 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006233 /* set connection select to line in (default select for this ADC) */
6234 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006235 /* mute capture amp left and right */
6236 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6237 /* set connection select to line in (default select for this ADC) */
6238 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006239 /* set vol=0 Line-Out mixer amp left and right */
6240 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6241 /* unmute pin widget amp left and right (no gain on this amp) */
6242 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6243 /* set vol=0 HP mixer amp left and right */
6244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6245 /* unmute pin widget amp left and right (no gain on this amp) */
6246 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6247 /* set vol=0 Mono mixer amp left and right */
6248 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6249 /* unmute pin widget amp left and right (no gain on this amp) */
6250 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6251 /* unmute LINE-2 out pin */
6252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006253 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6254 * Line In 2 = 0x03
6255 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006256 /* mute analog inputs */
6257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6258 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006262 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006263 /* mute Front out path */
6264 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6266 /* mute Headphone out path */
6267 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6268 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6269 /* mute Mono out path */
6270 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6271 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006272 { }
6273};
6274
Takashi Iwai474167d2006-05-17 17:17:43 +02006275#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006276static struct hda_verb alc260_hp_init_verbs[] = {
6277 /* Headphone and output */
6278 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6279 /* mono output */
6280 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6281 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6282 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6283 /* Mic2 (front panel) pin widget for input and vref at 80% */
6284 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6285 /* Line In pin widget for input */
6286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6287 /* Line-2 pin widget for output */
6288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6289 /* CD pin widget for input */
6290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6291 /* unmute amp left and right */
6292 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6293 /* set connection select to line in (default select for this ADC) */
6294 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6295 /* unmute Line-Out mixer amp left and right (volume = 0) */
6296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6297 /* mute pin widget amp left and right (no gain on this amp) */
6298 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6299 /* unmute HP mixer amp left and right (volume = 0) */
6300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6301 /* mute pin widget amp left and right (no gain on this amp) */
6302 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006303 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6304 * Line In 2 = 0x03
6305 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006306 /* mute analog inputs */
6307 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006312 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6313 /* Unmute Front out path */
6314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6316 /* Unmute Headphone out path */
6317 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6318 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6319 /* Unmute Mono out path */
6320 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6321 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6322 { }
6323};
Takashi Iwai474167d2006-05-17 17:17:43 +02006324#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006325
6326static struct hda_verb alc260_hp_3013_init_verbs[] = {
6327 /* Line out and output */
6328 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6329 /* mono output */
6330 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6331 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6332 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6333 /* Mic2 (front panel) pin widget for input and vref at 80% */
6334 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6335 /* Line In pin widget for input */
6336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6337 /* Headphone pin widget for output */
6338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6339 /* CD pin widget for input */
6340 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6341 /* unmute amp left and right */
6342 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6343 /* set connection select to line in (default select for this ADC) */
6344 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6345 /* unmute Line-Out mixer amp left and right (volume = 0) */
6346 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6347 /* mute pin widget amp left and right (no gain on this amp) */
6348 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6349 /* unmute HP mixer amp left and right (volume = 0) */
6350 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6351 /* mute pin widget amp left and right (no gain on this amp) */
6352 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006353 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6354 * Line In 2 = 0x03
6355 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006356 /* mute analog inputs */
6357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6358 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006362 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6363 /* Unmute Front out path */
6364 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6365 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6366 /* Unmute Headphone out path */
6367 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6369 /* Unmute Mono out path */
6370 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6371 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6372 { }
6373};
6374
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006375/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006376 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6377 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006378 */
6379static struct hda_verb alc260_fujitsu_init_verbs[] = {
6380 /* Disable all GPIOs */
6381 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6382 /* Internal speaker is connected to headphone pin */
6383 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6384 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006386 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6387 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6388 /* Ensure all other unused pins are disabled and muted. */
6389 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6390 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006391 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006392 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006393 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006394 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6395 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006397
Jonathan Woithef7ace402006-02-28 11:46:14 +01006398 /* Disable digital (SPDIF) pins */
6399 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6400 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006401
Kailang Yangea1fb292008-08-26 12:58:38 +02006402 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006403 * when acting as an output.
6404 */
6405 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6406
6407 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6409 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6410 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6411 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6412 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6413 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6414 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6415 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6416 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006417
Jonathan Woithef7ace402006-02-28 11:46:14 +01006418 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6419 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6420 /* Unmute Line1 pin widget output buffer since it starts as an output.
6421 * If the pin mode is changed by the user the pin mode control will
6422 * take care of enabling the pin's input/output buffers as needed.
6423 * Therefore there's no need to enable the input buffer at this
6424 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006425 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006427 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006428 * mixer ctrl)
6429 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006430 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006431
Jonathan Woithef7ace402006-02-28 11:46:14 +01006432 /* Mute capture amp left and right */
6433 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006434 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006435 * in (on mic1 pin)
6436 */
6437 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006438
Jonathan Woithef7ace402006-02-28 11:46:14 +01006439 /* Do the same for the second ADC: mute capture input amp and
6440 * set ADC connection to line in (on mic1 pin)
6441 */
6442 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6443 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006444
Jonathan Woithef7ace402006-02-28 11:46:14 +01006445 /* Mute all inputs to mixer widget (even unconnected ones) */
6446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6447 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6448 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006454
6455 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006456};
6457
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006458/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6459 * similar laptops (adapted from Fujitsu init verbs).
6460 */
6461static struct hda_verb alc260_acer_init_verbs[] = {
6462 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6463 * the headphone jack. Turn this on and rely on the standard mute
6464 * methods whenever the user wants to turn these outputs off.
6465 */
6466 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6467 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6468 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6469 /* Internal speaker/Headphone jack is connected to Line-out pin */
6470 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6471 /* Internal microphone/Mic jack is connected to Mic1 pin */
6472 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6473 /* Line In jack is connected to Line1 pin */
6474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006475 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6476 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006477 /* Ensure all other unused pins are disabled and muted. */
6478 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6479 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006480 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6481 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6484 /* Disable digital (SPDIF) pins */
6485 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6486 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6487
Kailang Yangea1fb292008-08-26 12:58:38 +02006488 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006489 * bus when acting as outputs.
6490 */
6491 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6492 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6493
6494 /* Start with output sum widgets muted and their output gains at min */
6495 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6496 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6497 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6498 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6499 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6500 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6501 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6502 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6503 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6504
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006505 /* Unmute Line-out pin widget amp left and right
6506 * (no equiv mixer ctrl)
6507 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006508 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006509 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6510 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006511 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6512 * inputs. If the pin mode is changed by the user the pin mode control
6513 * will take care of enabling the pin's input/output buffers as needed.
6514 * Therefore there's no need to enable the input buffer at this
6515 * stage.
6516 */
6517 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6519
6520 /* Mute capture amp left and right */
6521 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6522 /* Set ADC connection select to match default mixer setting - mic
6523 * (on mic1 pin)
6524 */
6525 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6526
6527 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006528 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006529 */
6530 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006531 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006532
6533 /* Mute all inputs to mixer widget (even unconnected ones) */
6534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6536 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6537 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6538 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6539 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6542
6543 { }
6544};
6545
Michael Schwingencc959482009-02-22 18:58:45 +01006546/* Initialisation sequence for Maxdata Favorit 100XS
6547 * (adapted from Acer init verbs).
6548 */
6549static struct hda_verb alc260_favorit100_init_verbs[] = {
6550 /* GPIO 0 enables the output jack.
6551 * Turn this on and rely on the standard mute
6552 * methods whenever the user wants to turn these outputs off.
6553 */
6554 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6555 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6556 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6557 /* Line/Mic input jack is connected to Mic1 pin */
6558 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6559 /* Ensure all other unused pins are disabled and muted. */
6560 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6561 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6562 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6563 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6564 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6565 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6566 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6567 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6570 /* Disable digital (SPDIF) pins */
6571 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6572 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6573
6574 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6575 * bus when acting as outputs.
6576 */
6577 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6578 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6579
6580 /* Start with output sum widgets muted and their output gains at min */
6581 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6582 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6583 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6584 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6585 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6586 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6587 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6588 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6589 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6590
6591 /* Unmute Line-out pin widget amp left and right
6592 * (no equiv mixer ctrl)
6593 */
6594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6595 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6596 * inputs. If the pin mode is changed by the user the pin mode control
6597 * will take care of enabling the pin's input/output buffers as needed.
6598 * Therefore there's no need to enable the input buffer at this
6599 * stage.
6600 */
6601 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6602
6603 /* Mute capture amp left and right */
6604 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6605 /* Set ADC connection select to match default mixer setting - mic
6606 * (on mic1 pin)
6607 */
6608 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6609
6610 /* Do similar with the second ADC: mute capture input amp and
6611 * set ADC connection to mic to match ALSA's default state.
6612 */
6613 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6614 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6615
6616 /* Mute all inputs to mixer widget (even unconnected ones) */
6617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6620 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6623 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6624 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6625
6626 { }
6627};
6628
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006629static struct hda_verb alc260_will_verbs[] = {
6630 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6631 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6632 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6633 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6634 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6635 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6636 {}
6637};
6638
6639static struct hda_verb alc260_replacer_672v_verbs[] = {
6640 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6641 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6642 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6643
6644 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6645 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6646 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6647
6648 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6649 {}
6650};
6651
6652/* toggle speaker-output according to the hp-jack state */
6653static void alc260_replacer_672v_automute(struct hda_codec *codec)
6654{
6655 unsigned int present;
6656
6657 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006658 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006659 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006660 snd_hda_codec_write_cache(codec, 0x01, 0,
6661 AC_VERB_SET_GPIO_DATA, 1);
6662 snd_hda_codec_write_cache(codec, 0x0f, 0,
6663 AC_VERB_SET_PIN_WIDGET_CONTROL,
6664 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006665 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006666 snd_hda_codec_write_cache(codec, 0x01, 0,
6667 AC_VERB_SET_GPIO_DATA, 0);
6668 snd_hda_codec_write_cache(codec, 0x0f, 0,
6669 AC_VERB_SET_PIN_WIDGET_CONTROL,
6670 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006671 }
6672}
6673
6674static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6675 unsigned int res)
6676{
6677 if ((res >> 26) == ALC880_HP_EVENT)
6678 alc260_replacer_672v_automute(codec);
6679}
6680
Kailang Yang3f878302008-08-26 13:02:23 +02006681static struct hda_verb alc260_hp_dc7600_verbs[] = {
6682 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6684 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6685 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6686 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6688 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6689 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6690 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6691 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6692 {}
6693};
6694
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006695/* Test configuration for debugging, modelled after the ALC880 test
6696 * configuration.
6697 */
6698#ifdef CONFIG_SND_DEBUG
6699static hda_nid_t alc260_test_dac_nids[1] = {
6700 0x02,
6701};
6702static hda_nid_t alc260_test_adc_nids[2] = {
6703 0x04, 0x05,
6704};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006705/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006706 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006707 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006708 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006709static struct hda_input_mux alc260_test_capture_sources[2] = {
6710 {
6711 .num_items = 7,
6712 .items = {
6713 { "MIC1 pin", 0x0 },
6714 { "MIC2 pin", 0x1 },
6715 { "LINE1 pin", 0x2 },
6716 { "LINE2 pin", 0x3 },
6717 { "CD pin", 0x4 },
6718 { "LINE-OUT pin", 0x5 },
6719 { "HP-OUT pin", 0x6 },
6720 },
6721 },
6722 {
6723 .num_items = 8,
6724 .items = {
6725 { "MIC1 pin", 0x0 },
6726 { "MIC2 pin", 0x1 },
6727 { "LINE1 pin", 0x2 },
6728 { "LINE2 pin", 0x3 },
6729 { "CD pin", 0x4 },
6730 { "Mixer", 0x5 },
6731 { "LINE-OUT pin", 0x6 },
6732 { "HP-OUT pin", 0x7 },
6733 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006734 },
6735};
6736static struct snd_kcontrol_new alc260_test_mixer[] = {
6737 /* Output driver widgets */
6738 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6739 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6740 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6741 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6742 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6743 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6744
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006745 /* Modes for retasking pin widgets
6746 * Note: the ALC260 doesn't seem to act on requests to enable mic
6747 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6748 * mention this restriction. At this stage it's not clear whether
6749 * this behaviour is intentional or is a hardware bug in chip
6750 * revisions available at least up until early 2006. Therefore for
6751 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6752 * choices, but if it turns out that the lack of mic bias for these
6753 * NIDs is intentional we could change their modes from
6754 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6755 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006756 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6757 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6758 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6759 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6760 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6761 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6762
6763 /* Loopback mixer controls */
6764 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6765 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6766 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6767 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6768 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6769 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6770 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6771 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6772 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6773 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006774 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6775 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6776 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6777 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006778
6779 /* Controls for GPIO pins, assuming they are configured as outputs */
6780 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6781 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6782 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6783 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6784
Jonathan Woithe92621f12006-02-28 11:47:47 +01006785 /* Switches to allow the digital IO pins to be enabled. The datasheet
6786 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006787 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006788 */
6789 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6790 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6791
Jonathan Woithef8225f62008-01-08 12:16:54 +01006792 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6793 * this output to turn on an external amplifier.
6794 */
6795 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6796 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6797
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006798 { } /* end */
6799};
6800static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006801 /* Enable all GPIOs as outputs with an initial value of 0 */
6802 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6803 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6804 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6805
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006806 /* Enable retasking pins as output, initially without power amp */
6807 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6808 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6811 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6812 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6813
Jonathan Woithe92621f12006-02-28 11:47:47 +01006814 /* Disable digital (SPDIF) pins initially, but users can enable
6815 * them via a mixer switch. In the case of SPDIF-out, this initverb
6816 * payload also sets the generation to 0, output to be in "consumer"
6817 * PCM format, copyright asserted, no pre-emphasis and no validity
6818 * control.
6819 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006820 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6821 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6822
Kailang Yangea1fb292008-08-26 12:58:38 +02006823 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006824 * OUT1 sum bus when acting as an output.
6825 */
6826 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6827 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6828 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6829 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6830
6831 /* Start with output sum widgets muted and their output gains at min */
6832 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6833 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6834 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6836 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6837 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6838 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6839 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6840 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6841
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006842 /* Unmute retasking pin widget output buffers since the default
6843 * state appears to be output. As the pin mode is changed by the
6844 * user the pin mode control will take care of enabling the pin's
6845 * input/output buffers as needed.
6846 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006847 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6850 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6851 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6852 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6853 /* Also unmute the mono-out pin widget */
6854 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6855
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006856 /* Mute capture amp left and right */
6857 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006858 /* Set ADC connection select to match default mixer setting (mic1
6859 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006860 */
6861 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6862
6863 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006864 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006865 */
6866 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6867 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6868
6869 /* Mute all inputs to mixer widget (even unconnected ones) */
6870 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6878
6879 { }
6880};
6881#endif
6882
Takashi Iwai63300792008-01-24 15:31:36 +01006883#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6884#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006885
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006886#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6887#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6888
Kailang Yangdf694da2005-12-05 19:42:22 +01006889/*
6890 * for BIOS auto-configuration
6891 */
6892
6893static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006894 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006895{
6896 hda_nid_t nid_vol;
6897 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006898 int err;
6899
6900 if (nid >= 0x0f && nid < 0x11) {
6901 nid_vol = nid - 0x7;
6902 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6903 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6904 } else if (nid == 0x11) {
6905 nid_vol = nid - 0x7;
6906 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6907 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6908 } else if (nid >= 0x12 && nid <= 0x15) {
6909 nid_vol = 0x08;
6910 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6911 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6912 } else
6913 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006914
Takashi Iwai863b4512008-10-21 17:01:47 +02006915 if (!(*vol_bits & (1 << nid_vol))) {
6916 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006917 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006918 if (err < 0)
6919 return err;
6920 *vol_bits |= (1 << nid_vol);
6921 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006922 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006923 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006924 return err;
6925 return 1;
6926}
6927
6928/* add playback controls from the parsed DAC table */
6929static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6930 const struct auto_pin_cfg *cfg)
6931{
6932 hda_nid_t nid;
6933 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006934 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006935
6936 spec->multiout.num_dacs = 1;
6937 spec->multiout.dac_nids = spec->private_dac_nids;
6938 spec->multiout.dac_nids[0] = 0x02;
6939
6940 nid = cfg->line_out_pins[0];
6941 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006942 const char *pfx;
6943 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6944 pfx = "Master";
6945 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6946 pfx = "Speaker";
6947 else
6948 pfx = "Front";
6949 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006950 if (err < 0)
6951 return err;
6952 }
6953
Takashi Iwai82bc9552006-03-21 11:24:42 +01006954 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006955 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006956 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006957 if (err < 0)
6958 return err;
6959 }
6960
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006961 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006962 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006963 err = alc260_add_playback_controls(spec, nid, "Headphone",
6964 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006965 if (err < 0)
6966 return err;
6967 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006968 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006969}
6970
6971/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006972static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006973 const struct auto_pin_cfg *cfg)
6974{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006975 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006976}
6977
6978static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6979 hda_nid_t nid, int pin_type,
6980 int sel_idx)
6981{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006982 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006983 /* need the manual connection? */
6984 if (nid >= 0x12) {
6985 int idx = nid - 0x12;
6986 snd_hda_codec_write(codec, idx + 0x0b, 0,
6987 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006988 }
6989}
6990
6991static void alc260_auto_init_multi_out(struct hda_codec *codec)
6992{
6993 struct alc_spec *spec = codec->spec;
6994 hda_nid_t nid;
6995
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006996 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006997 if (nid) {
6998 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6999 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
7000 }
Kailang Yangea1fb292008-08-26 12:58:38 +02007001
Takashi Iwai82bc9552006-03-21 11:24:42 +01007002 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007003 if (nid)
7004 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
7005
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007006 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007007 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007008 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007009}
Kailang Yangdf694da2005-12-05 19:42:22 +01007010
7011#define ALC260_PIN_CD_NID 0x16
7012static void alc260_auto_init_analog_input(struct hda_codec *codec)
7013{
7014 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007015 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01007016 int i;
7017
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007018 for (i = 0; i < cfg->num_inputs; i++) {
7019 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01007020 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02007021 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01007022 if (nid != ALC260_PIN_CD_NID &&
7023 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007024 snd_hda_codec_write(codec, nid, 0,
7025 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01007026 AMP_OUT_MUTE);
7027 }
7028 }
7029}
7030
Takashi Iwai7f311a42010-04-09 17:32:23 +02007031#define alc260_auto_init_input_src alc880_auto_init_input_src
7032
Kailang Yangdf694da2005-12-05 19:42:22 +01007033/*
7034 * generic initialization of ADC, input mixers and output mixers
7035 */
7036static struct hda_verb alc260_volume_init_verbs[] = {
7037 /*
7038 * Unmute ADC0-1 and set the default input to mic-in
7039 */
7040 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7041 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7042 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7043 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007044
Kailang Yangdf694da2005-12-05 19:42:22 +01007045 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7046 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007047 * Note: PASD motherboards uses the Line In 2 as the input for
7048 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007049 */
7050 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007051 /* mute analog inputs */
7052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007057
7058 /*
7059 * Set up output mixers (0x08 - 0x0a)
7060 */
7061 /* set vol=0 to output mixers */
7062 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7064 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7065 /* set up input amps for analog loopback */
7066 /* Amp Indices: DAC = 0, mixer = 1 */
7067 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7069 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7071 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7072 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007073
Kailang Yangdf694da2005-12-05 19:42:22 +01007074 { }
7075};
7076
7077static int alc260_parse_auto_config(struct hda_codec *codec)
7078{
7079 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007080 int err;
7081 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7082
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007083 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7084 alc260_ignore);
7085 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007086 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007087 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7088 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007089 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007090 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007091 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007092 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007093 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007094 return err;
7095
7096 spec->multiout.max_channels = 2;
7097
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007098 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007099 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007100 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007101 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007102
Takashi Iwaid88897e2008-10-31 15:01:37 +01007103 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007104
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007105 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007106 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007107
Kailang Yang6227cdc2010-02-25 08:36:52 +01007108 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007109
Kailang Yangdf694da2005-12-05 19:42:22 +01007110 return 1;
7111}
7112
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007113/* additional initialization for auto-configuration model */
7114static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007115{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007116 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007117 alc260_auto_init_multi_out(codec);
7118 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007119 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007120 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007121 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007122 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007123}
7124
Takashi Iwaicb53c622007-08-10 17:21:45 +02007125#ifdef CONFIG_SND_HDA_POWER_SAVE
7126static struct hda_amp_list alc260_loopbacks[] = {
7127 { 0x07, HDA_INPUT, 0 },
7128 { 0x07, HDA_INPUT, 1 },
7129 { 0x07, HDA_INPUT, 2 },
7130 { 0x07, HDA_INPUT, 3 },
7131 { 0x07, HDA_INPUT, 4 },
7132 { } /* end */
7133};
7134#endif
7135
Kailang Yangdf694da2005-12-05 19:42:22 +01007136/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007137 * Pin config fixes
7138 */
7139enum {
7140 PINFIX_HP_DC5750,
7141};
7142
Takashi Iwaifc091762010-08-04 23:53:36 +02007143static const struct alc_fixup alc260_fixups[] = {
7144 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007145 .type = ALC_FIXUP_PINS,
7146 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007147 { 0x11, 0x90130110 }, /* speaker */
7148 { }
7149 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007150 },
7151};
7152
7153static struct snd_pci_quirk alc260_fixup_tbl[] = {
7154 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7155 {}
7156};
7157
7158/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007159 * ALC260 configurations
7160 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007161static const char *alc260_models[ALC260_MODEL_LAST] = {
7162 [ALC260_BASIC] = "basic",
7163 [ALC260_HP] = "hp",
7164 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007165 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007166 [ALC260_FUJITSU_S702X] = "fujitsu",
7167 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007168 [ALC260_WILL] = "will",
7169 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007170 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007171#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007172 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007173#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007174 [ALC260_AUTO] = "auto",
7175};
7176
7177static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007178 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007179 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007180 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007181 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007182 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007183 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007184 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007185 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007186 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007187 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7188 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7189 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7190 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7191 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7192 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7193 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7194 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7195 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007196 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007197 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007198 {}
7199};
7200
Kailang Yangdf694da2005-12-05 19:42:22 +01007201static struct alc_config_preset alc260_presets[] = {
7202 [ALC260_BASIC] = {
7203 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007204 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007205 .init_verbs = { alc260_init_verbs },
7206 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7207 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007208 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007209 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007210 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7211 .channel_mode = alc260_modes,
7212 .input_mux = &alc260_capture_source,
7213 },
7214 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007215 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007216 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007217 .init_verbs = { alc260_init_verbs,
7218 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007219 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7220 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007221 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7222 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007223 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7224 .channel_mode = alc260_modes,
7225 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007226 .unsol_event = alc260_hp_unsol_event,
7227 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007228 },
Kailang Yang3f878302008-08-26 13:02:23 +02007229 [ALC260_HP_DC7600] = {
7230 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007231 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007232 .init_verbs = { alc260_init_verbs,
7233 alc260_hp_dc7600_verbs },
7234 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7235 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007236 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7237 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007238 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7239 .channel_mode = alc260_modes,
7240 .input_mux = &alc260_capture_source,
7241 .unsol_event = alc260_hp_3012_unsol_event,
7242 .init_hook = alc260_hp_3012_automute,
7243 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007244 [ALC260_HP_3013] = {
7245 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007246 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007247 .init_verbs = { alc260_hp_3013_init_verbs,
7248 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007249 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7250 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007251 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7252 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007253 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7254 .channel_mode = alc260_modes,
7255 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007256 .unsol_event = alc260_hp_3013_unsol_event,
7257 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007258 },
7259 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007260 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007261 .init_verbs = { alc260_fujitsu_init_verbs },
7262 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7263 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007264 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7265 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007266 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7267 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007268 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7269 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007270 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007271 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007272 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007273 .init_verbs = { alc260_acer_init_verbs },
7274 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7275 .dac_nids = alc260_dac_nids,
7276 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7277 .adc_nids = alc260_dual_adc_nids,
7278 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7279 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007280 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7281 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007282 },
Michael Schwingencc959482009-02-22 18:58:45 +01007283 [ALC260_FAVORIT100] = {
7284 .mixers = { alc260_favorit100_mixer },
7285 .init_verbs = { alc260_favorit100_init_verbs },
7286 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7287 .dac_nids = alc260_dac_nids,
7288 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7289 .adc_nids = alc260_dual_adc_nids,
7290 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7291 .channel_mode = alc260_modes,
7292 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7293 .input_mux = alc260_favorit100_capture_sources,
7294 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007295 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007296 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007297 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7298 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7299 .dac_nids = alc260_dac_nids,
7300 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7301 .adc_nids = alc260_adc_nids,
7302 .dig_out_nid = ALC260_DIGOUT_NID,
7303 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7304 .channel_mode = alc260_modes,
7305 .input_mux = &alc260_capture_source,
7306 },
7307 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007308 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007309 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7310 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7311 .dac_nids = alc260_dac_nids,
7312 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7313 .adc_nids = alc260_adc_nids,
7314 .dig_out_nid = ALC260_DIGOUT_NID,
7315 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7316 .channel_mode = alc260_modes,
7317 .input_mux = &alc260_capture_source,
7318 .unsol_event = alc260_replacer_672v_unsol_event,
7319 .init_hook = alc260_replacer_672v_automute,
7320 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007321#ifdef CONFIG_SND_DEBUG
7322 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007323 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007324 .init_verbs = { alc260_test_init_verbs },
7325 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7326 .dac_nids = alc260_test_dac_nids,
7327 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7328 .adc_nids = alc260_test_adc_nids,
7329 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7330 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007331 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7332 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007333 },
7334#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007335};
7336
Linus Torvalds1da177e2005-04-16 15:20:36 -07007337static int patch_alc260(struct hda_codec *codec)
7338{
7339 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007340 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007341
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007342 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007343 if (spec == NULL)
7344 return -ENOMEM;
7345
7346 codec->spec = spec;
7347
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007348 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7349 alc260_models,
7350 alc260_cfg_tbl);
7351 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007352 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007353 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007354 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007355 }
7356
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007357 if (board_config == ALC260_AUTO) {
7358 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7359 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7360 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007361
Kailang Yangdf694da2005-12-05 19:42:22 +01007362 if (board_config == ALC260_AUTO) {
7363 /* automatic parse from the BIOS config */
7364 err = alc260_parse_auto_config(codec);
7365 if (err < 0) {
7366 alc_free(codec);
7367 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007368 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007369 printk(KERN_INFO
7370 "hda_codec: Cannot set up configuration "
7371 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007372 board_config = ALC260_BASIC;
7373 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007374 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007375
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007376 err = snd_hda_attach_beep_device(codec, 0x1);
7377 if (err < 0) {
7378 alc_free(codec);
7379 return err;
7380 }
7381
Kailang Yangdf694da2005-12-05 19:42:22 +01007382 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007383 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007384
Linus Torvalds1da177e2005-04-16 15:20:36 -07007385 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7386 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307387 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007388
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007389 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7390 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7391
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007392 if (!spec->adc_nids && spec->input_mux) {
7393 /* check whether NID 0x04 is valid */
7394 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007395 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007396 /* get type */
7397 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7398 spec->adc_nids = alc260_adc_nids_alt;
7399 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7400 } else {
7401 spec->adc_nids = alc260_adc_nids;
7402 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7403 }
7404 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007405 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007406 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007407
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007408 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007409
Takashi Iwai2134ea42008-01-10 16:53:55 +01007410 spec->vmaster_nid = 0x08;
7411
Linus Torvalds1da177e2005-04-16 15:20:36 -07007412 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007413 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007414 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007415#ifdef CONFIG_SND_HDA_POWER_SAVE
7416 if (!spec->loopback.amplist)
7417 spec->loopback.amplist = alc260_loopbacks;
7418#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007419
7420 return 0;
7421}
7422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007423
Linus Torvalds1da177e2005-04-16 15:20:36 -07007424/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007425 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007426 *
7427 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7428 * configuration. Each pin widget can choose any input DACs and a mixer.
7429 * Each ADC is connected from a mixer of all inputs. This makes possible
7430 * 6-channel independent captures.
7431 *
7432 * In addition, an independent DAC for the multi-playback (not used in this
7433 * driver yet).
7434 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007435#define ALC882_DIGOUT_NID 0x06
7436#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007437#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7438#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7439#define ALC1200_DIGOUT_NID 0x10
7440
Linus Torvalds1da177e2005-04-16 15:20:36 -07007441
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007442static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007443 { 8, NULL }
7444};
7445
Takashi Iwai4953550a2009-06-30 15:28:30 +02007446/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007447static hda_nid_t alc882_dac_nids[4] = {
7448 /* front, rear, clfe, rear_surr */
7449 0x02, 0x03, 0x04, 0x05
7450};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007451#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007452
Takashi Iwai4953550a2009-06-30 15:28:30 +02007453/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007454#define alc882_adc_nids alc880_adc_nids
7455#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007456#define alc883_adc_nids alc882_adc_nids_alt
7457static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7458static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7459#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007460
Takashi Iwaie1406342008-02-11 18:32:32 +01007461static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7462static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007463#define alc883_capsrc_nids alc882_capsrc_nids_alt
7464static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7465#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007466
Linus Torvalds1da177e2005-04-16 15:20:36 -07007467/* input MUX */
7468/* FIXME: should be a matrix-type input source selection */
7469
7470static struct hda_input_mux alc882_capture_source = {
7471 .num_items = 4,
7472 .items = {
7473 { "Mic", 0x0 },
7474 { "Front Mic", 0x1 },
7475 { "Line", 0x2 },
7476 { "CD", 0x4 },
7477 },
7478};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007479
Takashi Iwai4953550a2009-06-30 15:28:30 +02007480#define alc883_capture_source alc882_capture_source
7481
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007482static struct hda_input_mux alc889_capture_source = {
7483 .num_items = 3,
7484 .items = {
7485 { "Front Mic", 0x0 },
7486 { "Mic", 0x3 },
7487 { "Line", 0x2 },
7488 },
7489};
7490
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007491static struct hda_input_mux mb5_capture_source = {
7492 .num_items = 3,
7493 .items = {
7494 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307495 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007496 { "CD", 0x4 },
7497 },
7498};
7499
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007500static struct hda_input_mux macmini3_capture_source = {
7501 .num_items = 2,
7502 .items = {
7503 { "Line", 0x2 },
7504 { "CD", 0x4 },
7505 },
7506};
7507
Takashi Iwai4953550a2009-06-30 15:28:30 +02007508static struct hda_input_mux alc883_3stack_6ch_intel = {
7509 .num_items = 4,
7510 .items = {
7511 { "Mic", 0x1 },
7512 { "Front Mic", 0x0 },
7513 { "Line", 0x2 },
7514 { "CD", 0x4 },
7515 },
7516};
7517
7518static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7519 .num_items = 2,
7520 .items = {
7521 { "Mic", 0x1 },
7522 { "Line", 0x2 },
7523 },
7524};
7525
7526static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7527 .num_items = 4,
7528 .items = {
7529 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007530 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007531 { "Line", 0x2 },
7532 { "CD", 0x4 },
7533 },
7534};
7535
7536static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7537 .num_items = 2,
7538 .items = {
7539 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007540 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007541 },
7542};
7543
7544static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7545 .num_items = 3,
7546 .items = {
7547 { "Mic", 0x0 },
7548 { "Front Mic", 0x1 },
7549 { "Line", 0x4 },
7550 },
7551};
7552
7553static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7554 .num_items = 2,
7555 .items = {
7556 { "Mic", 0x0 },
7557 { "Line", 0x2 },
7558 },
7559};
7560
7561static struct hda_input_mux alc889A_mb31_capture_source = {
7562 .num_items = 2,
7563 .items = {
7564 { "Mic", 0x0 },
7565 /* Front Mic (0x01) unused */
7566 { "Line", 0x2 },
7567 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007568 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007569 },
7570};
7571
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007572static struct hda_input_mux alc889A_imac91_capture_source = {
7573 .num_items = 2,
7574 .items = {
7575 { "Mic", 0x01 },
7576 { "Line", 0x2 }, /* Not sure! */
7577 },
7578};
7579
Takashi Iwai4953550a2009-06-30 15:28:30 +02007580/*
7581 * 2ch mode
7582 */
7583static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7584 { 2, NULL }
7585};
7586
Kailang Yangdf694da2005-12-05 19:42:22 +01007587/*
Kailang Yang272a5272007-05-14 11:00:38 +02007588 * 2ch mode
7589 */
7590static struct hda_verb alc882_3ST_ch2_init[] = {
7591 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7592 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7593 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7594 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7595 { } /* end */
7596};
7597
7598/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007599 * 4ch mode
7600 */
7601static struct hda_verb alc882_3ST_ch4_init[] = {
7602 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7603 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7604 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7605 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7606 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7607 { } /* end */
7608};
7609
7610/*
Kailang Yang272a5272007-05-14 11:00:38 +02007611 * 6ch mode
7612 */
7613static struct hda_verb alc882_3ST_ch6_init[] = {
7614 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7615 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7616 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7617 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7618 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7619 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7620 { } /* end */
7621};
7622
Takashi Iwai4953550a2009-06-30 15:28:30 +02007623static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007624 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007625 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007626 { 6, alc882_3ST_ch6_init },
7627};
7628
Takashi Iwai4953550a2009-06-30 15:28:30 +02007629#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7630
Kailang Yang272a5272007-05-14 11:00:38 +02007631/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307632 * 2ch mode
7633 */
7634static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7635 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7636 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7637 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7638 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7639 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7640 { } /* end */
7641};
7642
7643/*
7644 * 4ch mode
7645 */
7646static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7647 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7648 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7649 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7650 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7651 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7652 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7653 { } /* end */
7654};
7655
7656/*
7657 * 6ch mode
7658 */
7659static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7660 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7661 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7662 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7663 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7664 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7665 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7666 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7667 { } /* end */
7668};
7669
7670static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7671 { 2, alc883_3ST_ch2_clevo_init },
7672 { 4, alc883_3ST_ch4_clevo_init },
7673 { 6, alc883_3ST_ch6_clevo_init },
7674};
7675
7676
7677/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007678 * 6ch mode
7679 */
7680static struct hda_verb alc882_sixstack_ch6_init[] = {
7681 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7682 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7683 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7684 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7685 { } /* end */
7686};
7687
7688/*
7689 * 8ch mode
7690 */
7691static struct hda_verb alc882_sixstack_ch8_init[] = {
7692 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7693 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7694 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7695 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7696 { } /* end */
7697};
7698
7699static struct hda_channel_mode alc882_sixstack_modes[2] = {
7700 { 6, alc882_sixstack_ch6_init },
7701 { 8, alc882_sixstack_ch8_init },
7702};
7703
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007704
7705/* Macbook Air 2,1 */
7706
7707static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7708 { 2, NULL },
7709};
7710
Takashi Iwai87350ad2007-08-16 18:19:38 +02007711/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007712 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007713 */
7714
7715/*
7716 * 2ch mode
7717 */
7718static struct hda_verb alc885_mbp_ch2_init[] = {
7719 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7720 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7721 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7722 { } /* end */
7723};
7724
7725/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007726 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007727 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007728static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007729 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7730 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7731 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7732 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7733 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7734 { } /* end */
7735};
7736
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007737static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007738 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007739 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007740};
7741
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007742/*
7743 * 2ch
7744 * Speakers/Woofer/HP = Front
7745 * LineIn = Input
7746 */
7747static struct hda_verb alc885_mb5_ch2_init[] = {
7748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7750 { } /* end */
7751};
7752
7753/*
7754 * 6ch mode
7755 * Speakers/HP = Front
7756 * Woofer = LFE
7757 * LineIn = Surround
7758 */
7759static struct hda_verb alc885_mb5_ch6_init[] = {
7760 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7762 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7763 { } /* end */
7764};
7765
7766static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7767 { 2, alc885_mb5_ch2_init },
7768 { 6, alc885_mb5_ch6_init },
7769};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007770
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007771#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007772
7773/*
7774 * 2ch mode
7775 */
7776static struct hda_verb alc883_4ST_ch2_init[] = {
7777 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7778 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7779 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7780 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7781 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7782 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7783 { } /* end */
7784};
7785
7786/*
7787 * 4ch mode
7788 */
7789static struct hda_verb alc883_4ST_ch4_init[] = {
7790 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7791 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7792 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7793 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7794 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7795 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7796 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7797 { } /* end */
7798};
7799
7800/*
7801 * 6ch mode
7802 */
7803static struct hda_verb alc883_4ST_ch6_init[] = {
7804 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7805 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7806 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7807 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7808 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7809 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7810 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7811 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7812 { } /* end */
7813};
7814
7815/*
7816 * 8ch mode
7817 */
7818static struct hda_verb alc883_4ST_ch8_init[] = {
7819 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7820 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7821 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7822 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7823 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7824 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7825 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7826 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7827 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7828 { } /* end */
7829};
7830
7831static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7832 { 2, alc883_4ST_ch2_init },
7833 { 4, alc883_4ST_ch4_init },
7834 { 6, alc883_4ST_ch6_init },
7835 { 8, alc883_4ST_ch8_init },
7836};
7837
7838
7839/*
7840 * 2ch mode
7841 */
7842static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7843 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7844 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7845 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7846 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7847 { } /* end */
7848};
7849
7850/*
7851 * 4ch mode
7852 */
7853static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7854 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7855 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7856 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7857 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7858 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7859 { } /* end */
7860};
7861
7862/*
7863 * 6ch mode
7864 */
7865static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7866 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7867 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7868 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7869 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7870 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7871 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7872 { } /* end */
7873};
7874
7875static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7876 { 2, alc883_3ST_ch2_intel_init },
7877 { 4, alc883_3ST_ch4_intel_init },
7878 { 6, alc883_3ST_ch6_intel_init },
7879};
7880
7881/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007882 * 2ch mode
7883 */
7884static struct hda_verb alc889_ch2_intel_init[] = {
7885 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7886 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7887 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7888 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7889 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7890 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7891 { } /* end */
7892};
7893
7894/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007895 * 6ch mode
7896 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007897static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007898 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7899 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7900 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7901 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7902 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007903 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7904 { } /* end */
7905};
7906
7907/*
7908 * 8ch mode
7909 */
7910static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007911 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7912 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7913 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7914 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7915 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007916 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7917 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007918 { } /* end */
7919};
7920
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007921static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7922 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007923 { 6, alc889_ch6_intel_init },
7924 { 8, alc889_ch8_intel_init },
7925};
7926
7927/*
7928 * 6ch mode
7929 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007930static struct hda_verb alc883_sixstack_ch6_init[] = {
7931 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7932 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7933 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7934 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7935 { } /* end */
7936};
7937
7938/*
7939 * 8ch mode
7940 */
7941static struct hda_verb alc883_sixstack_ch8_init[] = {
7942 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7943 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7944 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7945 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7946 { } /* end */
7947};
7948
7949static struct hda_channel_mode alc883_sixstack_modes[2] = {
7950 { 6, alc883_sixstack_ch6_init },
7951 { 8, alc883_sixstack_ch8_init },
7952};
7953
7954
Linus Torvalds1da177e2005-04-16 15:20:36 -07007955/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7956 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7957 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007958static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007962 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007963 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7964 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007965 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7966 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007967 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007968 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7970 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7971 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7973 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007975 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007976 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7977 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007978 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007979 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007980 { } /* end */
7981};
7982
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007983/* Macbook Air 2,1 same control for HP and internal Speaker */
7984
7985static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7986 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7987 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7988 { }
7989};
7990
7991
Takashi Iwai87350ad2007-08-16 18:19:38 +02007992static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007993 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7994 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7996 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7997 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7999 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8001 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008002 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
8003 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008004 { } /* end */
8005};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008006
8007static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008008 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8009 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8011 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8012 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8013 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10308014 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8015 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09308016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8017 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8019 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008020 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
8021 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008022 { } /* end */
8023};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008024
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008025static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
8026 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8027 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8028 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8029 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8030 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8031 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
8032 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8033 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
8034 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8035 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008036 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008037 { } /* end */
8038};
8039
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008040static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008041 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8042 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008043 { } /* end */
8044};
8045
8046
Kailang Yangbdd148a2007-05-08 15:19:08 +02008047static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8048 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8049 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8050 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8051 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8052 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8053 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008055 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008056 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008057 { } /* end */
8058};
8059
Kailang Yang272a5272007-05-14 11:00:38 +02008060static struct snd_kcontrol_new alc882_targa_mixer[] = {
8061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8062 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8064 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8065 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8066 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8067 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8069 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008070 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008071 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8072 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008073 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008074 { } /* end */
8075};
8076
8077/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8078 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8079 */
8080static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8081 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8082 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8083 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8084 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8085 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8086 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8087 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8088 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8089 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8090 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008093 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008094 { } /* end */
8095};
8096
Takashi Iwai914759b2007-09-06 14:52:04 +02008097static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8098 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8099 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8102 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8103 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8104 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008106 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008107 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008108 { } /* end */
8109};
8110
Kailang Yangdf694da2005-12-05 19:42:22 +01008111static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8112 {
8113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8114 .name = "Channel Mode",
8115 .info = alc_ch_mode_info,
8116 .get = alc_ch_mode_get,
8117 .put = alc_ch_mode_put,
8118 },
8119 { } /* end */
8120};
8121
Takashi Iwai4953550a2009-06-30 15:28:30 +02008122static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008123 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008126 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008127 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8128 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008129 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008130 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8131 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008132 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008133 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8134 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008135
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008136 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008139 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008140 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008142 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008143 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008144 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008145 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008146 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008147 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008148 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008149 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008150 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008151 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008152 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008153 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008154 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8155 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008156 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008157 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8158 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008159 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008160 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8161 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8162 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8163 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8164 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008165 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008166 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008167
8168 /* FIXME: use matrix-type input source selection */
8169 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008170 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008171 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008172 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008174 /* ADC2: mute amp left and right */
8175 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008176 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008177 /* ADC3: mute amp left and right */
8178 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008179 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008180
8181 { }
8182};
8183
Takashi Iwai4953550a2009-06-30 15:28:30 +02008184static struct hda_verb alc882_adc1_init_verbs[] = {
8185 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8186 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8187 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8190 /* ADC1: mute amp left and right */
8191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8192 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8193 { }
8194};
8195
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008196static struct hda_verb alc882_eapd_verbs[] = {
8197 /* change to EAPD mode */
8198 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008199 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008200 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008201};
8202
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008203static struct hda_verb alc889_eapd_verbs[] = {
8204 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8205 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8206 { }
8207};
8208
Wu Fengguang6732bd02009-07-30 09:19:14 +02008209static struct hda_verb alc_hp15_unsol_verbs[] = {
8210 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8212 {}
8213};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008214
8215static struct hda_verb alc885_init_verbs[] = {
8216 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008219 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008222 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008225 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008226 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8227 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008228
8229 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008231 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8232 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8233 /* Front Pin: output 0 (0x0c) */
8234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8235 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8236 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8237 /* Rear Pin: output 1 (0x0d) */
8238 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8239 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8240 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8241 /* CLFE Pin: output 2 (0x0e) */
8242 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8243 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8244 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8245 /* Side Pin: output 3 (0x0f) */
8246 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8247 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8248 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8249 /* Mic (rear) pin: input vref at 80% */
8250 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8251 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8252 /* Front Mic pin: input vref at 80% */
8253 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8254 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8255 /* Line In pin: input */
8256 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8257 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8258
8259 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8260 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008261 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008262 /* Input mixer2 */
8263 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008264 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008266 /* ADC2: mute amp left and right */
8267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8268 /* ADC3: mute amp left and right */
8269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8270
8271 { }
8272};
8273
8274static struct hda_verb alc885_init_input_verbs[] = {
8275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8278 { }
8279};
8280
8281
8282/* Unmute Selector 24h and set the default input to front mic */
8283static struct hda_verb alc889_init_input_verbs[] = {
8284 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8286 { }
8287};
8288
8289
Takashi Iwai4953550a2009-06-30 15:28:30 +02008290#define alc883_init_verbs alc882_base_init_verbs
8291
Tobin Davis9102cd12006-12-15 10:02:12 +01008292/* Mac Pro test */
8293static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8294 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8295 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8296 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8297 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8298 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008299 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008300 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8301 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008302 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008303 { } /* end */
8304};
8305
8306static struct hda_verb alc882_macpro_init_verbs[] = {
8307 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8311 /* Front Pin: output 0 (0x0c) */
8312 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8313 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8314 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8315 /* Front Mic pin: input vref at 80% */
8316 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8318 /* Speaker: output */
8319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8321 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8322 /* Headphone output (output 0 - 0x0c) */
8323 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8324 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8325 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8326
8327 /* FIXME: use matrix-type input source selection */
8328 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8329 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8334 /* Input mixer2 */
8335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8339 /* Input mixer3 */
8340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8344 /* ADC1: mute amp left and right */
8345 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8346 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8347 /* ADC2: mute amp left and right */
8348 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8349 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8350 /* ADC3: mute amp left and right */
8351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8352 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8353
8354 { }
8355};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008356
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008357/* Macbook 5,1 */
8358static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008359 /* DACs */
8360 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8361 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8362 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8363 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008364 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008368 /* Surround mixer */
8369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8371 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8372 /* LFE mixer */
8373 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8376 /* HP mixer */
8377 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8378 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8380 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008383 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8384 /* LFE Pin (0x0e) */
8385 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8386 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8387 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8388 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8390 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008391 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308392 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008393 /* Front Mic pin: input vref at 80% */
8394 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8396 /* Line In pin */
8397 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8398 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8399
Alex Murrayb8f171e2010-06-14 12:08:43 +09308400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008403 { }
8404};
8405
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008406/* Macmini 3,1 */
8407static struct hda_verb alc885_macmini3_init_verbs[] = {
8408 /* DACs */
8409 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8410 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8411 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8412 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8413 /* Front mixer */
8414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8417 /* Surround mixer */
8418 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8419 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8420 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8421 /* LFE mixer */
8422 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8423 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8424 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8425 /* HP mixer */
8426 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8427 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8428 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8429 /* Front Pin (0x0c) */
8430 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8432 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8433 /* LFE Pin (0x0e) */
8434 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8436 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8437 /* HP Pin (0x0f) */
8438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8439 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8440 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8441 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8442 /* Line In pin */
8443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8445
8446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8450 { }
8451};
8452
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008453
8454static struct hda_verb alc885_mba21_init_verbs[] = {
8455 /*Internal and HP Speaker Mixer*/
8456 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8459 /*Internal Speaker Pin (0x0c)*/
8460 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8461 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8462 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8463 /* HP Pin: output 0 (0x0e) */
8464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8466 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8467 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8468 /* Line in (is hp when jack connected)*/
8469 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8471
8472 { }
8473 };
8474
8475
Takashi Iwai87350ad2007-08-16 18:19:38 +02008476/* Macbook Pro rev3 */
8477static struct hda_verb alc885_mbp3_init_verbs[] = {
8478 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8480 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8482 /* Rear mixer */
8483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008486 /* HP mixer */
8487 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8488 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8489 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008490 /* Front Pin: output 0 (0x0c) */
8491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8492 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8493 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008494 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008495 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8497 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008498 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8499 /* Mic (rear) pin: input vref at 80% */
8500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8501 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8502 /* Front Mic pin: input vref at 80% */
8503 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8504 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8505 /* Line In pin: use output 1 when in LineOut mode */
8506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8508 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8509
8510 /* FIXME: use matrix-type input source selection */
8511 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8512 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8513 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8514 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8517 /* Input mixer2 */
8518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8519 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8522 /* Input mixer3 */
8523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8527 /* ADC1: mute amp left and right */
8528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8529 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8530 /* ADC2: mute amp left and right */
8531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8532 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8533 /* ADC3: mute amp left and right */
8534 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8535 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8536
8537 { }
8538};
8539
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008540/* iMac 9,1 */
8541static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008542 /* Internal Speaker Pin (0x0c) */
8543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8545 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8546 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8548 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8549 /* HP Pin: Rear */
8550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8551 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8552 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8554 /* Line in Rear */
8555 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8556 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8557 /* Front Mic pin: input vref at 80% */
8558 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008560 /* Rear mixer */
8561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8562 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008564 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8566 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8567 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8568 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008569 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008573 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8577 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008578 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008583 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008584 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8585 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008586 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008587 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8588 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008589 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008590 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8591 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008592 { }
8593};
8594
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008595/* iMac 24 mixer. */
8596static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8597 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8598 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8599 { } /* end */
8600};
8601
8602/* iMac 24 init verbs. */
8603static struct hda_verb alc885_imac24_init_verbs[] = {
8604 /* Internal speakers: output 0 (0x0c) */
8605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8607 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8608 /* Internal speakers: output 0 (0x0c) */
8609 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8610 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8611 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8612 /* Headphone: output 0 (0x0c) */
8613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8614 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8615 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8616 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8617 /* Front Mic: input vref at 80% */
8618 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8619 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8620 { }
8621};
8622
8623/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008624static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008625{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008626 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008627
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008628 spec->autocfg.hp_pins[0] = 0x14;
8629 spec->autocfg.speaker_pins[0] = 0x18;
8630 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008631}
8632
Takashi Iwai9d54f082010-02-22 08:34:40 +01008633#define alc885_mb5_setup alc885_imac24_setup
8634#define alc885_macmini3_setup alc885_imac24_setup
8635
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008636/* Macbook Air 2,1 */
8637static void alc885_mba21_setup(struct hda_codec *codec)
8638{
8639 struct alc_spec *spec = codec->spec;
8640
8641 spec->autocfg.hp_pins[0] = 0x14;
8642 spec->autocfg.speaker_pins[0] = 0x18;
8643}
8644
8645
8646
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008647static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008648{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008649 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008650
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008651 spec->autocfg.hp_pins[0] = 0x15;
8652 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008653}
8654
Takashi Iwai9d54f082010-02-22 08:34:40 +01008655static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308656{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008657 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308658
Takashi Iwai9d54f082010-02-22 08:34:40 +01008659 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008660 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008661 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008662}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008663
Kailang Yang272a5272007-05-14 11:00:38 +02008664static struct hda_verb alc882_targa_verbs[] = {
8665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8667
8668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8669 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008670
Kailang Yang272a5272007-05-14 11:00:38 +02008671 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8672 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8673 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8674
8675 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008676 { } /* end */
8677};
8678
8679/* toggle speaker-output according to the hp-jack state */
8680static void alc882_targa_automute(struct hda_codec *codec)
8681{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008682 struct alc_spec *spec = codec->spec;
8683 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008684 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008685 spec->jack_present ? 1 : 3);
8686}
8687
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008688static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008689{
8690 struct alc_spec *spec = codec->spec;
8691
8692 spec->autocfg.hp_pins[0] = 0x14;
8693 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008694}
8695
8696static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8697{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008698 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008699 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008700}
8701
8702static struct hda_verb alc882_asus_a7j_verbs[] = {
8703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8705
8706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8708 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008709
Kailang Yang272a5272007-05-14 11:00:38 +02008710 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8711 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8712 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8713
8714 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8715 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8716 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8717 { } /* end */
8718};
8719
Takashi Iwai914759b2007-09-06 14:52:04 +02008720static struct hda_verb alc882_asus_a7m_verbs[] = {
8721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8723
8724 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8726 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008727
Takashi Iwai914759b2007-09-06 14:52:04 +02008728 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8729 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8730 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8731
8732 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8733 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8734 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8735 { } /* end */
8736};
8737
Tobin Davis9102cd12006-12-15 10:02:12 +01008738static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8739{
8740 unsigned int gpiostate, gpiomask, gpiodir;
8741
8742 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8743 AC_VERB_GET_GPIO_DATA, 0);
8744
8745 if (!muted)
8746 gpiostate |= (1 << pin);
8747 else
8748 gpiostate &= ~(1 << pin);
8749
8750 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8751 AC_VERB_GET_GPIO_MASK, 0);
8752 gpiomask |= (1 << pin);
8753
8754 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8755 AC_VERB_GET_GPIO_DIRECTION, 0);
8756 gpiodir |= (1 << pin);
8757
8758
8759 snd_hda_codec_write(codec, codec->afg, 0,
8760 AC_VERB_SET_GPIO_MASK, gpiomask);
8761 snd_hda_codec_write(codec, codec->afg, 0,
8762 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8763
8764 msleep(1);
8765
8766 snd_hda_codec_write(codec, codec->afg, 0,
8767 AC_VERB_SET_GPIO_DATA, gpiostate);
8768}
8769
Takashi Iwai7debbe52007-08-16 15:01:03 +02008770/* set up GPIO at initialization */
8771static void alc885_macpro_init_hook(struct hda_codec *codec)
8772{
8773 alc882_gpio_mute(codec, 0, 0);
8774 alc882_gpio_mute(codec, 1, 0);
8775}
8776
8777/* set up GPIO and update auto-muting at initialization */
8778static void alc885_imac24_init_hook(struct hda_codec *codec)
8779{
8780 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008781 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008782}
8783
Kailang Yangdf694da2005-12-05 19:42:22 +01008784/*
8785 * generic initialization of ADC, input mixers and output mixers
8786 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008787static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008788 /*
8789 * Unmute ADC0-2 and set the default input to mic-in
8790 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008791 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8792 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8793 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8794 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8795
Kailang Yangdf694da2005-12-05 19:42:22 +01008796 /*
8797 * Set up output mixers (0x0c - 0x0f)
8798 */
8799 /* set vol=0 to output mixers */
8800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8801 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8802 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8803 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8804 /* set up input amps for analog loopback */
8805 /* Amp Indices: DAC = 0, mixer = 1 */
8806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8810 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8812 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8814 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8815 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8816
8817 /* FIXME: use matrix-type input source selection */
8818 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008819 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008820 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008821 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008823 { }
8824};
8825
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008826/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8827static struct hda_verb alc889A_mb31_ch2_init[] = {
8828 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8829 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8832 { } /* end */
8833};
8834
8835/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8836static struct hda_verb alc889A_mb31_ch4_init[] = {
8837 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8839 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8840 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8841 { } /* end */
8842};
8843
8844/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8845static struct hda_verb alc889A_mb31_ch5_init[] = {
8846 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8847 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8848 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8850 { } /* end */
8851};
8852
8853/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8854static struct hda_verb alc889A_mb31_ch6_init[] = {
8855 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8856 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8857 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8858 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8859 { } /* end */
8860};
8861
8862static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8863 { 2, alc889A_mb31_ch2_init },
8864 { 4, alc889A_mb31_ch4_init },
8865 { 5, alc889A_mb31_ch5_init },
8866 { 6, alc889A_mb31_ch6_init },
8867};
8868
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008869static struct hda_verb alc883_medion_eapd_verbs[] = {
8870 /* eanable EAPD on medion laptop */
8871 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8872 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8873 { }
8874};
8875
Takashi Iwai4953550a2009-06-30 15:28:30 +02008876#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008877
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008878static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8881 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8882 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8883 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8884 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8885 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008887 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008888 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8889 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008890 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008891 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008892 { } /* end */
8893};
8894
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008895static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008896 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8897 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8898 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8899 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008901 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008903 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008904 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008905 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008906 { } /* end */
8907};
8908
Jiang zhefb97dc62008-03-06 11:07:11 +01008909static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8910 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8911 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8912 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8913 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008915 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008916 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008917 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008918 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008919 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008920 { } /* end */
8921};
8922
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008923static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8924 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8925 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8926 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8927 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8928 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8929 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8930 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8931 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008932 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008933 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8934 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008935 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008936 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008937 { } /* end */
8938};
8939
8940static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8941 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8942 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8943 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8944 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8945 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8946 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8947 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8948 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8949 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008955 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8957 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008958 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008960 { } /* end */
8961};
8962
Jiang zhe17bba1b2008-06-04 12:11:07 +02008963static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8965 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8966 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8967 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8968 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8969 HDA_OUTPUT),
8970 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8971 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8972 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8973 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8974 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8975 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8976 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8977 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8978 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008979 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8981 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008982 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008983 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008984 { } /* end */
8985};
8986
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008987static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8988 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8989 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8990 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8991 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8992 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8993 HDA_OUTPUT),
8994 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8995 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8996 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8997 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8998 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9000 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9001 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9002 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009003 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
9005 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009006 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009007 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9008 { } /* end */
9009};
9010
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009011static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02009012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009013 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009014 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009015 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009016 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9017 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009018 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9019 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9021 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9022 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009026 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009027 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9028 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009029 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009030 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009031 { } /* end */
9032};
9033
Sasha Alexandrc2592492009-06-16 14:52:54 -04009034static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009035 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009036 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009037 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009038 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9040 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9041 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9042 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9043 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9044 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9045 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9046 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9047 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9048 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009050 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009052 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009053};
Kailang Yangccc656c2006-10-17 12:32:26 +02009054
Sasha Alexandrc2592492009-06-16 14:52:54 -04009055static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009058 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009059 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009060 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9061 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009063 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009064 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009065 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009066 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009067 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009068 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009069};
Kailang Yangccc656c2006-10-17 12:32:26 +02009070
Takashi Iwaib99dba32009-09-17 18:23:00 +02009071static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9072 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9073 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009074 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009075 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009076 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009077 { } /* end */
9078};
9079
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009080static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9081 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9082 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009083 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9084 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009085 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009087 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009088 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009089 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009090};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009091
Kailang Yang272a5272007-05-14 11:00:38 +02009092static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9093 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9094 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9096 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9097 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009100 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9101 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009102 { } /* end */
9103};
9104
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009105static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9106 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9107 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9108 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9109 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9110 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9111 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9112 { } /* end */
9113};
9114
9115static struct hda_verb alc883_medion_wim2160_verbs[] = {
9116 /* Unmute front mixer */
9117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9118 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9119
9120 /* Set speaker pin to front mixer */
9121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9122
9123 /* Init headphone pin */
9124 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9126 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9127 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9128
9129 { } /* end */
9130};
9131
9132/* toggle speaker-output according to the hp-jack state */
9133static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9134{
9135 struct alc_spec *spec = codec->spec;
9136
9137 spec->autocfg.hp_pins[0] = 0x1a;
9138 spec->autocfg.speaker_pins[0] = 0x15;
9139}
9140
Tobin Davis2880a862007-08-07 11:50:26 +02009141static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009142 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9143 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009144 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009145 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9146 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009147 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009148 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009150 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009151};
Tobin Davis2880a862007-08-07 11:50:26 +02009152
Tony Vroond2fd4b02009-06-21 00:40:10 +01009153static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9154 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009155 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009158 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9159 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9160 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009161 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009162 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9163 { } /* end */
9164};
9165
Kailang Yange2757d52008-08-26 13:17:46 +02009166static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9167 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9168 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9169 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9170 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9171 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9172 0x0d, 1, 0x0, HDA_OUTPUT),
9173 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9174 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9175 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9176 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9177 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009178 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9179 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9180 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9181 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009183 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9185 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009186 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009187 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009188 { } /* end */
9189};
9190
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009191static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9192 /* Output mixers */
9193 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9194 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9195 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9196 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9197 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9198 HDA_OUTPUT),
9199 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9200 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9201 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9202 /* Output switches */
9203 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9204 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9205 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9206 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009207 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9208 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009209 /* Input mixers */
9210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9214 { } /* end */
9215};
9216
Guido Günther3e1647c2009-06-05 00:47:26 +02009217static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9218 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9219 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9220 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009222 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9224 { } /* end */
9225};
9226
Kailang Yange2757d52008-08-26 13:17:46 +02009227static struct hda_bind_ctls alc883_bind_cap_vol = {
9228 .ops = &snd_hda_bind_vol,
9229 .values = {
9230 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9231 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9232 0
9233 },
9234};
9235
9236static struct hda_bind_ctls alc883_bind_cap_switch = {
9237 .ops = &snd_hda_bind_sw,
9238 .values = {
9239 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9240 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9241 0
9242 },
9243};
9244
9245static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9246 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9247 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9248 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9250 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009252 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009254 { } /* end */
9255};
9256
9257static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009258 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9259 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9260 {
9261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9262 /* .name = "Capture Source", */
9263 .name = "Input Source",
9264 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009265 .info = alc_mux_enum_info,
9266 .get = alc_mux_enum_get,
9267 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009268 },
9269 { } /* end */
9270};
9271
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009272static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9273 {
9274 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9275 .name = "Channel Mode",
9276 .info = alc_ch_mode_info,
9277 .get = alc_ch_mode_get,
9278 .put = alc_ch_mode_put,
9279 },
9280 { } /* end */
9281};
9282
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009283/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009284static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009285{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009286 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009287
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009288 spec->autocfg.hp_pins[0] = 0x15;
9289 spec->autocfg.speaker_pins[0] = 0x14;
9290 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009291}
9292
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009293static struct hda_verb alc883_mitac_verbs[] = {
9294 /* HP */
9295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9297 /* Subwoofer */
9298 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9299 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9300
9301 /* enable unsolicited event */
9302 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9303 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9304
9305 { } /* end */
9306};
9307
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309308static struct hda_verb alc883_clevo_m540r_verbs[] = {
9309 /* HP */
9310 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9311 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9312 /* Int speaker */
9313 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9314
9315 /* enable unsolicited event */
9316 /*
9317 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9318 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9319 */
9320
9321 { } /* end */
9322};
9323
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009324static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009325 /* HP */
9326 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9327 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9328 /* Int speaker */
9329 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9331
9332 /* enable unsolicited event */
9333 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009334 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009335
9336 { } /* end */
9337};
9338
Jiang zhefb97dc62008-03-06 11:07:11 +01009339static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9340 /* HP */
9341 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9343 /* Subwoofer */
9344 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9345 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9346
9347 /* enable unsolicited event */
9348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9349
9350 { } /* end */
9351};
9352
Sasha Alexandrc2592492009-06-16 14:52:54 -04009353static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9356
9357 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9358 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009359
David Heidelberger64a8be72009-06-08 16:15:18 +02009360/* Connect Line-Out side jack (SPDIF) to Side */
9361 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9362 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9363 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9364/* Connect Mic jack to CLFE */
9365 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9367 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9368/* Connect Line-in jack to Surround */
9369 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9370 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9371 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9372/* Connect HP out jack to Front */
9373 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9374 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9375 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009376
9377 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009378
9379 { } /* end */
9380};
9381
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009382static struct hda_verb alc883_lenovo_101e_verbs[] = {
9383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9384 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9385 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9386 { } /* end */
9387};
9388
Kailang Yang272a5272007-05-14 11:00:38 +02009389static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9390 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9392 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9393 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9394 { } /* end */
9395};
9396
9397static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9400 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9401 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9402 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9403 { } /* end */
9404};
9405
Kailang Yang189609a2007-08-20 11:31:23 +02009406static struct hda_verb alc883_haier_w66_verbs[] = {
9407 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9409
9410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9411
9412 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9413 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9414 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9415 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9416 { } /* end */
9417};
9418
Kailang Yange2757d52008-08-26 13:17:46 +02009419static struct hda_verb alc888_lenovo_sky_verbs[] = {
9420 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9421 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9422 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9423 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9424 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9425 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9426 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9427 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9428 { } /* end */
9429};
9430
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009431static struct hda_verb alc888_6st_dell_verbs[] = {
9432 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9433 { }
9434};
9435
Guido Günther3e1647c2009-06-05 00:47:26 +02009436static struct hda_verb alc883_vaiott_verbs[] = {
9437 /* HP */
9438 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9439 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9440
9441 /* enable unsolicited event */
9442 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9443
9444 { } /* end */
9445};
9446
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009447static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009448{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009449 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009450
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009451 spec->autocfg.hp_pins[0] = 0x1b;
9452 spec->autocfg.speaker_pins[0] = 0x14;
9453 spec->autocfg.speaker_pins[1] = 0x16;
9454 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009455}
9456
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009457static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009458 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009459 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9460 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009461 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009462 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009463};
9464
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009465/*
9466 * 2ch mode
9467 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009468static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009469 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9470 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9471 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9472 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009473 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009474};
9475
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009476/*
9477 * 4ch mode
9478 */
9479static struct hda_verb alc888_3st_hp_4ch_init[] = {
9480 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9481 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9482 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9483 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9484 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9485 { } /* end */
9486};
9487
9488/*
9489 * 6ch mode
9490 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009491static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009492 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9493 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009494 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009495 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9496 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009497 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9498 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009499};
9500
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009501static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009502 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009503 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009504 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009505};
9506
Kailang Yang272a5272007-05-14 11:00:38 +02009507/* toggle front-jack and RCA according to the hp-jack state */
9508static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9509{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009510 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009511
Takashi Iwai47fd8302007-08-10 17:11:07 +02009512 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9513 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9514 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9515 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009516}
9517
9518/* toggle RCA according to the front-jack state */
9519static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9520{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009521 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009522
Takashi Iwai47fd8302007-08-10 17:11:07 +02009523 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9524 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009525}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009526
Kailang Yang272a5272007-05-14 11:00:38 +02009527static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9528 unsigned int res)
9529{
9530 if ((res >> 26) == ALC880_HP_EVENT)
9531 alc888_lenovo_ms7195_front_automute(codec);
9532 if ((res >> 26) == ALC880_FRONT_EVENT)
9533 alc888_lenovo_ms7195_rca_automute(codec);
9534}
9535
Kailang Yang272a5272007-05-14 11:00:38 +02009536/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009537static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009538{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009539 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009540
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009541 spec->autocfg.hp_pins[0] = 0x14;
9542 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009543}
9544
Kailang Yangccc656c2006-10-17 12:32:26 +02009545/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009546#define alc883_targa_init_hook alc882_targa_init_hook
9547#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009548
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009549static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009550{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009551 struct alc_spec *spec = codec->spec;
9552
9553 spec->autocfg.hp_pins[0] = 0x15;
9554 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009555}
9556
9557static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9558{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009559 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009560 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009561}
9562
9563static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009564 unsigned int res)
9565{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009566 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009567 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009568 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009569 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009570 default:
9571 alc_automute_amp_unsol_event(codec, res);
9572 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009573 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009574}
9575
Jiang zhefb97dc62008-03-06 11:07:11 +01009576/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009577static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009578{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009579 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009580
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009581 spec->autocfg.hp_pins[0] = 0x14;
9582 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009583}
9584
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009585static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009586{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009587 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009588
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009589 spec->autocfg.hp_pins[0] = 0x1b;
9590 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009591}
9592
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009593static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9594{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009595 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009596
Takashi Iwai47fd8302007-08-10 17:11:07 +02009597 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9598 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009599}
9600
9601static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9602{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009603 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009604
Takashi Iwai47fd8302007-08-10 17:11:07 +02009605 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9606 HDA_AMP_MUTE, bits);
9607 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9608 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009609}
9610
9611static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9612 unsigned int res)
9613{
9614 if ((res >> 26) == ALC880_HP_EVENT)
9615 alc883_lenovo_101e_all_automute(codec);
9616 if ((res >> 26) == ALC880_FRONT_EVENT)
9617 alc883_lenovo_101e_ispeaker_automute(codec);
9618}
9619
Takashi Iwai676a9b52007-08-16 15:23:35 +02009620/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009621static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009622{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009623 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009624
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009625 spec->autocfg.hp_pins[0] = 0x14;
9626 spec->autocfg.speaker_pins[0] = 0x15;
9627 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009628}
9629
Kailang Yangd1a991a2007-08-15 16:21:59 +02009630static struct hda_verb alc883_acer_eapd_verbs[] = {
9631 /* HP Pin: output 0 (0x0c) */
9632 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9633 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9634 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9635 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9637 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009638 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009639 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9640 /* eanable EAPD on medion laptop */
9641 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9642 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009643 /* enable unsolicited event */
9644 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009645 { }
9646};
9647
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009648static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009649{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009650 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009651
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009652 spec->autocfg.hp_pins[0] = 0x1b;
9653 spec->autocfg.speaker_pins[0] = 0x14;
9654 spec->autocfg.speaker_pins[1] = 0x15;
9655 spec->autocfg.speaker_pins[2] = 0x16;
9656 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009657}
9658
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009659static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009660{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009661 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009662
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009663 spec->autocfg.hp_pins[0] = 0x1b;
9664 spec->autocfg.speaker_pins[0] = 0x14;
9665 spec->autocfg.speaker_pins[1] = 0x15;
9666 spec->autocfg.speaker_pins[2] = 0x16;
9667 spec->autocfg.speaker_pins[3] = 0x17;
9668 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009669}
9670
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009671static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009672{
9673 struct alc_spec *spec = codec->spec;
9674
9675 spec->autocfg.hp_pins[0] = 0x15;
9676 spec->autocfg.speaker_pins[0] = 0x14;
9677 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009678}
9679
Kailang Yange2757d52008-08-26 13:17:46 +02009680static struct hda_verb alc888_asus_m90v_verbs[] = {
9681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9682 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9683 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9684 /* enable unsolicited event */
9685 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9686 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9687 { } /* end */
9688};
9689
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009690static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009691{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009692 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009693
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009694 spec->autocfg.hp_pins[0] = 0x1b;
9695 spec->autocfg.speaker_pins[0] = 0x14;
9696 spec->autocfg.speaker_pins[1] = 0x15;
9697 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009698 spec->ext_mic.pin = 0x18;
9699 spec->int_mic.pin = 0x19;
9700 spec->ext_mic.mux_idx = 0;
9701 spec->int_mic.mux_idx = 1;
9702 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009703}
9704
9705static struct hda_verb alc888_asus_eee1601_verbs[] = {
9706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9707 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9709 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9711 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9712 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9713 /* enable unsolicited event */
9714 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9715 { } /* end */
9716};
9717
Kailang Yange2757d52008-08-26 13:17:46 +02009718static void alc883_eee1601_inithook(struct hda_codec *codec)
9719{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009720 struct alc_spec *spec = codec->spec;
9721
9722 spec->autocfg.hp_pins[0] = 0x14;
9723 spec->autocfg.speaker_pins[0] = 0x1b;
9724 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009725}
9726
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009727static struct hda_verb alc889A_mb31_verbs[] = {
9728 /* Init rear pin (used as headphone output) */
9729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9730 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9731 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9732 /* Init line pin (used as output in 4ch and 6ch mode) */
9733 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9734 /* Init line 2 pin (used as headphone out by default) */
9735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9736 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9737 { } /* end */
9738};
9739
9740/* Mute speakers according to the headphone jack state */
9741static void alc889A_mb31_automute(struct hda_codec *codec)
9742{
9743 unsigned int present;
9744
9745 /* Mute only in 2ch or 4ch mode */
9746 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9747 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009748 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009749 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9750 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9751 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9752 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9753 }
9754}
9755
9756static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9757{
9758 if ((res >> 26) == ALC880_HP_EVENT)
9759 alc889A_mb31_automute(codec);
9760}
9761
Takashi Iwai4953550a2009-06-30 15:28:30 +02009762
Takashi Iwaicb53c622007-08-10 17:21:45 +02009763#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009764#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009765#endif
9766
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009767/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009768#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9769#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9770#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9771#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9772
9773static hda_nid_t alc883_slave_dig_outs[] = {
9774 ALC1200_DIGOUT_NID, 0,
9775};
9776
9777static hda_nid_t alc1200_slave_dig_outs[] = {
9778 ALC883_DIGOUT_NID, 0,
9779};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009780
9781/*
9782 * configuration and preset
9783 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009784static const char *alc882_models[ALC882_MODEL_LAST] = {
9785 [ALC882_3ST_DIG] = "3stack-dig",
9786 [ALC882_6ST_DIG] = "6stack-dig",
9787 [ALC882_ARIMA] = "arima",
9788 [ALC882_W2JC] = "w2jc",
9789 [ALC882_TARGA] = "targa",
9790 [ALC882_ASUS_A7J] = "asus-a7j",
9791 [ALC882_ASUS_A7M] = "asus-a7m",
9792 [ALC885_MACPRO] = "macpro",
9793 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009794 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009795 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009796 [ALC885_MBP3] = "mbp3",
9797 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009798 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009799 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009800 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9801 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009802 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009803 [ALC883_TARGA_DIG] = "targa-dig",
9804 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009805 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009806 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009807 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009808 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009809 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009810 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009811 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009812 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009813 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009814 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009815 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009816 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9817 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009818 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009819 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009820 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009821 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009822 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309823 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009824 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009825 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009826 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009827 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009828 [ALC889A_INTEL] = "intel-alc889a",
9829 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009830 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009831 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009832 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009833 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009834};
9835
Takashi Iwai4953550a2009-06-30 15:28:30 +02009836static struct snd_pci_quirk alc882_cfg_tbl[] = {
9837 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9838
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009839 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009840 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009841 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009842 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9843 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009844 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009845 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9846 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009847 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009848 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009849 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9850 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009851 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9852 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009853 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9854 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009855 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009856 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009857 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009858 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009859 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9860 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009861 /* default Acer -- disabled as it causes more problems.
9862 * model=auto should work fine now
9863 */
9864 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009865
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009866 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009867
Tobin Davisfebe3372007-06-12 11:27:46 +02009868 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009869 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9870 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009871 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009872 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009873 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009874
9875 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9876 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9877 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009878 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009879 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9880 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9881 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009882 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009883 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009884 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009885 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009886
9887 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009888 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009889 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009890 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009891 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9892 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009893 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009894 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009895 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9896
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009897 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9898 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9899 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009900 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009901 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009902 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009903 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009904 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009905 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9906 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9907 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9908 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9909 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9910 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009911 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009912 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9913 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9914 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009915 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009916 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009917 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9918 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009919 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009920 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009921 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009922 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009923 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009924 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009925 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009926 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009927 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009928
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009929 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009930 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009931 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9932 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309933 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009934 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009935 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009936 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009937 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009938 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009939 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009940 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009941 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009942 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009943 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009944 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9945 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009946 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009947 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009948 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009949 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009950
Jiang zhe17bba1b2008-06-04 12:11:07 +02009951 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9952 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009953 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009954 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9955 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9956 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009957 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009958
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009959 {}
9960};
9961
Takashi Iwai4953550a2009-06-30 15:28:30 +02009962/* codec SSID table for Intel Mac */
9963static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9964 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9965 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9966 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9967 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9968 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9969 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9970 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009971 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009972 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009973 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009974 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009975 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9976 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9977 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009978 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009979 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009980 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009981 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9982 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009983 */
9984 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009985 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009986 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009987 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009988};
9989
Takashi Iwai4953550a2009-06-30 15:28:30 +02009990static struct alc_config_preset alc882_presets[] = {
9991 [ALC882_3ST_DIG] = {
9992 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009993 .init_verbs = { alc882_base_init_verbs,
9994 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009995 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9996 .dac_nids = alc882_dac_nids,
9997 .dig_out_nid = ALC882_DIGOUT_NID,
9998 .dig_in_nid = ALC882_DIGIN_NID,
9999 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10000 .channel_mode = alc882_ch_modes,
10001 .need_dac_fix = 1,
10002 .input_mux = &alc882_capture_source,
10003 },
10004 [ALC882_6ST_DIG] = {
10005 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010006 .init_verbs = { alc882_base_init_verbs,
10007 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010008 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10009 .dac_nids = alc882_dac_nids,
10010 .dig_out_nid = ALC882_DIGOUT_NID,
10011 .dig_in_nid = ALC882_DIGIN_NID,
10012 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10013 .channel_mode = alc882_sixstack_modes,
10014 .input_mux = &alc882_capture_source,
10015 },
10016 [ALC882_ARIMA] = {
10017 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010018 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10019 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010020 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10021 .dac_nids = alc882_dac_nids,
10022 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10023 .channel_mode = alc882_sixstack_modes,
10024 .input_mux = &alc882_capture_source,
10025 },
10026 [ALC882_W2JC] = {
10027 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010028 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10029 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010030 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10031 .dac_nids = alc882_dac_nids,
10032 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10033 .channel_mode = alc880_threestack_modes,
10034 .need_dac_fix = 1,
10035 .input_mux = &alc882_capture_source,
10036 .dig_out_nid = ALC882_DIGOUT_NID,
10037 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010038 [ALC885_MBA21] = {
10039 .mixers = { alc885_mba21_mixer },
10040 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
10041 .num_dacs = 2,
10042 .dac_nids = alc882_dac_nids,
10043 .channel_mode = alc885_mba21_ch_modes,
10044 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10045 .input_mux = &alc882_capture_source,
10046 .unsol_event = alc_automute_amp_unsol_event,
10047 .setup = alc885_mba21_setup,
10048 .init_hook = alc_automute_amp,
10049 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010050 [ALC885_MBP3] = {
10051 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10052 .init_verbs = { alc885_mbp3_init_verbs,
10053 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010054 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010055 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010056 .hp_nid = 0x04,
10057 .channel_mode = alc885_mbp_4ch_modes,
10058 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010059 .input_mux = &alc882_capture_source,
10060 .dig_out_nid = ALC882_DIGOUT_NID,
10061 .dig_in_nid = ALC882_DIGIN_NID,
10062 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010063 .setup = alc885_mbp3_setup,
10064 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010065 },
10066 [ALC885_MB5] = {
10067 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10068 .init_verbs = { alc885_mb5_init_verbs,
10069 alc880_gpio1_init_verbs },
10070 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10071 .dac_nids = alc882_dac_nids,
10072 .channel_mode = alc885_mb5_6ch_modes,
10073 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10074 .input_mux = &mb5_capture_source,
10075 .dig_out_nid = ALC882_DIGOUT_NID,
10076 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010077 .unsol_event = alc_automute_amp_unsol_event,
10078 .setup = alc885_mb5_setup,
10079 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010080 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010081 [ALC885_MACMINI3] = {
10082 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10083 .init_verbs = { alc885_macmini3_init_verbs,
10084 alc880_gpio1_init_verbs },
10085 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10086 .dac_nids = alc882_dac_nids,
10087 .channel_mode = alc885_macmini3_6ch_modes,
10088 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10089 .input_mux = &macmini3_capture_source,
10090 .dig_out_nid = ALC882_DIGOUT_NID,
10091 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010092 .unsol_event = alc_automute_amp_unsol_event,
10093 .setup = alc885_macmini3_setup,
10094 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010095 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010096 [ALC885_MACPRO] = {
10097 .mixers = { alc882_macpro_mixer },
10098 .init_verbs = { alc882_macpro_init_verbs },
10099 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10100 .dac_nids = alc882_dac_nids,
10101 .dig_out_nid = ALC882_DIGOUT_NID,
10102 .dig_in_nid = ALC882_DIGIN_NID,
10103 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10104 .channel_mode = alc882_ch_modes,
10105 .input_mux = &alc882_capture_source,
10106 .init_hook = alc885_macpro_init_hook,
10107 },
10108 [ALC885_IMAC24] = {
10109 .mixers = { alc885_imac24_mixer },
10110 .init_verbs = { alc885_imac24_init_verbs },
10111 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10112 .dac_nids = alc882_dac_nids,
10113 .dig_out_nid = ALC882_DIGOUT_NID,
10114 .dig_in_nid = ALC882_DIGIN_NID,
10115 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10116 .channel_mode = alc882_ch_modes,
10117 .input_mux = &alc882_capture_source,
10118 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010119 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010120 .init_hook = alc885_imac24_init_hook,
10121 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010122 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010123 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010124 .init_verbs = { alc885_imac91_init_verbs,
10125 alc880_gpio1_init_verbs },
10126 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10127 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010128 .channel_mode = alc885_mba21_ch_modes,
10129 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10130 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010131 .dig_out_nid = ALC882_DIGOUT_NID,
10132 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010133 .unsol_event = alc_automute_amp_unsol_event,
10134 .setup = alc885_imac91_setup,
10135 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010136 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010137 [ALC882_TARGA] = {
10138 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010139 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010140 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010141 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10142 .dac_nids = alc882_dac_nids,
10143 .dig_out_nid = ALC882_DIGOUT_NID,
10144 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10145 .adc_nids = alc882_adc_nids,
10146 .capsrc_nids = alc882_capsrc_nids,
10147 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10148 .channel_mode = alc882_3ST_6ch_modes,
10149 .need_dac_fix = 1,
10150 .input_mux = &alc882_capture_source,
10151 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010152 .setup = alc882_targa_setup,
10153 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010154 },
10155 [ALC882_ASUS_A7J] = {
10156 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010157 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10158 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010159 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10160 .dac_nids = alc882_dac_nids,
10161 .dig_out_nid = ALC882_DIGOUT_NID,
10162 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10163 .adc_nids = alc882_adc_nids,
10164 .capsrc_nids = alc882_capsrc_nids,
10165 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10166 .channel_mode = alc882_3ST_6ch_modes,
10167 .need_dac_fix = 1,
10168 .input_mux = &alc882_capture_source,
10169 },
10170 [ALC882_ASUS_A7M] = {
10171 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010172 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10173 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010174 alc882_asus_a7m_verbs },
10175 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10176 .dac_nids = alc882_dac_nids,
10177 .dig_out_nid = ALC882_DIGOUT_NID,
10178 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10179 .channel_mode = alc880_threestack_modes,
10180 .need_dac_fix = 1,
10181 .input_mux = &alc882_capture_source,
10182 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010183 [ALC883_3ST_2ch_DIG] = {
10184 .mixers = { alc883_3ST_2ch_mixer },
10185 .init_verbs = { alc883_init_verbs },
10186 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10187 .dac_nids = alc883_dac_nids,
10188 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010189 .dig_in_nid = ALC883_DIGIN_NID,
10190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10191 .channel_mode = alc883_3ST_2ch_modes,
10192 .input_mux = &alc883_capture_source,
10193 },
10194 [ALC883_3ST_6ch_DIG] = {
10195 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10196 .init_verbs = { alc883_init_verbs },
10197 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10198 .dac_nids = alc883_dac_nids,
10199 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010200 .dig_in_nid = ALC883_DIGIN_NID,
10201 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10202 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010203 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010204 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010205 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010206 [ALC883_3ST_6ch] = {
10207 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10208 .init_verbs = { alc883_init_verbs },
10209 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10210 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010211 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10212 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010213 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010214 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010215 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010216 [ALC883_3ST_6ch_INTEL] = {
10217 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10218 .init_verbs = { alc883_init_verbs },
10219 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10220 .dac_nids = alc883_dac_nids,
10221 .dig_out_nid = ALC883_DIGOUT_NID,
10222 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010223 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010224 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10225 .channel_mode = alc883_3ST_6ch_intel_modes,
10226 .need_dac_fix = 1,
10227 .input_mux = &alc883_3stack_6ch_intel,
10228 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010229 [ALC889A_INTEL] = {
10230 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010231 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10232 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010233 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10234 .dac_nids = alc883_dac_nids,
10235 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10236 .adc_nids = alc889_adc_nids,
10237 .dig_out_nid = ALC883_DIGOUT_NID,
10238 .dig_in_nid = ALC883_DIGIN_NID,
10239 .slave_dig_outs = alc883_slave_dig_outs,
10240 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10241 .channel_mode = alc889_8ch_intel_modes,
10242 .capsrc_nids = alc889_capsrc_nids,
10243 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010244 .setup = alc889_automute_setup,
10245 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010246 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010247 .need_dac_fix = 1,
10248 },
10249 [ALC889_INTEL] = {
10250 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10251 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010252 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010253 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10254 .dac_nids = alc883_dac_nids,
10255 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10256 .adc_nids = alc889_adc_nids,
10257 .dig_out_nid = ALC883_DIGOUT_NID,
10258 .dig_in_nid = ALC883_DIGIN_NID,
10259 .slave_dig_outs = alc883_slave_dig_outs,
10260 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10261 .channel_mode = alc889_8ch_intel_modes,
10262 .capsrc_nids = alc889_capsrc_nids,
10263 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010264 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010265 .init_hook = alc889_intel_init_hook,
10266 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010267 .need_dac_fix = 1,
10268 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010269 [ALC883_6ST_DIG] = {
10270 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10271 .init_verbs = { alc883_init_verbs },
10272 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10273 .dac_nids = alc883_dac_nids,
10274 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010275 .dig_in_nid = ALC883_DIGIN_NID,
10276 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10277 .channel_mode = alc883_sixstack_modes,
10278 .input_mux = &alc883_capture_source,
10279 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010280 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010281 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010282 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10283 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010284 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10285 .dac_nids = alc883_dac_nids,
10286 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010287 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10288 .channel_mode = alc883_3ST_6ch_modes,
10289 .need_dac_fix = 1,
10290 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010291 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010292 .setup = alc882_targa_setup,
10293 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010294 },
10295 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010296 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010297 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10298 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010299 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10300 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010301 .adc_nids = alc883_adc_nids_alt,
10302 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010303 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010304 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010305 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10306 .channel_mode = alc883_3ST_2ch_modes,
10307 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010308 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010309 .setup = alc882_targa_setup,
10310 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010311 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010312 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010313 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10314 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010315 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010316 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010317 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10318 .dac_nids = alc883_dac_nids,
10319 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10320 .adc_nids = alc883_adc_nids_rev,
10321 .capsrc_nids = alc883_capsrc_nids_rev,
10322 .dig_out_nid = ALC883_DIGOUT_NID,
10323 .dig_in_nid = ALC883_DIGIN_NID,
10324 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10325 .channel_mode = alc883_4ST_8ch_modes,
10326 .need_dac_fix = 1,
10327 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010328 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010329 .setup = alc882_targa_setup,
10330 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010331 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010332 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010333 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010334 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10335 * and the headphone jack. Turn this on and rely on the
10336 * standard mute methods whenever the user wants to turn
10337 * these outputs off.
10338 */
10339 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10340 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10341 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010342 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10343 .channel_mode = alc883_3ST_2ch_modes,
10344 .input_mux = &alc883_capture_source,
10345 },
Tobin Davis2880a862007-08-07 11:50:26 +020010346 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010347 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010348 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010349 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10350 .dac_nids = alc883_dac_nids,
10351 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010352 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10353 .channel_mode = alc883_3ST_2ch_modes,
10354 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010355 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010356 .setup = alc883_acer_aspire_setup,
10357 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010358 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010359 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010360 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010361 alc883_chmode_mixer },
10362 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10363 alc888_acer_aspire_4930g_verbs },
10364 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10365 .dac_nids = alc883_dac_nids,
10366 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10367 .adc_nids = alc883_adc_nids_rev,
10368 .capsrc_nids = alc883_capsrc_nids_rev,
10369 .dig_out_nid = ALC883_DIGOUT_NID,
10370 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10371 .channel_mode = alc883_3ST_6ch_modes,
10372 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010373 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010374 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010375 ARRAY_SIZE(alc888_2_capture_sources),
10376 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010377 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010378 .setup = alc888_acer_aspire_4930g_setup,
10379 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010380 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010381 [ALC888_ACER_ASPIRE_6530G] = {
10382 .mixers = { alc888_acer_aspire_6530_mixer },
10383 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10384 alc888_acer_aspire_6530g_verbs },
10385 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10386 .dac_nids = alc883_dac_nids,
10387 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10388 .adc_nids = alc883_adc_nids_rev,
10389 .capsrc_nids = alc883_capsrc_nids_rev,
10390 .dig_out_nid = ALC883_DIGOUT_NID,
10391 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10392 .channel_mode = alc883_3ST_2ch_modes,
10393 .num_mux_defs =
10394 ARRAY_SIZE(alc888_2_capture_sources),
10395 .input_mux = alc888_acer_aspire_6530_sources,
10396 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010397 .setup = alc888_acer_aspire_6530g_setup,
10398 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010399 },
Hector Martin3b315d72009-06-02 10:54:19 +020010400 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010401 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010402 alc883_chmode_mixer },
10403 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010404 alc889_acer_aspire_8930g_verbs,
10405 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010406 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10407 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010408 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10409 .adc_nids = alc889_adc_nids,
10410 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010411 .dig_out_nid = ALC883_DIGOUT_NID,
10412 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10413 .channel_mode = alc883_3ST_6ch_modes,
10414 .need_dac_fix = 1,
10415 .const_channel_count = 6,
10416 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010417 ARRAY_SIZE(alc889_capture_sources),
10418 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010419 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010420 .setup = alc889_acer_aspire_8930g_setup,
10421 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010422#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010423 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010424#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010425 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010426 [ALC888_ACER_ASPIRE_7730G] = {
10427 .mixers = { alc883_3ST_6ch_mixer,
10428 alc883_chmode_mixer },
10429 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10430 alc888_acer_aspire_7730G_verbs },
10431 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10432 .dac_nids = alc883_dac_nids,
10433 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10434 .adc_nids = alc883_adc_nids_rev,
10435 .capsrc_nids = alc883_capsrc_nids_rev,
10436 .dig_out_nid = ALC883_DIGOUT_NID,
10437 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10438 .channel_mode = alc883_3ST_6ch_modes,
10439 .need_dac_fix = 1,
10440 .const_channel_count = 6,
10441 .input_mux = &alc883_capture_source,
10442 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010443 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010444 .init_hook = alc_automute_amp,
10445 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010446 [ALC883_MEDION] = {
10447 .mixers = { alc883_fivestack_mixer,
10448 alc883_chmode_mixer },
10449 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010450 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010451 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10452 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010453 .adc_nids = alc883_adc_nids_alt,
10454 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010455 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010456 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10457 .channel_mode = alc883_sixstack_modes,
10458 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010459 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010460 [ALC883_MEDION_WIM2160] = {
10461 .mixers = { alc883_medion_wim2160_mixer },
10462 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10463 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10464 .dac_nids = alc883_dac_nids,
10465 .dig_out_nid = ALC883_DIGOUT_NID,
10466 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10467 .adc_nids = alc883_adc_nids,
10468 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10469 .channel_mode = alc883_3ST_2ch_modes,
10470 .input_mux = &alc883_capture_source,
10471 .unsol_event = alc_automute_amp_unsol_event,
10472 .setup = alc883_medion_wim2160_setup,
10473 .init_hook = alc_automute_amp,
10474 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010475 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010476 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010477 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10478 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10479 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010480 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10481 .channel_mode = alc883_3ST_2ch_modes,
10482 .input_mux = &alc883_capture_source,
10483 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010484 [ALC883_CLEVO_M540R] = {
10485 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10486 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10487 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10488 .dac_nids = alc883_dac_nids,
10489 .dig_out_nid = ALC883_DIGOUT_NID,
10490 .dig_in_nid = ALC883_DIGIN_NID,
10491 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10492 .channel_mode = alc883_3ST_6ch_clevo_modes,
10493 .need_dac_fix = 1,
10494 .input_mux = &alc883_capture_source,
10495 /* This machine has the hardware HP auto-muting, thus
10496 * we need no software mute via unsol event
10497 */
10498 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010499 [ALC883_CLEVO_M720] = {
10500 .mixers = { alc883_clevo_m720_mixer },
10501 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010502 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10503 .dac_nids = alc883_dac_nids,
10504 .dig_out_nid = ALC883_DIGOUT_NID,
10505 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10506 .channel_mode = alc883_3ST_2ch_modes,
10507 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010508 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010509 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010510 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010511 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010512 [ALC883_LENOVO_101E_2ch] = {
10513 .mixers = { alc883_lenovo_101e_2ch_mixer},
10514 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10515 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10516 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010517 .adc_nids = alc883_adc_nids_alt,
10518 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010519 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010520 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10521 .channel_mode = alc883_3ST_2ch_modes,
10522 .input_mux = &alc883_lenovo_101e_capture_source,
10523 .unsol_event = alc883_lenovo_101e_unsol_event,
10524 .init_hook = alc883_lenovo_101e_all_automute,
10525 },
Kailang Yang272a5272007-05-14 11:00:38 +020010526 [ALC883_LENOVO_NB0763] = {
10527 .mixers = { alc883_lenovo_nb0763_mixer },
10528 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10529 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10530 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010531 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10532 .channel_mode = alc883_3ST_2ch_modes,
10533 .need_dac_fix = 1,
10534 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010535 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010536 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010537 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010538 },
10539 [ALC888_LENOVO_MS7195_DIG] = {
10540 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10541 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10542 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10543 .dac_nids = alc883_dac_nids,
10544 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010545 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10546 .channel_mode = alc883_3ST_6ch_modes,
10547 .need_dac_fix = 1,
10548 .input_mux = &alc883_capture_source,
10549 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10550 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010551 },
10552 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010553 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010554 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10555 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10556 .dac_nids = alc883_dac_nids,
10557 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010558 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10559 .channel_mode = alc883_3ST_2ch_modes,
10560 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010561 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010562 .setup = alc883_haier_w66_setup,
10563 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010564 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010565 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010566 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010567 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010568 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10569 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010570 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10571 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010572 .need_dac_fix = 1,
10573 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010574 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010575 .setup = alc888_3st_hp_setup,
10576 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010577 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010578 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010579 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010580 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10581 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10582 .dac_nids = alc883_dac_nids,
10583 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010584 .dig_in_nid = ALC883_DIGIN_NID,
10585 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10586 .channel_mode = alc883_sixstack_modes,
10587 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010588 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010589 .setup = alc888_6st_dell_setup,
10590 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010591 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010592 [ALC883_MITAC] = {
10593 .mixers = { alc883_mitac_mixer },
10594 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10595 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10596 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010597 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10598 .channel_mode = alc883_3ST_2ch_modes,
10599 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010600 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010601 .setup = alc883_mitac_setup,
10602 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010603 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010604 [ALC883_FUJITSU_PI2515] = {
10605 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10606 .init_verbs = { alc883_init_verbs,
10607 alc883_2ch_fujitsu_pi2515_verbs},
10608 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10609 .dac_nids = alc883_dac_nids,
10610 .dig_out_nid = ALC883_DIGOUT_NID,
10611 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10612 .channel_mode = alc883_3ST_2ch_modes,
10613 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010614 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010615 .setup = alc883_2ch_fujitsu_pi2515_setup,
10616 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010617 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010618 [ALC888_FUJITSU_XA3530] = {
10619 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10620 .init_verbs = { alc883_init_verbs,
10621 alc888_fujitsu_xa3530_verbs },
10622 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10623 .dac_nids = alc883_dac_nids,
10624 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10625 .adc_nids = alc883_adc_nids_rev,
10626 .capsrc_nids = alc883_capsrc_nids_rev,
10627 .dig_out_nid = ALC883_DIGOUT_NID,
10628 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10629 .channel_mode = alc888_4ST_8ch_intel_modes,
10630 .num_mux_defs =
10631 ARRAY_SIZE(alc888_2_capture_sources),
10632 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010633 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010634 .setup = alc888_fujitsu_xa3530_setup,
10635 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010636 },
Kailang Yange2757d52008-08-26 13:17:46 +020010637 [ALC888_LENOVO_SKY] = {
10638 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10639 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10640 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10641 .dac_nids = alc883_dac_nids,
10642 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010643 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10644 .channel_mode = alc883_sixstack_modes,
10645 .need_dac_fix = 1,
10646 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010647 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010648 .setup = alc888_lenovo_sky_setup,
10649 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010650 },
10651 [ALC888_ASUS_M90V] = {
10652 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10653 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10654 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10655 .dac_nids = alc883_dac_nids,
10656 .dig_out_nid = ALC883_DIGOUT_NID,
10657 .dig_in_nid = ALC883_DIGIN_NID,
10658 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10659 .channel_mode = alc883_3ST_6ch_modes,
10660 .need_dac_fix = 1,
10661 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010662 .unsol_event = alc_sku_unsol_event,
10663 .setup = alc883_mode2_setup,
10664 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010665 },
10666 [ALC888_ASUS_EEE1601] = {
10667 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010668 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010669 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10670 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10671 .dac_nids = alc883_dac_nids,
10672 .dig_out_nid = ALC883_DIGOUT_NID,
10673 .dig_in_nid = ALC883_DIGIN_NID,
10674 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10675 .channel_mode = alc883_3ST_2ch_modes,
10676 .need_dac_fix = 1,
10677 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010678 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010679 .init_hook = alc883_eee1601_inithook,
10680 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010681 [ALC1200_ASUS_P5Q] = {
10682 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10683 .init_verbs = { alc883_init_verbs },
10684 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10685 .dac_nids = alc883_dac_nids,
10686 .dig_out_nid = ALC1200_DIGOUT_NID,
10687 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010688 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010689 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10690 .channel_mode = alc883_sixstack_modes,
10691 .input_mux = &alc883_capture_source,
10692 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010693 [ALC889A_MB31] = {
10694 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10695 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10696 alc880_gpio1_init_verbs },
10697 .adc_nids = alc883_adc_nids,
10698 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010699 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010700 .dac_nids = alc883_dac_nids,
10701 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10702 .channel_mode = alc889A_mb31_6ch_modes,
10703 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10704 .input_mux = &alc889A_mb31_capture_source,
10705 .dig_out_nid = ALC883_DIGOUT_NID,
10706 .unsol_event = alc889A_mb31_unsol_event,
10707 .init_hook = alc889A_mb31_automute,
10708 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010709 [ALC883_SONY_VAIO_TT] = {
10710 .mixers = { alc883_vaiott_mixer },
10711 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10712 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10713 .dac_nids = alc883_dac_nids,
10714 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10715 .channel_mode = alc883_3ST_2ch_modes,
10716 .input_mux = &alc883_capture_source,
10717 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010718 .setup = alc883_vaiott_setup,
10719 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010720 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010721};
10722
10723
10724/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010725 * Pin config fixes
10726 */
10727enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010728 PINFIX_ABIT_AW9D_MAX,
10729 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010730 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010731};
10732
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010733static const struct alc_fixup alc882_fixups[] = {
10734 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010735 .type = ALC_FIXUP_PINS,
10736 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010737 { 0x15, 0x01080104 }, /* side */
10738 { 0x16, 0x01011012 }, /* rear */
10739 { 0x17, 0x01016011 }, /* clfe */
10740 { }
10741 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010742 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010743 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010744 .type = ALC_FIXUP_VERBS,
10745 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010746 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10747 {}
10748 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010749 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010750 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010751 .type = ALC_FIXUP_SKU,
10752 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010753 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010754};
10755
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010756static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010757 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010758 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010759 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010760 {}
10761};
10762
10763/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010764 * BIOS auto configuration
10765 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010766static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10767 const struct auto_pin_cfg *cfg)
10768{
10769 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10770}
10771
Takashi Iwai4953550a2009-06-30 15:28:30 +020010772static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010773 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010774 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010775{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010776 int idx;
10777
Takashi Iwai489008c2010-04-07 09:06:00 +020010778 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010779 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010780
Takashi Iwai489008c2010-04-07 09:06:00 +020010781 if (dac == 0x25)
10782 idx = 4;
10783 else if (dac >= 0x02 && dac <= 0x05)
10784 idx = dac - 2;
10785 else
10786 return;
10787 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010788}
10789
Takashi Iwai4953550a2009-06-30 15:28:30 +020010790static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010791{
10792 struct alc_spec *spec = codec->spec;
10793 int i;
10794
10795 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010796 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010797 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010798 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010799 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010800 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010801 }
10802}
10803
Takashi Iwai4953550a2009-06-30 15:28:30 +020010804static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010805{
10806 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010807 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010808 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010809
Takashi Iwai5855fb82010-09-16 18:24:02 +020010810 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10811 pin = spec->autocfg.hp_pins[i];
10812 if (!pin)
10813 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010814 dac = spec->multiout.hp_nid;
10815 if (!dac)
10816 dac = spec->multiout.dac_nids[0]; /* to front */
10817 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10818 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010819 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10820 pin = spec->autocfg.speaker_pins[i];
10821 if (!pin)
10822 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010823 dac = spec->multiout.extra_out_nid[0];
10824 if (!dac)
10825 dac = spec->multiout.dac_nids[0]; /* to front */
10826 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10827 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010828}
10829
Takashi Iwai4953550a2009-06-30 15:28:30 +020010830static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010831{
10832 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010833 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010834 int i;
10835
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010836 for (i = 0; i < cfg->num_inputs; i++) {
10837 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010838 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010839 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10840 snd_hda_codec_write(codec, nid, 0,
10841 AC_VERB_SET_AMP_GAIN_MUTE,
10842 AMP_OUT_MUTE);
10843 }
10844}
10845
10846static void alc882_auto_init_input_src(struct hda_codec *codec)
10847{
10848 struct alc_spec *spec = codec->spec;
10849 int c;
10850
10851 for (c = 0; c < spec->num_adc_nids; c++) {
10852 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10853 hda_nid_t nid = spec->capsrc_nids[c];
10854 unsigned int mux_idx;
10855 const struct hda_input_mux *imux;
10856 int conns, mute, idx, item;
10857
10858 conns = snd_hda_get_connections(codec, nid, conn_list,
10859 ARRAY_SIZE(conn_list));
10860 if (conns < 0)
10861 continue;
10862 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10863 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010864 if (!imux->num_items && mux_idx > 0)
10865 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010866 for (idx = 0; idx < conns; idx++) {
10867 /* if the current connection is the selected one,
10868 * unmute it as default - otherwise mute it
10869 */
10870 mute = AMP_IN_MUTE(idx);
10871 for (item = 0; item < imux->num_items; item++) {
10872 if (imux->items[item].index == idx) {
10873 if (spec->cur_mux[c] == item)
10874 mute = AMP_IN_UNMUTE(idx);
10875 break;
10876 }
10877 }
10878 /* check if we have a selector or mixer
10879 * we could check for the widget type instead, but
10880 * just check for Amp-In presence (in case of mixer
10881 * without amp-in there is something wrong, this
10882 * function shouldn't be used or capsrc nid is wrong)
10883 */
10884 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010885 snd_hda_codec_write(codec, nid, 0,
10886 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010887 mute);
10888 else if (mute != AMP_IN_MUTE(idx))
10889 snd_hda_codec_write(codec, nid, 0,
10890 AC_VERB_SET_CONNECT_SEL,
10891 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010892 }
10893 }
10894}
10895
Takashi Iwai4953550a2009-06-30 15:28:30 +020010896/* add mic boosts if needed */
10897static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010898{
10899 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010900 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010901 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010902 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010903 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010904 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010905
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010906 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010907 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010908 break;
10909 nid = cfg->inputs[i].pin;
10910 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010911 const char *label;
10912 char boost_label[32];
10913
10914 label = hda_get_autocfg_input_label(codec, cfg, i);
10915 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010916 type_idx++;
10917 else
10918 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010919 prev_label = label;
10920
10921 snprintf(boost_label, sizeof(boost_label),
10922 "%s Boost Volume", label);
10923 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10924 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010925 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010926 if (err < 0)
10927 return err;
10928 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010929 }
10930 return 0;
10931}
10932
10933/* almost identical with ALC880 parser... */
10934static int alc882_parse_auto_config(struct hda_codec *codec)
10935{
10936 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010937 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010938 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010939
Takashi Iwai05f5f472009-08-25 13:10:18 +020010940 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10941 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010942 if (err < 0)
10943 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010944 if (!spec->autocfg.line_outs)
10945 return 0; /* can't find valid BIOS pin config */
10946
10947 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10948 if (err < 0)
10949 return err;
10950 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10951 if (err < 0)
10952 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010953 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10954 "Headphone");
10955 if (err < 0)
10956 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010957 err = alc880_auto_create_extra_out(spec,
10958 spec->autocfg.speaker_pins[0],
10959 "Speaker");
10960 if (err < 0)
10961 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010962 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10963 if (err < 0)
10964 return err;
10965
10966 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10967
Takashi Iwai757899a2010-07-30 10:48:14 +020010968 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010969
10970 if (spec->kctls.list)
10971 add_mixer(spec, spec->kctls.list);
10972
10973 add_verb(spec, alc883_auto_init_verbs);
10974 /* if ADC 0x07 is available, initialize it, too */
10975 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10976 add_verb(spec, alc882_adc1_init_verbs);
10977
10978 spec->num_mux_defs = 1;
10979 spec->input_mux = &spec->private_imux[0];
10980
Kailang Yang6227cdc2010-02-25 08:36:52 +010010981 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010982
10983 err = alc_auto_add_mic_boost(codec);
10984 if (err < 0)
10985 return err;
10986
Takashi Iwai776e1842007-08-29 15:07:11 +020010987 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010988}
10989
10990/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010991static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010992{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010993 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010994 alc882_auto_init_multi_out(codec);
10995 alc882_auto_init_hp_out(codec);
10996 alc882_auto_init_analog_input(codec);
10997 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010998 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010999 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011000 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011001}
11002
Takashi Iwai4953550a2009-06-30 15:28:30 +020011003static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011004{
11005 struct alc_spec *spec;
11006 int err, board_config;
11007
11008 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11009 if (spec == NULL)
11010 return -ENOMEM;
11011
11012 codec->spec = spec;
11013
Takashi Iwai4953550a2009-06-30 15:28:30 +020011014 switch (codec->vendor_id) {
11015 case 0x10ec0882:
11016 case 0x10ec0885:
11017 break;
11018 default:
11019 /* ALC883 and variants */
11020 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11021 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011022 }
11023
Takashi Iwai4953550a2009-06-30 15:28:30 +020011024 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
11025 alc882_models,
11026 alc882_cfg_tbl);
11027
11028 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
11029 board_config = snd_hda_check_board_codec_sid_config(codec,
11030 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
11031
11032 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011033 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011034 codec->chip_name);
11035 board_config = ALC882_AUTO;
11036 }
11037
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011038 if (board_config == ALC882_AUTO) {
11039 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11040 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11041 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011042
David Henningsson90622912010-10-14 14:50:18 +020011043 alc_auto_parse_customize_define(codec);
11044
Takashi Iwai4953550a2009-06-30 15:28:30 +020011045 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011046 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011047 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011048 if (err < 0) {
11049 alc_free(codec);
11050 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011051 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011052 printk(KERN_INFO
11053 "hda_codec: Cannot set up configuration "
11054 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011055 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011056 }
11057 }
11058
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011059 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011060 err = snd_hda_attach_beep_device(codec, 0x1);
11061 if (err < 0) {
11062 alc_free(codec);
11063 return err;
11064 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011065 }
11066
Takashi Iwai4953550a2009-06-30 15:28:30 +020011067 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011068 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011069
Takashi Iwai4953550a2009-06-30 15:28:30 +020011070 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11071 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11072 /* FIXME: setup DAC5 */
11073 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11074 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11075
11076 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11077 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11078
Takashi Iwai4953550a2009-06-30 15:28:30 +020011079 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011080 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011081 spec->num_adc_nids = 0;
11082 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011083 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011084 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011085 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011086 hda_nid_t nid = alc882_adc_nids[i];
11087 unsigned int wcap = get_wcaps(codec, nid);
11088 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011089 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011090 if (wcap != AC_WID_AUD_IN)
11091 continue;
11092 spec->private_adc_nids[spec->num_adc_nids] = nid;
11093 err = snd_hda_get_connections(codec, nid, &cap, 1);
11094 if (err < 0)
11095 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011096 err = snd_hda_get_connections(codec, cap, items,
11097 ARRAY_SIZE(items));
11098 if (err < 0)
11099 continue;
11100 for (j = 0; j < imux->num_items; j++)
11101 if (imux->items[j].index >= err)
11102 break;
11103 if (j < imux->num_items)
11104 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011105 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11106 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011107 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011108 spec->adc_nids = spec->private_adc_nids;
11109 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011110 }
11111
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011112 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011113
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011114 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011115 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011116
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011117 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011118
Takashi Iwai2134ea42008-01-10 16:53:55 +010011119 spec->vmaster_nid = 0x0c;
11120
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011121 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011122 if (board_config == ALC882_AUTO)
11123 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011124
11125 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011126#ifdef CONFIG_SND_HDA_POWER_SAVE
11127 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011128 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011129#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011130
11131 return 0;
11132}
11133
Takashi Iwai4953550a2009-06-30 15:28:30 +020011134
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011135/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011136 * ALC262 support
11137 */
11138
11139#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11140#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11141
11142#define alc262_dac_nids alc260_dac_nids
11143#define alc262_adc_nids alc882_adc_nids
11144#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011145#define alc262_capsrc_nids alc882_capsrc_nids
11146#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011147
11148#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011149#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011150
Kailang Yang4e555fe2008-08-26 13:05:55 +020011151static hda_nid_t alc262_dmic_adc_nids[1] = {
11152 /* ADC0 */
11153 0x09
11154};
11155
11156static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11157
Kailang Yangdf694da2005-12-05 19:42:22 +010011158static struct snd_kcontrol_new alc262_base_mixer[] = {
11159 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11160 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11161 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11162 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11163 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11164 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011167 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011168 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11169 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011170 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11173 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11174 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011175 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011176};
11177
Takashi Iwaice875f02008-01-28 18:17:43 +010011178/* update HP, line and mono-out pins according to the master switch */
11179static void alc262_hp_master_update(struct hda_codec *codec)
11180{
11181 struct alc_spec *spec = codec->spec;
11182 int val = spec->master_sw;
11183
11184 /* HP & line-out */
11185 snd_hda_codec_write_cache(codec, 0x1b, 0,
11186 AC_VERB_SET_PIN_WIDGET_CONTROL,
11187 val ? PIN_HP : 0);
11188 snd_hda_codec_write_cache(codec, 0x15, 0,
11189 AC_VERB_SET_PIN_WIDGET_CONTROL,
11190 val ? PIN_HP : 0);
11191 /* mono (speaker) depending on the HP jack sense */
11192 val = val && !spec->jack_present;
11193 snd_hda_codec_write_cache(codec, 0x16, 0,
11194 AC_VERB_SET_PIN_WIDGET_CONTROL,
11195 val ? PIN_OUT : 0);
11196}
11197
11198static void alc262_hp_bpc_automute(struct hda_codec *codec)
11199{
11200 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011201
11202 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011203 alc262_hp_master_update(codec);
11204}
11205
11206static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11207{
11208 if ((res >> 26) != ALC880_HP_EVENT)
11209 return;
11210 alc262_hp_bpc_automute(codec);
11211}
11212
11213static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11214{
11215 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011216
11217 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011218 alc262_hp_master_update(codec);
11219}
11220
11221static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11222 unsigned int res)
11223{
11224 if ((res >> 26) != ALC880_HP_EVENT)
11225 return;
11226 alc262_hp_wildwest_automute(codec);
11227}
11228
Takashi Iwaib72519b2009-05-08 14:31:55 +020011229#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011230
11231static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11232 struct snd_ctl_elem_value *ucontrol)
11233{
11234 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11235 struct alc_spec *spec = codec->spec;
11236 int val = !!*ucontrol->value.integer.value;
11237
11238 if (val == spec->master_sw)
11239 return 0;
11240 spec->master_sw = val;
11241 alc262_hp_master_update(codec);
11242 return 1;
11243}
11244
Takashi Iwaib72519b2009-05-08 14:31:55 +020011245#define ALC262_HP_MASTER_SWITCH \
11246 { \
11247 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11248 .name = "Master Playback Switch", \
11249 .info = snd_ctl_boolean_mono_info, \
11250 .get = alc262_hp_master_sw_get, \
11251 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011252 }, \
11253 { \
11254 .iface = NID_MAPPING, \
11255 .name = "Master Playback Switch", \
11256 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011257 }
11258
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011259
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011260static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011261 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011262 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11263 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11264 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011265 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11266 HDA_OUTPUT),
11267 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11268 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011269 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11270 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011271 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011272 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11273 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011274 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011275 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11276 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11277 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11278 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011279 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11280 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11281 { } /* end */
11282};
11283
Kailang Yangcd7509a2007-01-26 18:33:17 +010011284static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011285 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011286 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11287 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11288 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11289 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011290 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11291 HDA_OUTPUT),
11292 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11293 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011294 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11295 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011296 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011297 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11298 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11299 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11300 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011301 { } /* end */
11302};
11303
11304static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11305 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11306 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011307 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011308 { } /* end */
11309};
11310
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011311/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011312static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011313{
11314 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011315
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011316 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011317 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011318}
11319
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011320static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011321 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11322 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11325 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11326 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011327 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011328 { } /* end */
11329};
11330
11331static struct hda_verb alc262_hp_t5735_verbs[] = {
11332 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11333 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11334
11335 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11336 { }
11337};
11338
Kailang Yang8c427222008-01-10 13:03:59 +010011339static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011340 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11341 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011342 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11343 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011344 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11345 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11346 { } /* end */
11347};
11348
11349static struct hda_verb alc262_hp_rp5700_verbs[] = {
11350 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11351 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11352 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11353 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11354 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11355 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11360 {}
11361};
11362
11363static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11364 .num_items = 1,
11365 .items = {
11366 { "Line", 0x1 },
11367 },
11368};
11369
Takashi Iwai42171c12009-05-08 14:11:43 +020011370/* bind hp and internal speaker mute (with plug check) as master switch */
11371static void alc262_hippo_master_update(struct hda_codec *codec)
11372{
11373 struct alc_spec *spec = codec->spec;
11374 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11375 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11376 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11377 unsigned int mute;
11378
11379 /* HP */
11380 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11381 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11382 HDA_AMP_MUTE, mute);
11383 /* mute internal speaker per jack sense */
11384 if (spec->jack_present)
11385 mute = HDA_AMP_MUTE;
11386 if (line_nid)
11387 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11388 HDA_AMP_MUTE, mute);
11389 if (speaker_nid && speaker_nid != line_nid)
11390 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11391 HDA_AMP_MUTE, mute);
11392}
11393
11394#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11395
11396static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11397 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011398{
11399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011400 struct alc_spec *spec = codec->spec;
11401 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011402
Takashi Iwai42171c12009-05-08 14:11:43 +020011403 if (val == spec->master_sw)
11404 return 0;
11405 spec->master_sw = val;
11406 alc262_hippo_master_update(codec);
11407 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011408}
Takashi Iwai5b319542007-07-26 11:49:22 +020011409
Takashi Iwai42171c12009-05-08 14:11:43 +020011410#define ALC262_HIPPO_MASTER_SWITCH \
11411 { \
11412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11413 .name = "Master Playback Switch", \
11414 .info = snd_ctl_boolean_mono_info, \
11415 .get = alc262_hippo_master_sw_get, \
11416 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011417 }, \
11418 { \
11419 .iface = NID_MAPPING, \
11420 .name = "Master Playback Switch", \
11421 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11422 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011423 }
11424
11425static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11426 ALC262_HIPPO_MASTER_SWITCH,
11427 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11430 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11431 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011434 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011435 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11436 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011437 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011438 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11439 { } /* end */
11440};
11441
11442static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11443 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11444 ALC262_HIPPO_MASTER_SWITCH,
11445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11447 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11448 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11450 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011451 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011452 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11453 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011454 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011455 { } /* end */
11456};
11457
11458/* mute/unmute internal speaker according to the hp jack and mute state */
11459static void alc262_hippo_automute(struct hda_codec *codec)
11460{
11461 struct alc_spec *spec = codec->spec;
11462 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011463
Wu Fengguang864f92b2009-11-18 12:38:02 +080011464 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011465 alc262_hippo_master_update(codec);
11466}
11467
11468static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11469{
11470 if ((res >> 26) != ALC880_HP_EVENT)
11471 return;
11472 alc262_hippo_automute(codec);
11473}
11474
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011475static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011476{
11477 struct alc_spec *spec = codec->spec;
11478
11479 spec->autocfg.hp_pins[0] = 0x15;
11480 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011481}
11482
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011483static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011484{
11485 struct alc_spec *spec = codec->spec;
11486
11487 spec->autocfg.hp_pins[0] = 0x1b;
11488 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011489}
11490
11491
Kailang Yang272a5272007-05-14 11:00:38 +020011492static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011493 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011494 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011495 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11496 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11497 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11498 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11499 { } /* end */
11500};
11501
Kailang Yang83c34212007-07-05 11:43:05 +020011502static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011503 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11504 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11508 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11509 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11510 { } /* end */
11511};
Kailang Yang272a5272007-05-14 11:00:38 +020011512
Tony Vroonba340e82009-02-02 19:01:30 +000011513static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11514 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11515 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11516 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11517 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11518 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11519 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11521 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011522 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011523 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11524 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011525 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011526 { } /* end */
11527};
11528
11529static struct hda_verb alc262_tyan_verbs[] = {
11530 /* Headphone automute */
11531 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11532 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11533 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11534
11535 /* P11 AUX_IN, white 4-pin connector */
11536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11537 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11538 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11539 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11540
11541 {}
11542};
11543
11544/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011545static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011546{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011547 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011548
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011549 spec->autocfg.hp_pins[0] = 0x1b;
11550 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011551}
11552
Tony Vroonba340e82009-02-02 19:01:30 +000011553
Kailang Yangdf694da2005-12-05 19:42:22 +010011554#define alc262_capture_mixer alc882_capture_mixer
11555#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11556
11557/*
11558 * generic initialization of ADC, input mixers and output mixers
11559 */
11560static struct hda_verb alc262_init_verbs[] = {
11561 /*
11562 * Unmute ADC0-2 and set the default input to mic-in
11563 */
11564 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11566 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11567 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11568 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11569 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11570
Takashi Iwaicb53c622007-08-10 17:21:45 +020011571 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011572 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011573 * Note: PASD motherboards uses the Line In 2 as the input for
11574 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011575 */
11576 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011577 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11578 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011582
11583 /*
11584 * Set up output mixers (0x0c - 0x0e)
11585 */
11586 /* set vol=0 to output mixers */
11587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11588 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11589 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11590 /* set up input amps for analog loopback */
11591 /* Amp Indices: DAC = 0, mixer = 1 */
11592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11594 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11595 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11596 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11598
11599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11600 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11601 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11602 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11603 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11604 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11605
11606 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11607 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11608 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11609 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11610 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011611
Kailang Yangdf694da2005-12-05 19:42:22 +010011612 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11613 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011614
Kailang Yangdf694da2005-12-05 19:42:22 +010011615 /* FIXME: use matrix-type input source selection */
11616 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11617 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11618 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11619 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11620 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11621 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11622 /* Input mixer2 */
11623 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11624 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11626 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11627 /* Input mixer3 */
11628 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11630 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011631 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011632
11633 { }
11634};
11635
Kailang Yang4e555fe2008-08-26 13:05:55 +020011636static struct hda_verb alc262_eapd_verbs[] = {
11637 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11638 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11639 { }
11640};
11641
Kailang Yangccc656c2006-10-17 12:32:26 +020011642static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11643 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11644 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11645 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11646
11647 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11649 {}
11650};
11651
Kailang Yang272a5272007-05-14 11:00:38 +020011652static struct hda_verb alc262_sony_unsol_verbs[] = {
11653 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11654 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11655 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11656
11657 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011659 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011660};
11661
Kailang Yang4e555fe2008-08-26 13:05:55 +020011662static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11663 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11664 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011668 { } /* end */
11669};
11670
11671static struct hda_verb alc262_toshiba_s06_verbs[] = {
11672 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11675 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11676 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11677 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11678 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11679 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11680 {}
11681};
11682
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011683static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011684{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011685 struct alc_spec *spec = codec->spec;
11686
11687 spec->autocfg.hp_pins[0] = 0x15;
11688 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011689 spec->ext_mic.pin = 0x18;
11690 spec->ext_mic.mux_idx = 0;
11691 spec->int_mic.pin = 0x12;
11692 spec->int_mic.mux_idx = 9;
11693 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011694}
11695
Takashi Iwai834be882006-03-01 14:16:17 +010011696/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011697 * nec model
11698 * 0x15 = headphone
11699 * 0x16 = internal speaker
11700 * 0x18 = external mic
11701 */
11702
11703static struct snd_kcontrol_new alc262_nec_mixer[] = {
11704 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11705 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11706
11707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011709 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011710
11711 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11712 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11713 { } /* end */
11714};
11715
11716static struct hda_verb alc262_nec_verbs[] = {
11717 /* Unmute Speaker */
11718 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11719
11720 /* Headphone */
11721 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11722 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11723
11724 /* External mic to headphone */
11725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11726 /* External mic to speaker */
11727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11728 {}
11729};
11730
11731/*
Takashi Iwai834be882006-03-01 14:16:17 +010011732 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011733 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11734 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011735 */
11736
11737#define ALC_HP_EVENT 0x37
11738
11739static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11740 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011742 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11743 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011744 {}
11745};
11746
Jiang zhe0e31daf2008-03-20 12:12:39 +010011747static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11748 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11750 {}
11751};
11752
Daniel T Chene2595322009-12-19 18:19:02 -050011753static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11754 /* Front Mic pin: input vref at 50% */
11755 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11756 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11757 {}
11758};
11759
Takashi Iwai834be882006-03-01 14:16:17 +010011760static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011761 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011762 .items = {
11763 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011764 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011765 { "CD", 0x4 },
11766 },
11767};
11768
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011769static struct hda_input_mux alc262_HP_capture_source = {
11770 .num_items = 5,
11771 .items = {
11772 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011773 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011774 { "Line", 0x2 },
11775 { "CD", 0x4 },
11776 { "AUX IN", 0x6 },
11777 },
11778};
11779
zhejiangaccbe492007-08-31 12:36:05 +020011780static struct hda_input_mux alc262_HP_D7000_capture_source = {
11781 .num_items = 4,
11782 .items = {
11783 { "Mic", 0x0 },
11784 { "Front Mic", 0x2 },
11785 { "Line", 0x1 },
11786 { "CD", 0x4 },
11787 },
11788};
11789
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011790/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011791static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11792{
11793 struct alc_spec *spec = codec->spec;
11794 unsigned int mute;
11795
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011796 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011797 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11798 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011799 spec->sense_updated = 1;
11800 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011801 /* unmute internal speaker only if both HPs are unplugged and
11802 * master switch is on
11803 */
11804 if (spec->jack_present)
11805 mute = HDA_AMP_MUTE;
11806 else
Takashi Iwai834be882006-03-01 14:16:17 +010011807 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011808 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11809 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011810}
11811
11812/* unsolicited event for HP jack sensing */
11813static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11814 unsigned int res)
11815{
11816 if ((res >> 26) != ALC_HP_EVENT)
11817 return;
11818 alc262_fujitsu_automute(codec, 1);
11819}
11820
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011821static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11822{
11823 alc262_fujitsu_automute(codec, 1);
11824}
11825
Takashi Iwai834be882006-03-01 14:16:17 +010011826/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011827static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11828 .ops = &snd_hda_bind_vol,
11829 .values = {
11830 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11831 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11832 0
11833 },
11834};
Takashi Iwai834be882006-03-01 14:16:17 +010011835
Jiang zhe0e31daf2008-03-20 12:12:39 +010011836/* mute/unmute internal speaker according to the hp jack and mute state */
11837static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11838{
11839 struct alc_spec *spec = codec->spec;
11840 unsigned int mute;
11841
11842 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011843 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011844 spec->sense_updated = 1;
11845 }
11846 if (spec->jack_present) {
11847 /* mute internal speaker */
11848 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11849 HDA_AMP_MUTE, HDA_AMP_MUTE);
11850 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11851 HDA_AMP_MUTE, HDA_AMP_MUTE);
11852 } else {
11853 /* unmute internal speaker if necessary */
11854 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11855 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11856 HDA_AMP_MUTE, mute);
11857 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11858 HDA_AMP_MUTE, mute);
11859 }
11860}
11861
11862/* unsolicited event for HP jack sensing */
11863static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11864 unsigned int res)
11865{
11866 if ((res >> 26) != ALC_HP_EVENT)
11867 return;
11868 alc262_lenovo_3000_automute(codec, 1);
11869}
11870
Takashi Iwai8de56b72009-07-24 16:51:47 +020011871static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11872 int dir, int idx, long *valp)
11873{
11874 int i, change = 0;
11875
11876 for (i = 0; i < 2; i++, valp++)
11877 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11878 HDA_AMP_MUTE,
11879 *valp ? 0 : HDA_AMP_MUTE);
11880 return change;
11881}
11882
Takashi Iwai834be882006-03-01 14:16:17 +010011883/* bind hp and internal speaker mute (with plug check) */
11884static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11885 struct snd_ctl_elem_value *ucontrol)
11886{
11887 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11888 long *valp = ucontrol->value.integer.value;
11889 int change;
11890
Takashi Iwai8de56b72009-07-24 16:51:47 +020011891 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11892 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011893 if (change)
11894 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011895 return change;
11896}
11897
11898static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011899 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011900 {
11901 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11902 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011903 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011904 .info = snd_hda_mixer_amp_switch_info,
11905 .get = snd_hda_mixer_amp_switch_get,
11906 .put = alc262_fujitsu_master_sw_put,
11907 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11908 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011909 {
11910 .iface = NID_MAPPING,
11911 .name = "Master Playback Switch",
11912 .private_value = 0x1b,
11913 },
Takashi Iwai834be882006-03-01 14:16:17 +010011914 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11915 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011916 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011919 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011920 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11921 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011922 { } /* end */
11923};
11924
Jiang zhe0e31daf2008-03-20 12:12:39 +010011925/* bind hp and internal speaker mute (with plug check) */
11926static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11927 struct snd_ctl_elem_value *ucontrol)
11928{
11929 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11930 long *valp = ucontrol->value.integer.value;
11931 int change;
11932
Takashi Iwai8de56b72009-07-24 16:51:47 +020011933 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011934 if (change)
11935 alc262_lenovo_3000_automute(codec, 0);
11936 return change;
11937}
11938
11939static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11940 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11941 {
11942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11943 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011944 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011945 .info = snd_hda_mixer_amp_switch_info,
11946 .get = snd_hda_mixer_amp_switch_get,
11947 .put = alc262_lenovo_3000_master_sw_put,
11948 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11949 },
11950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011952 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011955 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011956 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11957 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011958 { } /* end */
11959};
11960
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011961static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11962 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011963 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11965 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011966 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011967 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11968 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011969 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011970 { } /* end */
11971};
11972
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011973/* additional init verbs for Benq laptops */
11974static struct hda_verb alc262_EAPD_verbs[] = {
11975 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11976 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11977 {}
11978};
11979
Kailang Yang83c34212007-07-05 11:43:05 +020011980static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11982 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11983
11984 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11985 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11986 {}
11987};
11988
Tobin Davisf651b502007-10-26 12:40:47 +020011989/* Samsung Q1 Ultra Vista model setup */
11990static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011991 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11992 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011995 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
11996 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011997 { } /* end */
11998};
11999
12000static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012001 /* output mixer */
12002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12003 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12005 /* speaker */
12006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12009 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12010 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020012011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12014 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12015 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12016 /* internal mic */
12017 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12019 /* ADC, choose mic */
12020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12021 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12022 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12023 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12024 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
12029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020012030 {}
12031};
12032
Tobin Davisf651b502007-10-26 12:40:47 +020012033/* mute/unmute internal speaker according to the hp jack and mute state */
12034static void alc262_ultra_automute(struct hda_codec *codec)
12035{
12036 struct alc_spec *spec = codec->spec;
12037 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012038
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012039 mute = 0;
12040 /* auto-mute only when HP is used as HP */
12041 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012042 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012043 if (spec->jack_present)
12044 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012045 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012046 /* mute/unmute internal speaker */
12047 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12048 HDA_AMP_MUTE, mute);
12049 /* mute/unmute HP */
12050 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12051 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012052}
12053
12054/* unsolicited event for HP jack sensing */
12055static void alc262_ultra_unsol_event(struct hda_codec *codec,
12056 unsigned int res)
12057{
12058 if ((res >> 26) != ALC880_HP_EVENT)
12059 return;
12060 alc262_ultra_automute(codec);
12061}
12062
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012063static struct hda_input_mux alc262_ultra_capture_source = {
12064 .num_items = 2,
12065 .items = {
12066 { "Mic", 0x1 },
12067 { "Headphone", 0x7 },
12068 },
12069};
12070
12071static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12072 struct snd_ctl_elem_value *ucontrol)
12073{
12074 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12075 struct alc_spec *spec = codec->spec;
12076 int ret;
12077
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012078 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012079 if (!ret)
12080 return 0;
12081 /* reprogram the HP pin as mic or HP according to the input source */
12082 snd_hda_codec_write_cache(codec, 0x15, 0,
12083 AC_VERB_SET_PIN_WIDGET_CONTROL,
12084 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12085 alc262_ultra_automute(codec); /* mute/unmute HP */
12086 return ret;
12087}
12088
12089static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12090 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12091 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12092 {
12093 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12094 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012095 .info = alc_mux_enum_info,
12096 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012097 .put = alc262_ultra_mux_enum_put,
12098 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012099 {
12100 .iface = NID_MAPPING,
12101 .name = "Capture Source",
12102 .private_value = 0x15,
12103 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012104 { } /* end */
12105};
12106
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012107/* We use two mixers depending on the output pin; 0x16 is a mono output
12108 * and thus it's bound with a different mixer.
12109 * This function returns which mixer amp should be used.
12110 */
12111static int alc262_check_volbit(hda_nid_t nid)
12112{
12113 if (!nid)
12114 return 0;
12115 else if (nid == 0x16)
12116 return 2;
12117 else
12118 return 1;
12119}
12120
12121static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012122 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012123{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012124 unsigned long val;
12125 int vbit;
12126
12127 vbit = alc262_check_volbit(nid);
12128 if (!vbit)
12129 return 0;
12130 if (*vbits & vbit) /* a volume control for this mixer already there */
12131 return 0;
12132 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012133 if (vbit == 2)
12134 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12135 else
12136 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012137 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012138}
12139
12140static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012141 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012142{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012143 unsigned long val;
12144
12145 if (!nid)
12146 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012147 if (nid == 0x16)
12148 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12149 else
12150 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012151 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012152}
12153
Kailang Yangdf694da2005-12-05 19:42:22 +010012154/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012155static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12156 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012157{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012158 const char *pfx;
12159 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012160 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012161
12162 spec->multiout.num_dacs = 1; /* only use one dac */
12163 spec->multiout.dac_nids = spec->private_dac_nids;
12164 spec->multiout.dac_nids[0] = 2;
12165
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012166 pfx = alc_get_line_out_pfx(cfg, true);
12167 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012168 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012169 for (i = 0; i < 2; i++) {
12170 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12171 if (err < 0)
12172 return err;
12173 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12174 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12175 "Speaker", i);
12176 if (err < 0)
12177 return err;
12178 }
12179 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12180 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12181 "Headphone", i);
12182 if (err < 0)
12183 return err;
12184 }
12185 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012186
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012187 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12188 alc262_check_volbit(cfg->speaker_pins[0]) |
12189 alc262_check_volbit(cfg->hp_pins[0]);
12190 if (vbits == 1 || vbits == 2)
12191 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012192 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012193 for (i = 0; i < 2; i++) {
12194 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12195 &vbits, i);
12196 if (err < 0)
12197 return err;
12198 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12199 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12200 "Speaker", &vbits, i);
12201 if (err < 0)
12202 return err;
12203 }
12204 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12205 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12206 "Headphone", &vbits, i);
12207 if (err < 0)
12208 return err;
12209 }
12210 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012211 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012212}
12213
Takashi Iwai05f5f472009-08-25 13:10:18 +020012214#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012215 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012216
12217/*
12218 * generic initialization of ADC, input mixers and output mixers
12219 */
12220static struct hda_verb alc262_volume_init_verbs[] = {
12221 /*
12222 * Unmute ADC0-2 and set the default input to mic-in
12223 */
12224 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12226 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12227 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12228 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12229 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12230
Takashi Iwaicb53c622007-08-10 17:21:45 +020012231 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012232 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012233 * Note: PASD motherboards uses the Line In 2 as the input for
12234 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012235 */
12236 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12238 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12239 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12240 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012242
12243 /*
12244 * Set up output mixers (0x0c - 0x0f)
12245 */
12246 /* set vol=0 to output mixers */
12247 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12248 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012250
Kailang Yangdf694da2005-12-05 19:42:22 +010012251 /* set up input amps for analog loopback */
12252 /* Amp Indices: DAC = 0, mixer = 1 */
12253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12255 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12256 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12257 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12258 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12259
12260 /* FIXME: use matrix-type input source selection */
12261 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12262 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12263 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12264 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12265 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12267 /* Input mixer2 */
12268 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12270 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12272 /* Input mixer3 */
12273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12274 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12275 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12277
12278 { }
12279};
12280
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012281static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12282 /*
12283 * Unmute ADC0-2 and set the default input to mic-in
12284 */
12285 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12287 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12288 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12289 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12291
Takashi Iwaicb53c622007-08-10 17:21:45 +020012292 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012293 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012294 * Note: PASD motherboards uses the Line In 2 as the input for
12295 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012296 */
12297 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12302 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012305
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012306 /*
12307 * Set up output mixers (0x0c - 0x0e)
12308 */
12309 /* set vol=0 to output mixers */
12310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12311 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12313
12314 /* set up input amps for analog loopback */
12315 /* Amp Indices: DAC = 0, mixer = 1 */
12316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12319 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12320 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12321 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12322
Takashi Iwaice875f02008-01-28 18:17:43 +010012323 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012324 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12325 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12326
12327 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12328 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12329
12330 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12331 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12332
12333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12334 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12335 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12336 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12337 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12338
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012340 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12341 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012343 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12344 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12345
12346
12347 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012348 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12349 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012350 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012359 /* Input mixer2 */
12360 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012361 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12362 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012369 /* Input mixer3 */
12370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12373 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012379
Takashi Iwaice875f02008-01-28 18:17:43 +010012380 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12381
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012382 { }
12383};
12384
Kailang Yangcd7509a2007-01-26 18:33:17 +010012385static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12386 /*
12387 * Unmute ADC0-2 and set the default input to mic-in
12388 */
12389 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12391 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12392 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12393 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12394 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12395
Takashi Iwaicb53c622007-08-10 17:21:45 +020012396 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012397 * mixer widget
12398 * Note: PASD motherboards uses the Line In 2 as the input for front
12399 * panel mic (mic 2)
12400 */
12401 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12403 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12404 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12405 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12406 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12407 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12408 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012410 /*
12411 * Set up output mixers (0x0c - 0x0e)
12412 */
12413 /* set vol=0 to output mixers */
12414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12415 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12416 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12417
12418 /* set up input amps for analog loopback */
12419 /* Amp Indices: DAC = 0, mixer = 1 */
12420 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12421 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12422 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12423 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12424 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12425 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12426
12427
12428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12429 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12430 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12431 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12432 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12433 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12434 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12435
12436 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12437 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12438
12439 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12440 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12441
12442 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12443 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12444 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12445 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12446 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12447 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12448
12449 /* FIXME: use matrix-type input source selection */
12450 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12451 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12457 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12459 /* Input mixer2 */
12460 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12461 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12465 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12466 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12467 /* Input mixer3 */
12468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12473 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12475
Takashi Iwaice875f02008-01-28 18:17:43 +010012476 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12477
Kailang Yangcd7509a2007-01-26 18:33:17 +010012478 { }
12479};
12480
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012481static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12482
12483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12485 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12486
12487 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12488 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12489 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12490 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12491
12492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12493 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12494 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12495 {}
12496};
12497
Takashi Iwai18675e42010-09-08 15:55:44 +020012498/*
12499 * Pin config fixes
12500 */
12501enum {
12502 PINFIX_FSC_H270,
12503};
12504
12505static const struct alc_fixup alc262_fixups[] = {
12506 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012507 .type = ALC_FIXUP_PINS,
12508 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012509 { 0x14, 0x99130110 }, /* speaker */
12510 { 0x15, 0x0221142f }, /* front HP */
12511 { 0x1b, 0x0121141f }, /* rear HP */
12512 { }
12513 }
12514 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012515};
12516
12517static struct snd_pci_quirk alc262_fixup_tbl[] = {
12518 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12519 {}
12520};
12521
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012522
Takashi Iwaicb53c622007-08-10 17:21:45 +020012523#ifdef CONFIG_SND_HDA_POWER_SAVE
12524#define alc262_loopbacks alc880_loopbacks
12525#endif
12526
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012527/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012528#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12529#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12530#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12531#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12532
12533/*
12534 * BIOS auto configuration
12535 */
12536static int alc262_parse_auto_config(struct hda_codec *codec)
12537{
12538 struct alc_spec *spec = codec->spec;
12539 int err;
12540 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12541
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012542 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12543 alc262_ignore);
12544 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012545 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012546 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012547 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012548 spec->multiout.max_channels = 2;
12549 spec->no_analog = 1;
12550 goto dig_only;
12551 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012552 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012553 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012554 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12555 if (err < 0)
12556 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012557 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012558 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012559 return err;
12560
12561 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12562
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012563 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012564 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012565
Takashi Iwai603c4012008-07-30 15:01:44 +020012566 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012567 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012568
Takashi Iwaid88897e2008-10-31 15:01:37 +010012569 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012570 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012571 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012572
Takashi Iwai776e1842007-08-29 15:07:11 +020012573 err = alc_auto_add_mic_boost(codec);
12574 if (err < 0)
12575 return err;
12576
Kailang Yang6227cdc2010-02-25 08:36:52 +010012577 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012578
Kailang Yangdf694da2005-12-05 19:42:22 +010012579 return 1;
12580}
12581
12582#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12583#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12584#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012585#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012586
12587
12588/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012589static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012590{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012591 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012592 alc262_auto_init_multi_out(codec);
12593 alc262_auto_init_hp_out(codec);
12594 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012595 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012596 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012597 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012598 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012599}
12600
12601/*
12602 * configuration and preset
12603 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012604static const char *alc262_models[ALC262_MODEL_LAST] = {
12605 [ALC262_BASIC] = "basic",
12606 [ALC262_HIPPO] = "hippo",
12607 [ALC262_HIPPO_1] = "hippo_1",
12608 [ALC262_FUJITSU] = "fujitsu",
12609 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012610 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012611 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012612 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012613 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012614 [ALC262_BENQ_T31] = "benq-t31",
12615 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012616 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012617 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012618 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012619 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012620 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012621 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012622 [ALC262_AUTO] = "auto",
12623};
12624
12625static struct snd_pci_quirk alc262_cfg_tbl[] = {
12626 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012627 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012628 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12629 ALC262_HP_BPC),
12630 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12631 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012632 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12633 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012634 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012635 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012636 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012637 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012638 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012639 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012640 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012641 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012642 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12643 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12644 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012645 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12646 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012647 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012648 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012649 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012650 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012651 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012652 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012653 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012654 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012655#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012656 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12657 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012658#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012659 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012660 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012661 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012662 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012663 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012664 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012665 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12666 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012667 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012668 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012669 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012670 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012671 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012672 {}
12673};
12674
12675static struct alc_config_preset alc262_presets[] = {
12676 [ALC262_BASIC] = {
12677 .mixers = { alc262_base_mixer },
12678 .init_verbs = { alc262_init_verbs },
12679 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12680 .dac_nids = alc262_dac_nids,
12681 .hp_nid = 0x03,
12682 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12683 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012684 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012685 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012686 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012687 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012688 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012689 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12690 .dac_nids = alc262_dac_nids,
12691 .hp_nid = 0x03,
12692 .dig_out_nid = ALC262_DIGOUT_NID,
12693 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12694 .channel_mode = alc262_modes,
12695 .input_mux = &alc262_capture_source,
12696 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012697 .setup = alc262_hippo_setup,
12698 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012699 },
12700 [ALC262_HIPPO_1] = {
12701 .mixers = { alc262_hippo1_mixer },
12702 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12703 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12704 .dac_nids = alc262_dac_nids,
12705 .hp_nid = 0x02,
12706 .dig_out_nid = ALC262_DIGOUT_NID,
12707 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12708 .channel_mode = alc262_modes,
12709 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012710 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012711 .setup = alc262_hippo1_setup,
12712 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012713 },
Takashi Iwai834be882006-03-01 14:16:17 +010012714 [ALC262_FUJITSU] = {
12715 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012716 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12717 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012718 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12719 .dac_nids = alc262_dac_nids,
12720 .hp_nid = 0x03,
12721 .dig_out_nid = ALC262_DIGOUT_NID,
12722 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12723 .channel_mode = alc262_modes,
12724 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012725 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012726 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012727 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012728 [ALC262_HP_BPC] = {
12729 .mixers = { alc262_HP_BPC_mixer },
12730 .init_verbs = { alc262_HP_BPC_init_verbs },
12731 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12732 .dac_nids = alc262_dac_nids,
12733 .hp_nid = 0x03,
12734 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12735 .channel_mode = alc262_modes,
12736 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012737 .unsol_event = alc262_hp_bpc_unsol_event,
12738 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012739 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012740 [ALC262_HP_BPC_D7000_WF] = {
12741 .mixers = { alc262_HP_BPC_WildWest_mixer },
12742 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12743 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12744 .dac_nids = alc262_dac_nids,
12745 .hp_nid = 0x03,
12746 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12747 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012748 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012749 .unsol_event = alc262_hp_wildwest_unsol_event,
12750 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012751 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012752 [ALC262_HP_BPC_D7000_WL] = {
12753 .mixers = { alc262_HP_BPC_WildWest_mixer,
12754 alc262_HP_BPC_WildWest_option_mixer },
12755 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12756 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12757 .dac_nids = alc262_dac_nids,
12758 .hp_nid = 0x03,
12759 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12760 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012761 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012762 .unsol_event = alc262_hp_wildwest_unsol_event,
12763 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012764 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012765 [ALC262_HP_TC_T5735] = {
12766 .mixers = { alc262_hp_t5735_mixer },
12767 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12768 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12769 .dac_nids = alc262_dac_nids,
12770 .hp_nid = 0x03,
12771 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12772 .channel_mode = alc262_modes,
12773 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012774 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012775 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012776 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012777 },
12778 [ALC262_HP_RP5700] = {
12779 .mixers = { alc262_hp_rp5700_mixer },
12780 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12781 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12782 .dac_nids = alc262_dac_nids,
12783 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12784 .channel_mode = alc262_modes,
12785 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012786 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012787 [ALC262_BENQ_ED8] = {
12788 .mixers = { alc262_base_mixer },
12789 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12790 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12791 .dac_nids = alc262_dac_nids,
12792 .hp_nid = 0x03,
12793 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12794 .channel_mode = alc262_modes,
12795 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012796 },
Kailang Yang272a5272007-05-14 11:00:38 +020012797 [ALC262_SONY_ASSAMD] = {
12798 .mixers = { alc262_sony_mixer },
12799 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12800 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12801 .dac_nids = alc262_dac_nids,
12802 .hp_nid = 0x02,
12803 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12804 .channel_mode = alc262_modes,
12805 .input_mux = &alc262_capture_source,
12806 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012807 .setup = alc262_hippo_setup,
12808 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012809 },
12810 [ALC262_BENQ_T31] = {
12811 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012812 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12813 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012814 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12815 .dac_nids = alc262_dac_nids,
12816 .hp_nid = 0x03,
12817 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12818 .channel_mode = alc262_modes,
12819 .input_mux = &alc262_capture_source,
12820 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012821 .setup = alc262_hippo_setup,
12822 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012823 },
Tobin Davisf651b502007-10-26 12:40:47 +020012824 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012825 .mixers = { alc262_ultra_mixer },
12826 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012827 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012828 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12829 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012830 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12831 .channel_mode = alc262_modes,
12832 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012833 .adc_nids = alc262_adc_nids, /* ADC0 */
12834 .capsrc_nids = alc262_capsrc_nids,
12835 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012836 .unsol_event = alc262_ultra_unsol_event,
12837 .init_hook = alc262_ultra_automute,
12838 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012839 [ALC262_LENOVO_3000] = {
12840 .mixers = { alc262_lenovo_3000_mixer },
12841 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012842 alc262_lenovo_3000_unsol_verbs,
12843 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012844 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12845 .dac_nids = alc262_dac_nids,
12846 .hp_nid = 0x03,
12847 .dig_out_nid = ALC262_DIGOUT_NID,
12848 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12849 .channel_mode = alc262_modes,
12850 .input_mux = &alc262_fujitsu_capture_source,
12851 .unsol_event = alc262_lenovo_3000_unsol_event,
12852 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012853 [ALC262_NEC] = {
12854 .mixers = { alc262_nec_mixer },
12855 .init_verbs = { alc262_nec_verbs },
12856 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12857 .dac_nids = alc262_dac_nids,
12858 .hp_nid = 0x03,
12859 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12860 .channel_mode = alc262_modes,
12861 .input_mux = &alc262_capture_source,
12862 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012863 [ALC262_TOSHIBA_S06] = {
12864 .mixers = { alc262_toshiba_s06_mixer },
12865 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12866 alc262_eapd_verbs },
12867 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12868 .capsrc_nids = alc262_dmic_capsrc_nids,
12869 .dac_nids = alc262_dac_nids,
12870 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012871 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012872 .dig_out_nid = ALC262_DIGOUT_NID,
12873 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12874 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012875 .unsol_event = alc_sku_unsol_event,
12876 .setup = alc262_toshiba_s06_setup,
12877 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012878 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012879 [ALC262_TOSHIBA_RX1] = {
12880 .mixers = { alc262_toshiba_rx1_mixer },
12881 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12882 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12883 .dac_nids = alc262_dac_nids,
12884 .hp_nid = 0x03,
12885 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12886 .channel_mode = alc262_modes,
12887 .input_mux = &alc262_capture_source,
12888 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012889 .setup = alc262_hippo_setup,
12890 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012891 },
Tony Vroonba340e82009-02-02 19:01:30 +000012892 [ALC262_TYAN] = {
12893 .mixers = { alc262_tyan_mixer },
12894 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12895 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12896 .dac_nids = alc262_dac_nids,
12897 .hp_nid = 0x02,
12898 .dig_out_nid = ALC262_DIGOUT_NID,
12899 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12900 .channel_mode = alc262_modes,
12901 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012902 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012903 .setup = alc262_tyan_setup,
12904 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012905 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012906};
12907
12908static int patch_alc262(struct hda_codec *codec)
12909{
12910 struct alc_spec *spec;
12911 int board_config;
12912 int err;
12913
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012914 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012915 if (spec == NULL)
12916 return -ENOMEM;
12917
12918 codec->spec = spec;
12919#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012920 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12921 * under-run
12922 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012923 {
12924 int tmp;
12925 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12926 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12927 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12928 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12929 }
12930#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012931 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012932
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012933 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12934
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012935 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12936 alc262_models,
12937 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012938
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012939 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012940 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12941 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012942 board_config = ALC262_AUTO;
12943 }
12944
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012945 if (board_config == ALC262_AUTO) {
12946 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12947 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12948 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012949
Kailang Yangdf694da2005-12-05 19:42:22 +010012950 if (board_config == ALC262_AUTO) {
12951 /* automatic parse from the BIOS config */
12952 err = alc262_parse_auto_config(codec);
12953 if (err < 0) {
12954 alc_free(codec);
12955 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012956 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012957 printk(KERN_INFO
12958 "hda_codec: Cannot set up configuration "
12959 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012960 board_config = ALC262_BASIC;
12961 }
12962 }
12963
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012964 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012965 err = snd_hda_attach_beep_device(codec, 0x1);
12966 if (err < 0) {
12967 alc_free(codec);
12968 return err;
12969 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012970 }
12971
Kailang Yangdf694da2005-12-05 19:42:22 +010012972 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012973 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012974
Kailang Yangdf694da2005-12-05 19:42:22 +010012975 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12976 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012977
Kailang Yangdf694da2005-12-05 19:42:22 +010012978 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12979 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12980
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012981 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012982 int i;
12983 /* check whether the digital-mic has to be supported */
12984 for (i = 0; i < spec->input_mux->num_items; i++) {
12985 if (spec->input_mux->items[i].index >= 9)
12986 break;
12987 }
12988 if (i < spec->input_mux->num_items) {
12989 /* use only ADC0 */
12990 spec->adc_nids = alc262_dmic_adc_nids;
12991 spec->num_adc_nids = 1;
12992 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012993 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012994 /* all analog inputs */
12995 /* check whether NID 0x07 is valid */
12996 unsigned int wcap = get_wcaps(codec, 0x07);
12997
12998 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012999 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020013000 if (wcap != AC_WID_AUD_IN) {
13001 spec->adc_nids = alc262_adc_nids_alt;
13002 spec->num_adc_nids =
13003 ARRAY_SIZE(alc262_adc_nids_alt);
13004 spec->capsrc_nids = alc262_capsrc_nids_alt;
13005 } else {
13006 spec->adc_nids = alc262_adc_nids;
13007 spec->num_adc_nids =
13008 ARRAY_SIZE(alc262_adc_nids);
13009 spec->capsrc_nids = alc262_capsrc_nids;
13010 }
Kailang Yangdf694da2005-12-05 19:42:22 +010013011 }
13012 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010013013 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013014 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013015 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010013016 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010013017
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013018 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020013019
Takashi Iwai2134ea42008-01-10 16:53:55 +010013020 spec->vmaster_nid = 0x0c;
13021
Kailang Yangdf694da2005-12-05 19:42:22 +010013022 codec->patch_ops = alc_patch_ops;
13023 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013024 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020013025
13026 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020013027#ifdef CONFIG_SND_HDA_POWER_SAVE
13028 if (!spec->loopback.amplist)
13029 spec->loopback.amplist = alc262_loopbacks;
13030#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013031
Kailang Yangdf694da2005-12-05 19:42:22 +010013032 return 0;
13033}
13034
Kailang Yangdf694da2005-12-05 19:42:22 +010013035/*
Kailang Yanga361d842007-06-05 12:30:55 +020013036 * ALC268 channel source setting (2 channel)
13037 */
13038#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13039#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013040
Kailang Yanga361d842007-06-05 12:30:55 +020013041static hda_nid_t alc268_dac_nids[2] = {
13042 /* front, hp */
13043 0x02, 0x03
13044};
13045
13046static hda_nid_t alc268_adc_nids[2] = {
13047 /* ADC0-1 */
13048 0x08, 0x07
13049};
13050
13051static hda_nid_t alc268_adc_nids_alt[1] = {
13052 /* ADC0 */
13053 0x08
13054};
13055
Takashi Iwaie1406342008-02-11 18:32:32 +010013056static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13057
Kailang Yanga361d842007-06-05 12:30:55 +020013058static struct snd_kcontrol_new alc268_base_mixer[] = {
13059 /* output mixer control */
13060 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13061 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13062 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013064 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13065 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13066 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013067 { }
13068};
13069
Takashi Iwai42171c12009-05-08 14:11:43 +020013070static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13071 /* output mixer control */
13072 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13073 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13074 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013075 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13076 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13077 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013078 { }
13079};
13080
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013081/* bind Beep switches of both NID 0x0f and 0x10 */
13082static struct hda_bind_ctls alc268_bind_beep_sw = {
13083 .ops = &snd_hda_bind_sw,
13084 .values = {
13085 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13086 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13087 0
13088 },
13089};
13090
13091static struct snd_kcontrol_new alc268_beep_mixer[] = {
13092 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13093 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13094 { }
13095};
13096
Kailang Yangd1a991a2007-08-15 16:21:59 +020013097static struct hda_verb alc268_eapd_verbs[] = {
13098 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13099 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13100 { }
13101};
13102
Takashi Iwaid2738092007-08-16 14:59:45 +020013103/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013104static struct hda_verb alc268_toshiba_verbs[] = {
13105 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13106 { } /* end */
13107};
13108
13109/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013110/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013111static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13112 .ops = &snd_hda_bind_vol,
13113 .values = {
13114 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13115 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13116 0
13117 },
13118};
13119
Takashi Iwai889c4392007-08-23 18:56:52 +020013120/* mute/unmute internal speaker according to the hp jack and mute state */
13121static void alc268_acer_automute(struct hda_codec *codec, int force)
13122{
13123 struct alc_spec *spec = codec->spec;
13124 unsigned int mute;
13125
13126 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013127 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013128 spec->sense_updated = 1;
13129 }
13130 if (spec->jack_present)
13131 mute = HDA_AMP_MUTE; /* mute internal speaker */
13132 else /* unmute internal speaker if necessary */
13133 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13134 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13135 HDA_AMP_MUTE, mute);
13136}
13137
13138
13139/* bind hp and internal speaker mute (with plug check) */
13140static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13141 struct snd_ctl_elem_value *ucontrol)
13142{
13143 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13144 long *valp = ucontrol->value.integer.value;
13145 int change;
13146
Takashi Iwai8de56b72009-07-24 16:51:47 +020013147 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013148 if (change)
13149 alc268_acer_automute(codec, 0);
13150 return change;
13151}
Takashi Iwaid2738092007-08-16 14:59:45 +020013152
Kailang Yang8ef355d2008-08-26 13:10:22 +020013153static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13154 /* output mixer control */
13155 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13156 {
13157 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13158 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013159 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013160 .info = snd_hda_mixer_amp_switch_info,
13161 .get = snd_hda_mixer_amp_switch_get,
13162 .put = alc268_acer_master_sw_put,
13163 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13164 },
13165 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13166 { }
13167};
13168
Takashi Iwaid2738092007-08-16 14:59:45 +020013169static struct snd_kcontrol_new alc268_acer_mixer[] = {
13170 /* output mixer control */
13171 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13172 {
13173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13174 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013175 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013176 .info = snd_hda_mixer_amp_switch_info,
13177 .get = snd_hda_mixer_amp_switch_get,
13178 .put = alc268_acer_master_sw_put,
13179 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13180 },
David Henningsson5f99f862011-01-04 15:24:24 +010013181 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13182 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13183 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013184 { }
13185};
13186
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013187static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13188 /* output mixer control */
13189 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13190 {
13191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13192 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013193 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013194 .info = snd_hda_mixer_amp_switch_info,
13195 .get = snd_hda_mixer_amp_switch_get,
13196 .put = alc268_acer_master_sw_put,
13197 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13198 },
David Henningsson5f99f862011-01-04 15:24:24 +010013199 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13200 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013201 { }
13202};
13203
Kailang Yang8ef355d2008-08-26 13:10:22 +020013204static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13205 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13206 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13207 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13208 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13209 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13211 { }
13212};
13213
Takashi Iwaid2738092007-08-16 14:59:45 +020013214static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013215 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13216 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013219 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13220 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013221 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13222 { }
13223};
13224
13225/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013226#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013227#define alc268_toshiba_setup alc262_hippo_setup
13228#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013229
13230static void alc268_acer_unsol_event(struct hda_codec *codec,
13231 unsigned int res)
13232{
Takashi Iwai889c4392007-08-23 18:56:52 +020013233 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013234 return;
13235 alc268_acer_automute(codec, 1);
13236}
13237
Takashi Iwai889c4392007-08-23 18:56:52 +020013238static void alc268_acer_init_hook(struct hda_codec *codec)
13239{
13240 alc268_acer_automute(codec, 1);
13241}
13242
Kailang Yang8ef355d2008-08-26 13:10:22 +020013243/* toggle speaker-output according to the hp-jack state */
13244static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13245{
13246 unsigned int present;
13247 unsigned char bits;
13248
Wu Fengguang864f92b2009-11-18 12:38:02 +080013249 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013250 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013251 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013252 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013253 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013254 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013255}
13256
Kailang Yang8ef355d2008-08-26 13:10:22 +020013257static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13258 unsigned int res)
13259{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013260 switch (res >> 26) {
13261 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013262 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013263 break;
13264 case ALC880_MIC_EVENT:
13265 alc_mic_automute(codec);
13266 break;
13267 }
13268}
13269
13270static void alc268_acer_lc_setup(struct hda_codec *codec)
13271{
13272 struct alc_spec *spec = codec->spec;
13273 spec->ext_mic.pin = 0x18;
13274 spec->ext_mic.mux_idx = 0;
13275 spec->int_mic.pin = 0x12;
13276 spec->int_mic.mux_idx = 6;
13277 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013278}
13279
13280static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13281{
13282 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013283 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013284}
13285
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013286static struct snd_kcontrol_new alc268_dell_mixer[] = {
13287 /* output mixer control */
13288 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13289 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13290 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013292 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13293 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013294 { }
13295};
13296
13297static struct hda_verb alc268_dell_verbs[] = {
13298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13300 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013301 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013302 { }
13303};
13304
13305/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013306static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013307{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013308 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013309
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013310 spec->autocfg.hp_pins[0] = 0x15;
13311 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013312 spec->ext_mic.pin = 0x18;
13313 spec->ext_mic.mux_idx = 0;
13314 spec->int_mic.pin = 0x19;
13315 spec->int_mic.mux_idx = 1;
13316 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013317}
13318
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013319static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13320 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13321 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13322 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13323 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13324 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13325 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013326 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13327 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013328 { }
13329};
13330
13331static struct hda_verb alc267_quanta_il1_verbs[] = {
13332 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13333 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13334 { }
13335};
13336
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013337static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013338{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013339 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013340 spec->autocfg.hp_pins[0] = 0x15;
13341 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013342 spec->ext_mic.pin = 0x18;
13343 spec->ext_mic.mux_idx = 0;
13344 spec->int_mic.pin = 0x19;
13345 spec->int_mic.mux_idx = 1;
13346 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013347}
13348
Kailang Yanga361d842007-06-05 12:30:55 +020013349/*
13350 * generic initialization of ADC, input mixers and output mixers
13351 */
13352static struct hda_verb alc268_base_init_verbs[] = {
13353 /* Unmute DAC0-1 and set vol = 0 */
13354 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013355 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013356
13357 /*
13358 * Set up output mixers (0x0c - 0x0e)
13359 */
13360 /* set vol=0 to output mixers */
13361 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013362 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13363
13364 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13365 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13366
13367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13369 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13370 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13372 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13373 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13374 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13375
13376 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13377 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13378 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013381
13382 /* set PCBEEP vol = 0, mute connections */
13383 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13384 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13385 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013386
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013387 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013388
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013389 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13391 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013393
Kailang Yanga361d842007-06-05 12:30:55 +020013394 { }
13395};
13396
13397/*
13398 * generic initialization of ADC, input mixers and output mixers
13399 */
13400static struct hda_verb alc268_volume_init_verbs[] = {
13401 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013402 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13403 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013404
13405 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13406 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13408 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13409 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13410
Kailang Yanga361d842007-06-05 12:30:55 +020013411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013412 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13413 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13414
13415 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013416 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013417
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013418 /* set PCBEEP vol = 0, mute connections */
13419 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13420 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13421 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013422
13423 { }
13424};
13425
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013426static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13427 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13428 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13429 { } /* end */
13430};
13431
Kailang Yanga361d842007-06-05 12:30:55 +020013432static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13433 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13434 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013435 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013436 { } /* end */
13437};
13438
13439static struct snd_kcontrol_new alc268_capture_mixer[] = {
13440 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13441 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13442 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13443 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013444 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013445 { } /* end */
13446};
13447
13448static struct hda_input_mux alc268_capture_source = {
13449 .num_items = 4,
13450 .items = {
13451 { "Mic", 0x0 },
13452 { "Front Mic", 0x1 },
13453 { "Line", 0x2 },
13454 { "CD", 0x3 },
13455 },
13456};
13457
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013458static struct hda_input_mux alc268_acer_capture_source = {
13459 .num_items = 3,
13460 .items = {
13461 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013462 { "Internal Mic", 0x1 },
13463 { "Line", 0x2 },
13464 },
13465};
13466
13467static struct hda_input_mux alc268_acer_dmic_capture_source = {
13468 .num_items = 3,
13469 .items = {
13470 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013471 { "Internal Mic", 0x6 },
13472 { "Line", 0x2 },
13473 },
13474};
13475
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013476#ifdef CONFIG_SND_DEBUG
13477static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013478 /* Volume widgets */
13479 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13480 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13481 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13482 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13483 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13484 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13485 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13486 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13487 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13488 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13489 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13490 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13491 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013492 /* The below appears problematic on some hardwares */
13493 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013494 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13495 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13496 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13497 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13498
13499 /* Modes for retasking pin widgets */
13500 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13501 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13502 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13503 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13504
13505 /* Controls for GPIO pins, assuming they are configured as outputs */
13506 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13507 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13508 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13509 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13510
13511 /* Switches to allow the digital SPDIF output pin to be enabled.
13512 * The ALC268 does not have an SPDIF input.
13513 */
13514 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13515
13516 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13517 * this output to turn on an external amplifier.
13518 */
13519 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13520 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13521
13522 { } /* end */
13523};
13524#endif
13525
Kailang Yanga361d842007-06-05 12:30:55 +020013526/* create input playback/capture controls for the given pin */
13527static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13528 const char *ctlname, int idx)
13529{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013530 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013531 int err;
13532
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013533 switch (nid) {
13534 case 0x14:
13535 case 0x16:
13536 dac = 0x02;
13537 break;
13538 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013539 case 0x1a: /* ALC259/269 only */
13540 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013541 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013542 dac = 0x03;
13543 break;
13544 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013545 snd_printd(KERN_WARNING "hda_codec: "
13546 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013547 return 0;
13548 }
13549 if (spec->multiout.dac_nids[0] != dac &&
13550 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013551 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013552 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013553 HDA_OUTPUT));
13554 if (err < 0)
13555 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013556 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13557 }
13558
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013559 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013560 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013561 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013562 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013563 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013564 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013565 if (err < 0)
13566 return err;
13567 return 0;
13568}
13569
13570/* add playback controls from the parsed DAC table */
13571static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13572 const struct auto_pin_cfg *cfg)
13573{
13574 hda_nid_t nid;
13575 int err;
13576
Kailang Yanga361d842007-06-05 12:30:55 +020013577 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013578
13579 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013580 if (nid) {
13581 const char *name;
13582 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13583 name = "Speaker";
13584 else
13585 name = "Front";
13586 err = alc268_new_analog_output(spec, nid, name, 0);
13587 if (err < 0)
13588 return err;
13589 }
Kailang Yanga361d842007-06-05 12:30:55 +020013590
13591 nid = cfg->speaker_pins[0];
13592 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013593 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013594 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13595 if (err < 0)
13596 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013597 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013598 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13599 if (err < 0)
13600 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013601 }
13602 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013603 if (nid) {
13604 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13605 if (err < 0)
13606 return err;
13607 }
Kailang Yanga361d842007-06-05 12:30:55 +020013608
13609 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13610 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013611 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013612 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013613 if (err < 0)
13614 return err;
13615 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013616 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013617}
13618
13619/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013620static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013621 const struct auto_pin_cfg *cfg)
13622{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013623 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013624}
13625
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013626static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13627 hda_nid_t nid, int pin_type)
13628{
13629 int idx;
13630
13631 alc_set_pin_output(codec, nid, pin_type);
13632 if (nid == 0x14 || nid == 0x16)
13633 idx = 0;
13634 else
13635 idx = 1;
13636 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13637}
13638
13639static void alc268_auto_init_multi_out(struct hda_codec *codec)
13640{
13641 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013642 int i;
13643
13644 for (i = 0; i < spec->autocfg.line_outs; i++) {
13645 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013646 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13647 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13648 }
13649}
13650
13651static void alc268_auto_init_hp_out(struct hda_codec *codec)
13652{
13653 struct alc_spec *spec = codec->spec;
13654 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013655 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013656
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013657 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13658 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013659 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013660 }
13661 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13662 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013663 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013664 }
13665 if (spec->autocfg.mono_out_pin)
13666 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13667 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013668}
13669
Kailang Yanga361d842007-06-05 12:30:55 +020013670static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13671{
13672 struct alc_spec *spec = codec->spec;
13673 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13674 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13675 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13676 unsigned int dac_vol1, dac_vol2;
13677
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013678 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013679 snd_hda_codec_write(codec, speaker_nid, 0,
13680 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013681 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013682 snd_hda_codec_write(codec, 0x0f, 0,
13683 AC_VERB_SET_AMP_GAIN_MUTE,
13684 AMP_IN_UNMUTE(1));
13685 snd_hda_codec_write(codec, 0x10, 0,
13686 AC_VERB_SET_AMP_GAIN_MUTE,
13687 AMP_IN_UNMUTE(1));
13688 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013689 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013690 snd_hda_codec_write(codec, 0x0f, 0,
13691 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13692 snd_hda_codec_write(codec, 0x10, 0,
13693 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13694 }
13695
13696 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013697 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013698 dac_vol2 = AMP_OUT_ZERO;
13699 else if (line_nid == 0x15)
13700 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013701 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013702 dac_vol2 = AMP_OUT_ZERO;
13703 else if (hp_nid == 0x15)
13704 dac_vol1 = AMP_OUT_ZERO;
13705 if (line_nid != 0x16 || hp_nid != 0x16 ||
13706 spec->autocfg.line_out_pins[1] != 0x16 ||
13707 spec->autocfg.line_out_pins[2] != 0x16)
13708 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13709
13710 snd_hda_codec_write(codec, 0x02, 0,
13711 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13712 snd_hda_codec_write(codec, 0x03, 0,
13713 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13714}
13715
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013716/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013717#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13718#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013719#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013720#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13721
13722/*
13723 * BIOS auto configuration
13724 */
13725static int alc268_parse_auto_config(struct hda_codec *codec)
13726{
13727 struct alc_spec *spec = codec->spec;
13728 int err;
13729 static hda_nid_t alc268_ignore[] = { 0 };
13730
13731 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13732 alc268_ignore);
13733 if (err < 0)
13734 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013735 if (!spec->autocfg.line_outs) {
13736 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13737 spec->multiout.max_channels = 2;
13738 spec->no_analog = 1;
13739 goto dig_only;
13740 }
Kailang Yanga361d842007-06-05 12:30:55 +020013741 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013742 }
Kailang Yanga361d842007-06-05 12:30:55 +020013743 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13744 if (err < 0)
13745 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013746 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013747 if (err < 0)
13748 return err;
13749
13750 spec->multiout.max_channels = 2;
13751
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013752 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013753 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013754 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013755 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013756 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013757
Takashi Iwai892981f2009-03-02 08:04:35 +010013758 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013759 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013760
Takashi Iwaid88897e2008-10-31 15:01:37 +010013761 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013762 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013763 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013764
Takashi Iwai776e1842007-08-29 15:07:11 +020013765 err = alc_auto_add_mic_boost(codec);
13766 if (err < 0)
13767 return err;
13768
Kailang Yang6227cdc2010-02-25 08:36:52 +010013769 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013770
Kailang Yanga361d842007-06-05 12:30:55 +020013771 return 1;
13772}
13773
Kailang Yanga361d842007-06-05 12:30:55 +020013774#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13775
13776/* init callback for auto-configuration model -- overriding the default init */
13777static void alc268_auto_init(struct hda_codec *codec)
13778{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013779 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013780 alc268_auto_init_multi_out(codec);
13781 alc268_auto_init_hp_out(codec);
13782 alc268_auto_init_mono_speaker_out(codec);
13783 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013784 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013785 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013786 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013787}
13788
13789/*
13790 * configuration and preset
13791 */
13792static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013793 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013794 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013795 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013796 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013797 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013798 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013799 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013800 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013801#ifdef CONFIG_SND_DEBUG
13802 [ALC268_TEST] = "test",
13803#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013804 [ALC268_AUTO] = "auto",
13805};
13806
13807static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013808 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013809 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013810 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013811 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013812 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013813 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13814 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013815 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013816 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13817 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013818 /* almost compatible with toshiba but with optional digital outs;
13819 * auto-probing seems working fine
13820 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013821 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013822 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013823 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013824 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013825 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013826 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013827 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013828 {}
13829};
13830
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013831/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13832static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13833 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13834 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13835 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13836 ALC268_TOSHIBA),
13837 {}
13838};
13839
Kailang Yanga361d842007-06-05 12:30:55 +020013840static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013841 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013842 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13843 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013844 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13845 alc267_quanta_il1_verbs },
13846 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13847 .dac_nids = alc268_dac_nids,
13848 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13849 .adc_nids = alc268_adc_nids_alt,
13850 .hp_nid = 0x03,
13851 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13852 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013853 .unsol_event = alc_sku_unsol_event,
13854 .setup = alc267_quanta_il1_setup,
13855 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013856 },
Kailang Yanga361d842007-06-05 12:30:55 +020013857 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013858 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13859 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013860 .init_verbs = { alc268_base_init_verbs },
13861 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13862 .dac_nids = alc268_dac_nids,
13863 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13864 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013865 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013866 .hp_nid = 0x03,
13867 .dig_out_nid = ALC268_DIGOUT_NID,
13868 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13869 .channel_mode = alc268_modes,
13870 .input_mux = &alc268_capture_source,
13871 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013872 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013873 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013874 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013875 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13876 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013877 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13878 .dac_nids = alc268_dac_nids,
13879 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13880 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013881 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013882 .hp_nid = 0x03,
13883 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13884 .channel_mode = alc268_modes,
13885 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013886 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013887 .setup = alc268_toshiba_setup,
13888 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013889 },
13890 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013891 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013892 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013893 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13894 alc268_acer_verbs },
13895 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13896 .dac_nids = alc268_dac_nids,
13897 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13898 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013899 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013900 .hp_nid = 0x02,
13901 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13902 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013903 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013904 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013905 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013906 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013907 [ALC268_ACER_DMIC] = {
13908 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13909 alc268_beep_mixer },
13910 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13911 alc268_acer_verbs },
13912 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13913 .dac_nids = alc268_dac_nids,
13914 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13915 .adc_nids = alc268_adc_nids_alt,
13916 .capsrc_nids = alc268_capsrc_nids,
13917 .hp_nid = 0x02,
13918 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13919 .channel_mode = alc268_modes,
13920 .input_mux = &alc268_acer_dmic_capture_source,
13921 .unsol_event = alc268_acer_unsol_event,
13922 .init_hook = alc268_acer_init_hook,
13923 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013924 [ALC268_ACER_ASPIRE_ONE] = {
13925 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013926 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013927 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013928 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13929 alc268_acer_aspire_one_verbs },
13930 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13931 .dac_nids = alc268_dac_nids,
13932 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13933 .adc_nids = alc268_adc_nids_alt,
13934 .capsrc_nids = alc268_capsrc_nids,
13935 .hp_nid = 0x03,
13936 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13937 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013938 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013939 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013940 .init_hook = alc268_acer_lc_init_hook,
13941 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013942 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013943 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13944 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013945 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13946 alc268_dell_verbs },
13947 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13948 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013949 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13950 .adc_nids = alc268_adc_nids_alt,
13951 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013952 .hp_nid = 0x02,
13953 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13954 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013955 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013956 .setup = alc268_dell_setup,
13957 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013958 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013959 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013960 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13961 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013962 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13963 alc268_toshiba_verbs },
13964 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13965 .dac_nids = alc268_dac_nids,
13966 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13967 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013968 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013969 .hp_nid = 0x03,
13970 .dig_out_nid = ALC268_DIGOUT_NID,
13971 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13972 .channel_mode = alc268_modes,
13973 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013974 .setup = alc268_toshiba_setup,
13975 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013976 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013977#ifdef CONFIG_SND_DEBUG
13978 [ALC268_TEST] = {
13979 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13980 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13981 alc268_volume_init_verbs },
13982 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13983 .dac_nids = alc268_dac_nids,
13984 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13985 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013986 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013987 .hp_nid = 0x03,
13988 .dig_out_nid = ALC268_DIGOUT_NID,
13989 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13990 .channel_mode = alc268_modes,
13991 .input_mux = &alc268_capture_source,
13992 },
13993#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013994};
13995
13996static int patch_alc268(struct hda_codec *codec)
13997{
13998 struct alc_spec *spec;
13999 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010014000 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020014001
Julia Lawallef86f582009-12-19 08:18:03 +010014002 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020014003 if (spec == NULL)
14004 return -ENOMEM;
14005
14006 codec->spec = spec;
14007
14008 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
14009 alc268_models,
14010 alc268_cfg_tbl);
14011
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014012 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
14013 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010014014 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014015
Kailang Yanga361d842007-06-05 12:30:55 +020014016 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014017 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14018 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020014019 board_config = ALC268_AUTO;
14020 }
14021
14022 if (board_config == ALC268_AUTO) {
14023 /* automatic parse from the BIOS config */
14024 err = alc268_parse_auto_config(codec);
14025 if (err < 0) {
14026 alc_free(codec);
14027 return err;
14028 } else if (!err) {
14029 printk(KERN_INFO
14030 "hda_codec: Cannot set up configuration "
14031 "from BIOS. Using base mode...\n");
14032 board_config = ALC268_3ST;
14033 }
14034 }
14035
14036 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014037 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014038
Kailang Yanga361d842007-06-05 12:30:55 +020014039 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14040 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014041 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014042
Kailang Yanga361d842007-06-05 12:30:55 +020014043 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14044
Takashi Iwai22971e32009-02-10 11:56:44 +010014045 has_beep = 0;
14046 for (i = 0; i < spec->num_mixers; i++) {
14047 if (spec->mixers[i] == alc268_beep_mixer) {
14048 has_beep = 1;
14049 break;
14050 }
14051 }
14052
14053 if (has_beep) {
14054 err = snd_hda_attach_beep_device(codec, 0x1);
14055 if (err < 0) {
14056 alc_free(codec);
14057 return err;
14058 }
14059 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14060 /* override the amp caps for beep generator */
14061 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014062 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14063 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14064 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14065 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014066 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014067
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014068 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014069 /* check whether NID 0x07 is valid */
14070 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010014071 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014072
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014073 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014074 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014075 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014076 if (spec->auto_mic ||
14077 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014078 spec->adc_nids = alc268_adc_nids_alt;
14079 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014080 if (spec->auto_mic)
14081 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014082 if (spec->auto_mic || spec->input_mux->num_items == 1)
14083 add_mixer(spec, alc268_capture_nosrc_mixer);
14084 else
14085 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014086 } else {
14087 spec->adc_nids = alc268_adc_nids;
14088 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014089 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014090 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014091 /* set default input source */
14092 for (i = 0; i < spec->num_adc_nids; i++)
14093 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14094 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014095 i < spec->num_mux_defs ?
14096 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014097 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014098 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014099
14100 spec->vmaster_nid = 0x02;
14101
Kailang Yanga361d842007-06-05 12:30:55 +020014102 codec->patch_ops = alc_patch_ops;
14103 if (board_config == ALC268_AUTO)
14104 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014105
Kailang Yangbf1b0222010-10-21 08:49:56 +020014106 alc_init_jacks(codec);
14107
Kailang Yanga361d842007-06-05 12:30:55 +020014108 return 0;
14109}
14110
14111/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014112 * ALC269 channel source setting (2 channel)
14113 */
14114#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14115
14116#define alc269_dac_nids alc260_dac_nids
14117
14118static hda_nid_t alc269_adc_nids[1] = {
14119 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014120 0x08,
14121};
14122
Takashi Iwaie01bf502008-08-21 16:25:07 +020014123static hda_nid_t alc269_capsrc_nids[1] = {
14124 0x23,
14125};
14126
Kailang Yang84898e82010-02-04 14:16:14 +010014127static hda_nid_t alc269vb_adc_nids[1] = {
14128 /* ADC1 */
14129 0x09,
14130};
14131
14132static hda_nid_t alc269vb_capsrc_nids[1] = {
14133 0x22,
14134};
14135
Takashi Iwai66946352010-03-29 17:21:45 +020014136static hda_nid_t alc269_adc_candidates[] = {
14137 0x08, 0x09, 0x07,
14138};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014139
Kailang Yangf6a92242007-12-13 16:52:54 +010014140#define alc269_modes alc260_modes
14141#define alc269_capture_source alc880_lg_lw_capture_source
14142
14143static struct snd_kcontrol_new alc269_base_mixer[] = {
14144 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14145 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14146 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14147 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14148 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014150 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014151 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14152 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014153 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014154 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14155 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14156 { } /* end */
14157};
14158
Kailang Yang60db6b52008-08-26 13:13:00 +020014159static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14160 /* output mixer control */
14161 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14162 {
14163 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14164 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014165 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014166 .info = snd_hda_mixer_amp_switch_info,
14167 .get = snd_hda_mixer_amp_switch_get,
14168 .put = alc268_acer_master_sw_put,
14169 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14170 },
14171 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14172 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014173 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014174 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14175 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014176 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014177 { }
14178};
14179
Tony Vroon64154832008-11-06 15:08:49 +000014180static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14181 /* output mixer control */
14182 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14183 {
14184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14185 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014186 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014187 .info = snd_hda_mixer_amp_switch_info,
14188 .get = snd_hda_mixer_amp_switch_get,
14189 .put = alc268_acer_master_sw_put,
14190 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14191 },
14192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014194 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014195 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14196 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014197 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014198 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14199 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014200 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014201 { }
14202};
14203
Kailang Yang84898e82010-02-04 14:16:14 +010014204static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014205 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014206 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014207 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014209 { } /* end */
14210};
14211
Kailang Yang84898e82010-02-04 14:16:14 +010014212static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14213 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14214 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14216 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14217 { } /* end */
14218};
14219
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014220static struct snd_kcontrol_new alc269_asus_mixer[] = {
14221 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14222 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14223 { } /* end */
14224};
14225
Kailang Yangf6a92242007-12-13 16:52:54 +010014226/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014227static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14228 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14229 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014230 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14231 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014232 { } /* end */
14233};
14234
14235static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014236 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14237 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014238 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014239 { } /* end */
14240};
14241
Kailang Yang84898e82010-02-04 14:16:14 +010014242static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14243 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14244 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014245 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14246 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014247 { } /* end */
14248};
14249
14250static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14251 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14252 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014253 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014254 { } /* end */
14255};
14256
Takashi Iwai26f5df22008-11-03 17:39:46 +010014257/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014258#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014259
Kailang Yang60db6b52008-08-26 13:13:00 +020014260static struct hda_verb alc269_quanta_fl1_verbs[] = {
14261 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14262 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14264 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14265 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14266 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14267 { }
14268};
14269
Tony Vroon64154832008-11-06 15:08:49 +000014270static struct hda_verb alc269_lifebook_verbs[] = {
14271 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14272 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14273 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14275 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14276 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14277 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14278 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14279 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14280 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14281 { }
14282};
14283
Kailang Yang60db6b52008-08-26 13:13:00 +020014284/* toggle speaker-output according to the hp-jack state */
14285static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14286{
14287 unsigned int present;
14288 unsigned char bits;
14289
Wu Fengguang864f92b2009-11-18 12:38:02 +080014290 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014291 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014292 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014293 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014294 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014295 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014296
14297 snd_hda_codec_write(codec, 0x20, 0,
14298 AC_VERB_SET_COEF_INDEX, 0x0c);
14299 snd_hda_codec_write(codec, 0x20, 0,
14300 AC_VERB_SET_PROC_COEF, 0x680);
14301
14302 snd_hda_codec_write(codec, 0x20, 0,
14303 AC_VERB_SET_COEF_INDEX, 0x0c);
14304 snd_hda_codec_write(codec, 0x20, 0,
14305 AC_VERB_SET_PROC_COEF, 0x480);
14306}
14307
Tony Vroon64154832008-11-06 15:08:49 +000014308/* toggle speaker-output according to the hp-jacks state */
14309static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14310{
14311 unsigned int present;
14312 unsigned char bits;
14313
14314 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014315 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014316
14317 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014318 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014319
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014320 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014321 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014322 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014323 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014324 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014325
14326 snd_hda_codec_write(codec, 0x20, 0,
14327 AC_VERB_SET_COEF_INDEX, 0x0c);
14328 snd_hda_codec_write(codec, 0x20, 0,
14329 AC_VERB_SET_PROC_COEF, 0x680);
14330
14331 snd_hda_codec_write(codec, 0x20, 0,
14332 AC_VERB_SET_COEF_INDEX, 0x0c);
14333 snd_hda_codec_write(codec, 0x20, 0,
14334 AC_VERB_SET_PROC_COEF, 0x480);
14335}
14336
Tony Vroon64154832008-11-06 15:08:49 +000014337static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14338{
14339 unsigned int present_laptop;
14340 unsigned int present_dock;
14341
Wu Fengguang864f92b2009-11-18 12:38:02 +080014342 present_laptop = snd_hda_jack_detect(codec, 0x18);
14343 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014344
14345 /* Laptop mic port overrides dock mic port, design decision */
14346 if (present_dock)
14347 snd_hda_codec_write(codec, 0x23, 0,
14348 AC_VERB_SET_CONNECT_SEL, 0x3);
14349 if (present_laptop)
14350 snd_hda_codec_write(codec, 0x23, 0,
14351 AC_VERB_SET_CONNECT_SEL, 0x0);
14352 if (!present_dock && !present_laptop)
14353 snd_hda_codec_write(codec, 0x23, 0,
14354 AC_VERB_SET_CONNECT_SEL, 0x1);
14355}
14356
Kailang Yang60db6b52008-08-26 13:13:00 +020014357static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14358 unsigned int res)
14359{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014360 switch (res >> 26) {
14361 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014362 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014363 break;
14364 case ALC880_MIC_EVENT:
14365 alc_mic_automute(codec);
14366 break;
14367 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014368}
14369
Tony Vroon64154832008-11-06 15:08:49 +000014370static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14371 unsigned int res)
14372{
14373 if ((res >> 26) == ALC880_HP_EVENT)
14374 alc269_lifebook_speaker_automute(codec);
14375 if ((res >> 26) == ALC880_MIC_EVENT)
14376 alc269_lifebook_mic_autoswitch(codec);
14377}
14378
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014379static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14380{
14381 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014382 spec->autocfg.hp_pins[0] = 0x15;
14383 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014384 spec->ext_mic.pin = 0x18;
14385 spec->ext_mic.mux_idx = 0;
14386 spec->int_mic.pin = 0x19;
14387 spec->int_mic.mux_idx = 1;
14388 spec->auto_mic = 1;
14389}
14390
Kailang Yang60db6b52008-08-26 13:13:00 +020014391static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14392{
14393 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014394 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014395}
14396
Tony Vroon64154832008-11-06 15:08:49 +000014397static void alc269_lifebook_init_hook(struct hda_codec *codec)
14398{
14399 alc269_lifebook_speaker_automute(codec);
14400 alc269_lifebook_mic_autoswitch(codec);
14401}
14402
Kailang Yang84898e82010-02-04 14:16:14 +010014403static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014404 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14405 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14406 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14408 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14409 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14410 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14411 {}
14412};
14413
Kailang Yang84898e82010-02-04 14:16:14 +010014414static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014415 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14416 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14417 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14418 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14419 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14420 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14421 {}
14422};
14423
Kailang Yang84898e82010-02-04 14:16:14 +010014424static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14425 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14426 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14427 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14429 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14430 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14431 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14432 {}
14433};
14434
14435static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14436 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14437 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14438 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14439 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14440 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14441 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14442 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14443 {}
14444};
14445
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014446static struct hda_verb alc271_acer_dmic_verbs[] = {
14447 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14448 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14449 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14451 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14452 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14453 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14454 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14455 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14456 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14457 { }
14458};
14459
Kailang Yang60db6b52008-08-26 13:13:00 +020014460/* toggle speaker-output according to the hp-jack state */
14461static void alc269_speaker_automute(struct hda_codec *codec)
14462{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014463 struct alc_spec *spec = codec->spec;
14464 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014465 unsigned int present;
14466 unsigned char bits;
14467
Kailang Yangebb83ee2009-12-17 12:23:00 +010014468 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014469 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014470 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014471 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014472 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014473 HDA_AMP_MUTE, bits);
Kailang Yangbf1b0222010-10-21 08:49:56 +020014474 alc_report_jack(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014475}
14476
Kailang Yang60db6b52008-08-26 13:13:00 +020014477/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014478static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014479 unsigned int res)
14480{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014481 switch (res >> 26) {
14482 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014483 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014484 break;
14485 case ALC880_MIC_EVENT:
14486 alc_mic_automute(codec);
14487 break;
14488 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014489}
14490
Kailang Yang226b1ec2010-04-09 11:01:20 +020014491static void alc269_laptop_amic_setup(struct hda_codec *codec)
14492{
14493 struct alc_spec *spec = codec->spec;
14494 spec->autocfg.hp_pins[0] = 0x15;
14495 spec->autocfg.speaker_pins[0] = 0x14;
14496 spec->ext_mic.pin = 0x18;
14497 spec->ext_mic.mux_idx = 0;
14498 spec->int_mic.pin = 0x19;
14499 spec->int_mic.mux_idx = 1;
14500 spec->auto_mic = 1;
14501}
14502
Kailang Yang84898e82010-02-04 14:16:14 +010014503static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014504{
14505 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014506 spec->autocfg.hp_pins[0] = 0x15;
14507 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014508 spec->ext_mic.pin = 0x18;
14509 spec->ext_mic.mux_idx = 0;
14510 spec->int_mic.pin = 0x12;
14511 spec->int_mic.mux_idx = 5;
14512 spec->auto_mic = 1;
14513}
14514
Kailang Yang226b1ec2010-04-09 11:01:20 +020014515static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014516{
14517 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014518 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014519 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014520 spec->ext_mic.pin = 0x18;
14521 spec->ext_mic.mux_idx = 0;
14522 spec->int_mic.pin = 0x19;
14523 spec->int_mic.mux_idx = 1;
14524 spec->auto_mic = 1;
14525}
14526
Kailang Yang226b1ec2010-04-09 11:01:20 +020014527static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14528{
14529 struct alc_spec *spec = codec->spec;
14530 spec->autocfg.hp_pins[0] = 0x21;
14531 spec->autocfg.speaker_pins[0] = 0x14;
14532 spec->ext_mic.pin = 0x18;
14533 spec->ext_mic.mux_idx = 0;
14534 spec->int_mic.pin = 0x12;
14535 spec->int_mic.mux_idx = 6;
14536 spec->auto_mic = 1;
14537}
14538
Kailang Yang84898e82010-02-04 14:16:14 +010014539static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014540{
14541 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014542 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014543}
14544
Kailang Yangf6a92242007-12-13 16:52:54 +010014545/*
14546 * generic initialization of ADC, input mixers and output mixers
14547 */
14548static struct hda_verb alc269_init_verbs[] = {
14549 /*
14550 * Unmute ADC0 and set the default input to mic-in
14551 */
Kailang Yang84898e82010-02-04 14:16:14 +010014552 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014553
14554 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014555 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014556 */
14557 /* set vol=0 to output mixers */
14558 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14559 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14560
14561 /* set up input amps for analog loopback */
14562 /* Amp Indices: DAC = 0, mixer = 1 */
14563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14565 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14566 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14567 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14569
14570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14571 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14572 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14573 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14574 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14575 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14576 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14577
14578 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014580
Kailang Yang84898e82010-02-04 14:16:14 +010014581 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014582 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14583 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014584 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014585
14586 /* set EAPD */
14587 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014588 { }
14589};
14590
14591static struct hda_verb alc269vb_init_verbs[] = {
14592 /*
14593 * Unmute ADC0 and set the default input to mic-in
14594 */
14595 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14596
14597 /*
14598 * Set up output mixers (0x02 - 0x03)
14599 */
14600 /* set vol=0 to output mixers */
14601 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14602 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14603
14604 /* set up input amps for analog loopback */
14605 /* Amp Indices: DAC = 0, mixer = 1 */
14606 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14607 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14608 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14609 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14610 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14611 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14612
14613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14614 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14615 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14616 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14617 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14618 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14619 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14620
14621 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14622 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14623
14624 /* FIXME: use Mux-type input source selection */
14625 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14626 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14627 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14628
14629 /* set EAPD */
14630 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014631 { }
14632};
14633
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014634#define alc269_auto_create_multi_out_ctls \
14635 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014636#define alc269_auto_create_input_ctls \
14637 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014638
14639#ifdef CONFIG_SND_HDA_POWER_SAVE
14640#define alc269_loopbacks alc880_loopbacks
14641#endif
14642
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014643/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014644#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14645#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14646#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14647#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14648
Takashi Iwaif03d3112009-03-05 14:18:16 +010014649static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14650 .substreams = 1,
14651 .channels_min = 2,
14652 .channels_max = 8,
14653 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14654 /* NID is set in alc_build_pcms */
14655 .ops = {
14656 .open = alc880_playback_pcm_open,
14657 .prepare = alc880_playback_pcm_prepare,
14658 .cleanup = alc880_playback_pcm_cleanup
14659 },
14660};
14661
14662static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14663 .substreams = 1,
14664 .channels_min = 2,
14665 .channels_max = 2,
14666 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14667 /* NID is set in alc_build_pcms */
14668};
14669
Takashi Iwaiad358792010-03-30 18:00:59 +020014670#ifdef CONFIG_SND_HDA_POWER_SAVE
14671static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14672{
14673 switch (codec->subsystem_id) {
14674 case 0x103c1586:
14675 return 1;
14676 }
14677 return 0;
14678}
14679
14680static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14681{
14682 /* update mute-LED according to the speaker mute state */
14683 if (nid == 0x01 || nid == 0x14) {
14684 int pinval;
14685 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14686 HDA_AMP_MUTE)
14687 pinval = 0x24;
14688 else
14689 pinval = 0x20;
14690 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014691 snd_hda_codec_update_cache(codec, 0x19, 0,
14692 AC_VERB_SET_PIN_WIDGET_CONTROL,
14693 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014694 }
14695 return alc_check_power_status(codec, nid);
14696}
14697#endif /* CONFIG_SND_HDA_POWER_SAVE */
14698
Takashi Iwai840b64c2010-07-13 22:49:01 +020014699static int alc275_setup_dual_adc(struct hda_codec *codec)
14700{
14701 struct alc_spec *spec = codec->spec;
14702
14703 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14704 return 0;
14705 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14706 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14707 if (spec->ext_mic.pin <= 0x12) {
14708 spec->private_adc_nids[0] = 0x08;
14709 spec->private_adc_nids[1] = 0x11;
14710 spec->private_capsrc_nids[0] = 0x23;
14711 spec->private_capsrc_nids[1] = 0x22;
14712 } else {
14713 spec->private_adc_nids[0] = 0x11;
14714 spec->private_adc_nids[1] = 0x08;
14715 spec->private_capsrc_nids[0] = 0x22;
14716 spec->private_capsrc_nids[1] = 0x23;
14717 }
14718 spec->adc_nids = spec->private_adc_nids;
14719 spec->capsrc_nids = spec->private_capsrc_nids;
14720 spec->num_adc_nids = 2;
14721 spec->dual_adc_switch = 1;
14722 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14723 spec->adc_nids[0], spec->adc_nids[1]);
14724 return 1;
14725 }
14726 return 0;
14727}
14728
Takashi Iwaid433a672010-09-20 15:11:54 +020014729/* different alc269-variants */
14730enum {
14731 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014732 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014733 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014734 ALC269_TYPE_ALC269VB,
14735 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014736 ALC269_TYPE_ALC271X,
14737};
14738
Kailang Yangf6a92242007-12-13 16:52:54 +010014739/*
14740 * BIOS auto configuration
14741 */
14742static int alc269_parse_auto_config(struct hda_codec *codec)
14743{
14744 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014745 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014746 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14747
14748 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14749 alc269_ignore);
14750 if (err < 0)
14751 return err;
14752
14753 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14754 if (err < 0)
14755 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014756 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14757 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14758 else
14759 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14760 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014761 if (err < 0)
14762 return err;
14763
14764 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14765
Takashi Iwai757899a2010-07-30 10:48:14 +020014766 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014767
Takashi Iwai603c4012008-07-30 15:01:44 +020014768 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014769 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014770
Takashi Iwaid433a672010-09-20 15:11:54 +020014771 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014772 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014773 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014774 } else {
14775 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014776 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014777 }
14778
Kailang Yangf6a92242007-12-13 16:52:54 +010014779 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014780 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014781
14782 if (!alc275_setup_dual_adc(codec))
14783 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14784 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014785
Takashi Iwaie01bf502008-08-21 16:25:07 +020014786 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014787 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014788 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14789 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014790
14791 err = alc_auto_add_mic_boost(codec);
14792 if (err < 0)
14793 return err;
14794
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014795 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014796 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014797
Kailang Yangf6a92242007-12-13 16:52:54 +010014798 return 1;
14799}
14800
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014801#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14802#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014803#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14804
14805
14806/* init callback for auto-configuration model -- overriding the default init */
14807static void alc269_auto_init(struct hda_codec *codec)
14808{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014809 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014810 alc269_auto_init_multi_out(codec);
14811 alc269_auto_init_hp_out(codec);
14812 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014813 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014814 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014815 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014816}
14817
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014818#ifdef SND_HDA_NEEDS_RESUME
14819static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14820{
14821 int val = alc_read_coef_idx(codec, 0x04);
14822 if (power_up)
14823 val |= 1 << 11;
14824 else
14825 val &= ~(1 << 11);
14826 alc_write_coef_idx(codec, 0x04, val);
14827}
14828
Kailang Yang977ddd62010-09-15 10:02:29 +020014829#ifdef CONFIG_SND_HDA_POWER_SAVE
14830static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14831{
14832 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014833
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014834 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14835 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014836 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014837 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014838 msleep(150);
14839 }
14840
14841 alc_shutup(codec);
14842 if (spec && spec->power_hook)
14843 spec->power_hook(codec);
14844 return 0;
14845}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014846#endif /* CONFIG_SND_HDA_POWER_SAVE */
14847
Kailang Yang977ddd62010-09-15 10:02:29 +020014848static int alc269_resume(struct hda_codec *codec)
14849{
Kailang Yang977ddd62010-09-15 10:02:29 +020014850 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014851 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014852 msleep(150);
14853 }
14854
14855 codec->patch_ops.init(codec);
14856
14857 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014858 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014859 msleep(200);
14860 }
14861
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014862 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14863 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014864
14865 snd_hda_codec_resume_amp(codec);
14866 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014867 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014868 return 0;
14869}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014870#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014871
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014872static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014873 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014874{
14875 int coef;
14876
Takashi Iwai58701122011-01-13 15:41:45 +010014877 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014878 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014879 coef = alc_read_coef_idx(codec, 0x1e);
14880 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14881}
14882
Takashi Iwaiff818c22010-04-12 08:59:25 +020014883enum {
14884 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014885 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014886 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014887 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014888 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014889 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014890 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014891};
14892
Takashi Iwaiff818c22010-04-12 08:59:25 +020014893static const struct alc_fixup alc269_fixups[] = {
14894 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014895 .type = ALC_FIXUP_VERBS,
14896 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014897 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14898 {}
14899 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014900 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014901 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014902 .type = ALC_FIXUP_VERBS,
14903 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014904 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14905 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14906 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14907 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014908 },
14909 .chained = true,
14910 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014911 },
David Henningsson145a9022010-09-16 10:07:53 +020014912 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014913 .type = ALC_FIXUP_VERBS,
14914 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014915 /* Enables internal speaker */
14916 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14917 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14918 {}
14919 }
14920 },
David Henningsson022c92b2010-12-17 20:43:04 +010014921 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014922 .type = ALC_FIXUP_SKU,
14923 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014924 },
David Henningssonac612402010-12-15 09:18:18 +010014925 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014926 .type = ALC_FIXUP_PINS,
14927 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014928 { 0x17, 0x99130111 }, /* subwoofer */
14929 { }
14930 }
14931 },
Kailang Yang357f9152011-01-12 08:12:52 +010014932 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014933 .type = ALC_FIXUP_VERBS,
14934 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014935 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14936 {}
14937 }
14938 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014939 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014940 .type = ALC_FIXUP_FUNC,
14941 .v.func = alc269_fixup_hweq,
14942 .chained = true,
14943 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014944 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014945};
14946
14947static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014948 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014949 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14950 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwaiabdd8f52010-09-21 17:38:14 +020014951 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014952 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson022c92b2010-12-17 20:43:04 +010014953 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14954 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014955 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014956 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014957 {}
14958};
14959
14960
Kailang Yangf6a92242007-12-13 16:52:54 +010014961/*
14962 * configuration and preset
14963 */
14964static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014965 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014966 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014967 [ALC269_AMIC] = "laptop-amic",
14968 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014969 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014970 [ALC269_LIFEBOOK] = "lifebook",
14971 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014972};
14973
14974static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014975 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014976 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014977 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014978 ALC269_AMIC),
14979 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14980 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14981 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14982 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14983 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14984 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14985 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14986 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14987 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14988 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14989 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14990 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14991 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14992 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14993 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14994 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14995 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14996 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14997 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14998 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14999 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
15000 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
15001 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
15002 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
15003 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
15004 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
15005 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
15006 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
15007 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
15008 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
15009 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
15010 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
15011 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
15012 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
15013 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
15014 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020015015 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010015016 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020015017 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010015018 ALC269_DMIC),
15019 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
15020 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020015021 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000015022 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010015023 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
15024 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
15025 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
15026 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
15027 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
15028 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010015029 {}
15030};
15031
15032static struct alc_config_preset alc269_presets[] = {
15033 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015034 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010015035 .init_verbs = { alc269_init_verbs },
15036 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15037 .dac_nids = alc269_dac_nids,
15038 .hp_nid = 0x03,
15039 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15040 .channel_mode = alc269_modes,
15041 .input_mux = &alc269_capture_source,
15042 },
Kailang Yang60db6b52008-08-26 13:13:00 +020015043 [ALC269_QUANTA_FL1] = {
15044 .mixers = { alc269_quanta_fl1_mixer },
15045 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15046 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15047 .dac_nids = alc269_dac_nids,
15048 .hp_nid = 0x03,
15049 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15050 .channel_mode = alc269_modes,
15051 .input_mux = &alc269_capture_source,
15052 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015053 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015054 .init_hook = alc269_quanta_fl1_init_hook,
15055 },
Kailang Yang84898e82010-02-04 14:16:14 +010015056 [ALC269_AMIC] = {
15057 .mixers = { alc269_laptop_mixer },
15058 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015059 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015060 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015061 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15062 .dac_nids = alc269_dac_nids,
15063 .hp_nid = 0x03,
15064 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15065 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015066 .unsol_event = alc269_laptop_unsol_event,
15067 .setup = alc269_laptop_amic_setup,
15068 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015069 },
Kailang Yang84898e82010-02-04 14:16:14 +010015070 [ALC269_DMIC] = {
15071 .mixers = { alc269_laptop_mixer },
15072 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015073 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015074 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015075 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15076 .dac_nids = alc269_dac_nids,
15077 .hp_nid = 0x03,
15078 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15079 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015080 .unsol_event = alc269_laptop_unsol_event,
15081 .setup = alc269_laptop_dmic_setup,
15082 .init_hook = alc269_laptop_inithook,
15083 },
15084 [ALC269VB_AMIC] = {
15085 .mixers = { alc269vb_laptop_mixer },
15086 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15087 .init_verbs = { alc269vb_init_verbs,
15088 alc269vb_laptop_amic_init_verbs },
15089 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15090 .dac_nids = alc269_dac_nids,
15091 .hp_nid = 0x03,
15092 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15093 .channel_mode = alc269_modes,
15094 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015095 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010015096 .init_hook = alc269_laptop_inithook,
15097 },
15098 [ALC269VB_DMIC] = {
15099 .mixers = { alc269vb_laptop_mixer },
15100 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15101 .init_verbs = { alc269vb_init_verbs,
15102 alc269vb_laptop_dmic_init_verbs },
15103 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15104 .dac_nids = alc269_dac_nids,
15105 .hp_nid = 0x03,
15106 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15107 .channel_mode = alc269_modes,
15108 .unsol_event = alc269_laptop_unsol_event,
15109 .setup = alc269vb_laptop_dmic_setup,
15110 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015111 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015112 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015113 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015114 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015115 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015116 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015117 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15118 .dac_nids = alc269_dac_nids,
15119 .hp_nid = 0x03,
15120 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15121 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015122 .unsol_event = alc269_laptop_unsol_event,
15123 .setup = alc269_laptop_dmic_setup,
15124 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015125 },
Tony Vroon64154832008-11-06 15:08:49 +000015126 [ALC269_LIFEBOOK] = {
15127 .mixers = { alc269_lifebook_mixer },
15128 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15129 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15130 .dac_nids = alc269_dac_nids,
15131 .hp_nid = 0x03,
15132 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15133 .channel_mode = alc269_modes,
15134 .input_mux = &alc269_capture_source,
15135 .unsol_event = alc269_lifebook_unsol_event,
15136 .init_hook = alc269_lifebook_init_hook,
15137 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015138 [ALC271_ACER] = {
15139 .mixers = { alc269_asus_mixer },
15140 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15141 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15142 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15143 .dac_nids = alc269_dac_nids,
15144 .adc_nids = alc262_dmic_adc_nids,
15145 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15146 .capsrc_nids = alc262_dmic_capsrc_nids,
15147 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15148 .channel_mode = alc269_modes,
15149 .input_mux = &alc269_capture_source,
15150 .dig_out_nid = ALC880_DIGOUT_NID,
15151 .unsol_event = alc_sku_unsol_event,
15152 .setup = alc269vb_laptop_dmic_setup,
15153 .init_hook = alc_inithook,
15154 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015155};
15156
Kailang Yang977ddd62010-09-15 10:02:29 +020015157static int alc269_fill_coef(struct hda_codec *codec)
15158{
15159 int val;
15160
15161 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15162 alc_write_coef_idx(codec, 0xf, 0x960b);
15163 alc_write_coef_idx(codec, 0xe, 0x8817);
15164 }
15165
15166 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15167 alc_write_coef_idx(codec, 0xf, 0x960b);
15168 alc_write_coef_idx(codec, 0xe, 0x8814);
15169 }
15170
15171 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15172 val = alc_read_coef_idx(codec, 0x04);
15173 /* Power up output pin */
15174 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15175 }
15176
15177 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15178 val = alc_read_coef_idx(codec, 0xd);
15179 if ((val & 0x0c00) >> 10 != 0x1) {
15180 /* Capless ramp up clock control */
15181 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15182 }
15183 val = alc_read_coef_idx(codec, 0x17);
15184 if ((val & 0x01c0) >> 6 != 0x4) {
15185 /* Class D power on reset */
15186 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15187 }
15188 }
15189 return 0;
15190}
15191
Kailang Yangf6a92242007-12-13 16:52:54 +010015192static int patch_alc269(struct hda_codec *codec)
15193{
15194 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015195 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015196 int err;
15197
15198 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15199 if (spec == NULL)
15200 return -ENOMEM;
15201
15202 codec->spec = spec;
15203
Kailang Yangda00c242010-03-19 11:23:45 +010015204 alc_auto_parse_customize_define(codec);
15205
Kailang Yangc793bec2010-12-21 09:14:13 +010015206 if (codec->vendor_id == 0x10ec0269) {
15207 coef = alc_read_coef_idx(codec, 0);
15208 if ((coef & 0x00f0) == 0x0010) {
15209 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15210 spec->cdefine.platform_type == 1) {
15211 alc_codec_rename(codec, "ALC271X");
15212 spec->codec_variant = ALC269_TYPE_ALC271X;
15213 } else if ((coef & 0xf000) == 0x1000) {
15214 spec->codec_variant = ALC269_TYPE_ALC270;
15215 } else if ((coef & 0xf000) == 0x2000) {
15216 alc_codec_rename(codec, "ALC259");
15217 spec->codec_variant = ALC269_TYPE_ALC259;
15218 } else if ((coef & 0xf000) == 0x3000) {
15219 alc_codec_rename(codec, "ALC258");
15220 spec->codec_variant = ALC269_TYPE_ALC258;
15221 } else {
15222 alc_codec_rename(codec, "ALC269VB");
15223 spec->codec_variant = ALC269_TYPE_ALC269VB;
15224 }
15225 } else
15226 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15227 alc269_fill_coef(codec);
15228 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015229
Kailang Yangf6a92242007-12-13 16:52:54 +010015230 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15231 alc269_models,
15232 alc269_cfg_tbl);
15233
15234 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015235 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15236 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015237 board_config = ALC269_AUTO;
15238 }
15239
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015240 if (board_config == ALC269_AUTO) {
15241 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15242 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15243 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015244
Kailang Yangf6a92242007-12-13 16:52:54 +010015245 if (board_config == ALC269_AUTO) {
15246 /* automatic parse from the BIOS config */
15247 err = alc269_parse_auto_config(codec);
15248 if (err < 0) {
15249 alc_free(codec);
15250 return err;
15251 } else if (!err) {
15252 printk(KERN_INFO
15253 "hda_codec: Cannot set up configuration "
15254 "from BIOS. Using base mode...\n");
15255 board_config = ALC269_BASIC;
15256 }
15257 }
15258
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015259 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015260 err = snd_hda_attach_beep_device(codec, 0x1);
15261 if (err < 0) {
15262 alc_free(codec);
15263 return err;
15264 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015265 }
15266
Kailang Yangf6a92242007-12-13 16:52:54 +010015267 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015268 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015269
Kailang Yang84898e82010-02-04 14:16:14 +010015270 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015271 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15272 * fix the sample rate of analog I/O to 44.1kHz
15273 */
15274 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15275 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015276 } else if (spec->dual_adc_switch) {
15277 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15278 /* switch ADC dynamically */
15279 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015280 } else {
15281 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15282 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15283 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015284 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15285 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15286
Takashi Iwai66946352010-03-29 17:21:45 +020015287 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015288 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015289 spec->adc_nids = alc269_adc_nids;
15290 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15291 spec->capsrc_nids = alc269_capsrc_nids;
15292 } else {
15293 spec->adc_nids = alc269vb_adc_nids;
15294 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15295 spec->capsrc_nids = alc269vb_capsrc_nids;
15296 }
Kailang Yang84898e82010-02-04 14:16:14 +010015297 }
15298
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015299 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015300 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015301 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015302 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015303
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015304 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015305
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015306 spec->vmaster_nid = 0x02;
15307
Kailang Yangf6a92242007-12-13 16:52:54 +010015308 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015309#ifdef CONFIG_SND_HDA_POWER_SAVE
15310 codec->patch_ops.suspend = alc269_suspend;
15311#endif
15312#ifdef SND_HDA_NEEDS_RESUME
15313 codec->patch_ops.resume = alc269_resume;
15314#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015315 if (board_config == ALC269_AUTO)
15316 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015317
15318 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015319#ifdef CONFIG_SND_HDA_POWER_SAVE
15320 if (!spec->loopback.amplist)
15321 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015322 if (alc269_mic2_for_mute_led(codec))
15323 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015324#endif
15325
15326 return 0;
15327}
15328
15329/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015330 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15331 */
15332
15333/*
15334 * set the path ways for 2 channel output
15335 * need to set the codec line out and mic 1 pin widgets to inputs
15336 */
15337static struct hda_verb alc861_threestack_ch2_init[] = {
15338 /* set pin widget 1Ah (line in) for input */
15339 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015340 /* set pin widget 18h (mic1/2) for input, for mic also enable
15341 * the vref
15342 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015343 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15344
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015345 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15346#if 0
15347 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15348 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15349#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015350 { } /* end */
15351};
15352/*
15353 * 6ch mode
15354 * need to set the codec line out and mic 1 pin widgets to outputs
15355 */
15356static struct hda_verb alc861_threestack_ch6_init[] = {
15357 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15358 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15359 /* set pin widget 18h (mic1) for output (CLFE)*/
15360 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15361
15362 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015363 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015364
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015365 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15366#if 0
15367 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15368 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15369#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015370 { } /* end */
15371};
15372
15373static struct hda_channel_mode alc861_threestack_modes[2] = {
15374 { 2, alc861_threestack_ch2_init },
15375 { 6, alc861_threestack_ch6_init },
15376};
Takashi Iwai22309c32006-08-09 16:57:28 +020015377/* Set mic1 as input and unmute the mixer */
15378static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15379 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15380 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15381 { } /* end */
15382};
15383/* Set mic1 as output and mute mixer */
15384static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15385 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15386 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15387 { } /* end */
15388};
15389
15390static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15391 { 2, alc861_uniwill_m31_ch2_init },
15392 { 4, alc861_uniwill_m31_ch4_init },
15393};
Kailang Yangdf694da2005-12-05 19:42:22 +010015394
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015395/* Set mic1 and line-in as input and unmute the mixer */
15396static struct hda_verb alc861_asus_ch2_init[] = {
15397 /* set pin widget 1Ah (line in) for input */
15398 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015399 /* set pin widget 18h (mic1/2) for input, for mic also enable
15400 * the vref
15401 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015402 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15403
15404 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15405#if 0
15406 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15407 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15408#endif
15409 { } /* end */
15410};
15411/* Set mic1 nad line-in as output and mute mixer */
15412static struct hda_verb alc861_asus_ch6_init[] = {
15413 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15414 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15415 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15416 /* set pin widget 18h (mic1) for output (CLFE)*/
15417 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15418 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15419 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15420 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15421
15422 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15423#if 0
15424 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15425 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15426#endif
15427 { } /* end */
15428};
15429
15430static struct hda_channel_mode alc861_asus_modes[2] = {
15431 { 2, alc861_asus_ch2_init },
15432 { 6, alc861_asus_ch6_init },
15433};
15434
Kailang Yangdf694da2005-12-05 19:42:22 +010015435/* patch-ALC861 */
15436
15437static struct snd_kcontrol_new alc861_base_mixer[] = {
15438 /* output mixer control */
15439 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15440 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15441 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15442 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15443 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15444
15445 /*Input mixer control */
15446 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15447 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15448 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15449 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15450 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15451 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15453 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15454 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15455 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015456
Kailang Yangdf694da2005-12-05 19:42:22 +010015457 { } /* end */
15458};
15459
15460static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15461 /* output mixer control */
15462 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15463 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15464 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15465 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15466 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15467
15468 /* Input mixer control */
15469 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15470 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15471 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15472 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15473 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15474 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15475 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15476 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15477 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15478 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015479
Kailang Yangdf694da2005-12-05 19:42:22 +010015480 {
15481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15482 .name = "Channel Mode",
15483 .info = alc_ch_mode_info,
15484 .get = alc_ch_mode_get,
15485 .put = alc_ch_mode_put,
15486 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15487 },
15488 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015489};
15490
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015491static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015492 /* output mixer control */
15493 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15495 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015496
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015497 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015498};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015499
Takashi Iwai22309c32006-08-09 16:57:28 +020015500static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15501 /* output mixer control */
15502 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15503 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15504 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15505 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15506 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15507
15508 /* Input mixer control */
15509 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15510 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15511 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15512 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15513 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15514 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15516 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15517 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15518 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015519
Takashi Iwai22309c32006-08-09 16:57:28 +020015520 {
15521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15522 .name = "Channel Mode",
15523 .info = alc_ch_mode_info,
15524 .get = alc_ch_mode_get,
15525 .put = alc_ch_mode_put,
15526 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15527 },
15528 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015529};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015530
15531static struct snd_kcontrol_new alc861_asus_mixer[] = {
15532 /* output mixer control */
15533 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15534 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15535 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15536 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15537 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15538
15539 /* Input mixer control */
15540 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15541 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15542 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15543 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15544 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15545 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15547 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15548 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015549 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15550
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015551 {
15552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15553 .name = "Channel Mode",
15554 .info = alc_ch_mode_info,
15555 .get = alc_ch_mode_get,
15556 .put = alc_ch_mode_put,
15557 .private_value = ARRAY_SIZE(alc861_asus_modes),
15558 },
15559 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015560};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015561
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015562/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015563static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015564 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15565 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015566 { }
15567};
15568
Kailang Yangdf694da2005-12-05 19:42:22 +010015569/*
15570 * generic initialization of ADC, input mixers and output mixers
15571 */
15572static struct hda_verb alc861_base_init_verbs[] = {
15573 /*
15574 * Unmute ADC0 and set the default input to mic-in
15575 */
15576 /* port-A for surround (rear panel) */
15577 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15578 { 0x0e, AC_VERB_SET_CONNECT_SEL, 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) */
15587 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15588 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015589 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015590 /* port-F for mic-in (front panel) with vref */
15591 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15592 /* port-G for CLFE (rear panel) */
15593 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15594 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15595 /* port-H for side (rear panel) */
15596 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15597 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15598 /* CD-in */
15599 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15600 /* route front mic to ADC1*/
15601 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15602 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015603
Kailang Yangdf694da2005-12-05 19:42:22 +010015604 /* Unmute DAC0~3 & spdif out*/
15605 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15606 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15607 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15608 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015610
Kailang Yangdf694da2005-12-05 19:42:22 +010015611 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15612 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15613 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15614 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15615 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015616
Kailang Yangdf694da2005-12-05 19:42:22 +010015617 /* Unmute Stereo Mixer 15 */
15618 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15619 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015622
15623 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15624 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15625 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15626 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15627 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15628 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15629 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15630 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015631 /* hp used DAC 3 (Front) */
15632 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015633 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15634
15635 { }
15636};
15637
15638static struct hda_verb alc861_threestack_init_verbs[] = {
15639 /*
15640 * Unmute ADC0 and set the default input to mic-in
15641 */
15642 /* port-A for surround (rear panel) */
15643 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15644 /* port-B for mic-in (rear panel) with vref */
15645 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15646 /* port-C for line-in (rear panel) */
15647 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15648 /* port-D for Front */
15649 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15650 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15651 /* port-E for HP out (front panel) */
15652 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15653 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015654 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015655 /* port-F for mic-in (front panel) with vref */
15656 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15657 /* port-G for CLFE (rear panel) */
15658 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15659 /* port-H for side (rear panel) */
15660 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15661 /* CD-in */
15662 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15663 /* route front mic to ADC1*/
15664 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15665 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15666 /* Unmute DAC0~3 & spdif out*/
15667 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15668 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15669 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15670 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015672
Kailang Yangdf694da2005-12-05 19:42:22 +010015673 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15674 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15675 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15676 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15677 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015678
Kailang Yangdf694da2005-12-05 19:42:22 +010015679 /* Unmute Stereo Mixer 15 */
15680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015684
15685 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15686 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15687 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15689 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15690 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15691 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15692 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015693 /* hp used DAC 3 (Front) */
15694 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015695 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15696 { }
15697};
Takashi Iwai22309c32006-08-09 16:57:28 +020015698
15699static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15700 /*
15701 * Unmute ADC0 and set the default input to mic-in
15702 */
15703 /* port-A for surround (rear panel) */
15704 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15705 /* port-B for mic-in (rear panel) with vref */
15706 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15707 /* port-C for line-in (rear panel) */
15708 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15709 /* port-D for Front */
15710 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15711 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15712 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015713 /* this has to be set to VREF80 */
15714 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015715 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015716 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015717 /* port-F for mic-in (front panel) with vref */
15718 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15719 /* port-G for CLFE (rear panel) */
15720 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15721 /* port-H for side (rear panel) */
15722 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15723 /* CD-in */
15724 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15725 /* route front mic to ADC1*/
15726 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15727 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15728 /* Unmute DAC0~3 & spdif out*/
15729 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15730 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15731 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15732 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015734
Takashi Iwai22309c32006-08-09 16:57:28 +020015735 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15736 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15737 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15738 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15739 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015740
Takashi Iwai22309c32006-08-09 16:57:28 +020015741 /* Unmute Stereo Mixer 15 */
15742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015745 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015746
15747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15748 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15749 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15750 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15751 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15752 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15753 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15754 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015755 /* hp used DAC 3 (Front) */
15756 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15758 { }
15759};
15760
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015761static struct hda_verb alc861_asus_init_verbs[] = {
15762 /*
15763 * Unmute ADC0 and set the default input to mic-in
15764 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015765 /* port-A for surround (rear panel)
15766 * according to codec#0 this is the HP jack
15767 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015768 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15769 /* route front PCM to HP */
15770 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15771 /* port-B for mic-in (rear panel) with vref */
15772 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15773 /* port-C for line-in (rear panel) */
15774 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15775 /* port-D for Front */
15776 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15777 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15778 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015779 /* this has to be set to VREF80 */
15780 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015781 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015782 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015783 /* port-F for mic-in (front panel) with vref */
15784 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15785 /* port-G for CLFE (rear panel) */
15786 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15787 /* port-H for side (rear panel) */
15788 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15789 /* CD-in */
15790 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15791 /* route front mic to ADC1*/
15792 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15794 /* Unmute DAC0~3 & spdif out*/
15795 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15796 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15797 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15798 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15800 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15801 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15802 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15803 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15804 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015805
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015806 /* Unmute Stereo Mixer 15 */
15807 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015811
15812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15813 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15814 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15815 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15817 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15818 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015820 /* hp used DAC 3 (Front) */
15821 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15823 { }
15824};
15825
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015826/* additional init verbs for ASUS laptops */
15827static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15828 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15829 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15830 { }
15831};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015832
Kailang Yangdf694da2005-12-05 19:42:22 +010015833/*
15834 * generic initialization of ADC, input mixers and output mixers
15835 */
15836static struct hda_verb alc861_auto_init_verbs[] = {
15837 /*
15838 * Unmute ADC0 and set the default input to mic-in
15839 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015840 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015841 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015842
Kailang Yangdf694da2005-12-05 19:42:22 +010015843 /* Unmute DAC0~3 & spdif out*/
15844 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15845 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15846 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15847 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015849
Kailang Yangdf694da2005-12-05 19:42:22 +010015850 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15851 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15852 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15853 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15854 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015855
Kailang Yangdf694da2005-12-05 19:42:22 +010015856 /* Unmute Stereo Mixer 15 */
15857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15861
Takashi Iwai1c209302009-07-22 15:17:45 +020015862 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15863 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15864 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15865 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15867 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15868 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15869 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015870
15871 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15872 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015873 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15874 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015875 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15876 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015877 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15878 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015879
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015880 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015881
15882 { }
15883};
15884
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015885static struct hda_verb alc861_toshiba_init_verbs[] = {
15886 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015887
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015888 { }
15889};
15890
15891/* toggle speaker-output according to the hp-jack state */
15892static void alc861_toshiba_automute(struct hda_codec *codec)
15893{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015894 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015895
Takashi Iwai47fd8302007-08-10 17:11:07 +020015896 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15897 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15898 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15899 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015900}
15901
15902static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15903 unsigned int res)
15904{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015905 if ((res >> 26) == ALC880_HP_EVENT)
15906 alc861_toshiba_automute(codec);
15907}
15908
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015909/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015910#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15911#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15912#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15913#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15914
15915
15916#define ALC861_DIGOUT_NID 0x07
15917
15918static struct hda_channel_mode alc861_8ch_modes[1] = {
15919 { 8, NULL }
15920};
15921
15922static hda_nid_t alc861_dac_nids[4] = {
15923 /* front, surround, clfe, side */
15924 0x03, 0x06, 0x05, 0x04
15925};
15926
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015927static hda_nid_t alc660_dac_nids[3] = {
15928 /* front, clfe, surround */
15929 0x03, 0x05, 0x06
15930};
15931
Kailang Yangdf694da2005-12-05 19:42:22 +010015932static hda_nid_t alc861_adc_nids[1] = {
15933 /* ADC0-2 */
15934 0x08,
15935};
15936
15937static struct hda_input_mux alc861_capture_source = {
15938 .num_items = 5,
15939 .items = {
15940 { "Mic", 0x0 },
15941 { "Front Mic", 0x3 },
15942 { "Line", 0x1 },
15943 { "CD", 0x4 },
15944 { "Mixer", 0x5 },
15945 },
15946};
15947
Takashi Iwai1c209302009-07-22 15:17:45 +020015948static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15949{
15950 struct alc_spec *spec = codec->spec;
15951 hda_nid_t mix, srcs[5];
15952 int i, j, num;
15953
15954 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15955 return 0;
15956 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15957 if (num < 0)
15958 return 0;
15959 for (i = 0; i < num; i++) {
15960 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015961 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015962 if (type != AC_WID_AUD_OUT)
15963 continue;
15964 for (j = 0; j < spec->multiout.num_dacs; j++)
15965 if (spec->multiout.dac_nids[j] == srcs[i])
15966 break;
15967 if (j >= spec->multiout.num_dacs)
15968 return srcs[i];
15969 }
15970 return 0;
15971}
15972
Kailang Yangdf694da2005-12-05 19:42:22 +010015973/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015974static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015975 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015976{
Takashi Iwai1c209302009-07-22 15:17:45 +020015977 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015978 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015979 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015980
15981 spec->multiout.dac_nids = spec->private_dac_nids;
15982 for (i = 0; i < cfg->line_outs; i++) {
15983 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015984 dac = alc861_look_for_dac(codec, nid);
15985 if (!dac)
15986 continue;
15987 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015988 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015989 return 0;
15990}
15991
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015992static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15993 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015994{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015995 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015996 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15997}
15998
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015999#define alc861_create_out_sw(codec, pfx, nid, chs) \
16000 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
16001
Takashi Iwai1c209302009-07-22 15:17:45 +020016002/* add playback controls from the parsed DAC table */
16003static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
16004 const struct auto_pin_cfg *cfg)
16005{
16006 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016007 static const char *chname[4] = {
16008 "Front", "Surround", NULL /*CLFE*/, "Side"
16009 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016010 const char *pfx = alc_get_line_out_pfx(cfg, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010016011 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020016012 int i, err;
16013
Kailang Yangdf694da2005-12-05 19:42:22 +010016014 for (i = 0; i < cfg->line_outs; i++) {
16015 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016016 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010016017 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016018 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010016019 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020016020 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016021 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016022 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016023 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016024 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016025 return err;
16026 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016027 const char *name = pfx;
16028 if (!name)
16029 name = chname[i];
16030 err = __alc861_create_out_sw(codec, name, nid, i, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016031 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016032 return err;
16033 }
16034 }
16035 return 0;
16036}
16037
Takashi Iwai1c209302009-07-22 15:17:45 +020016038static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016039{
Takashi Iwai1c209302009-07-22 15:17:45 +020016040 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016041 int err;
16042 hda_nid_t nid;
16043
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016044 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016045 return 0;
16046
16047 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016048 nid = alc861_look_for_dac(codec, pin);
16049 if (nid) {
16050 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16051 if (err < 0)
16052 return err;
16053 spec->multiout.hp_nid = nid;
16054 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016055 }
16056 return 0;
16057}
16058
16059/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016060static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016061 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016062{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016063 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016064}
16065
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016066static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16067 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016068 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016069{
Takashi Iwai1c209302009-07-22 15:17:45 +020016070 hda_nid_t mix, srcs[5];
16071 int i, num;
16072
Jacek Luczak564c5be2008-05-03 18:41:23 +020016073 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16074 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016075 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016076 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016077 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16078 return;
16079 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16080 if (num < 0)
16081 return;
16082 for (i = 0; i < num; i++) {
16083 unsigned int mute;
16084 if (srcs[i] == dac || srcs[i] == 0x15)
16085 mute = AMP_IN_UNMUTE(i);
16086 else
16087 mute = AMP_IN_MUTE(i);
16088 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16089 mute);
16090 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016091}
16092
16093static void alc861_auto_init_multi_out(struct hda_codec *codec)
16094{
16095 struct alc_spec *spec = codec->spec;
16096 int i;
16097
16098 for (i = 0; i < spec->autocfg.line_outs; i++) {
16099 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016100 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016101 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016102 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016103 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016104 }
16105}
16106
16107static void alc861_auto_init_hp_out(struct hda_codec *codec)
16108{
16109 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016110
Takashi Iwai15870f02009-10-05 08:25:13 +020016111 if (spec->autocfg.hp_outs)
16112 alc861_auto_set_output_and_unmute(codec,
16113 spec->autocfg.hp_pins[0],
16114 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016115 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016116 if (spec->autocfg.speaker_outs)
16117 alc861_auto_set_output_and_unmute(codec,
16118 spec->autocfg.speaker_pins[0],
16119 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016120 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016121}
16122
16123static void alc861_auto_init_analog_input(struct hda_codec *codec)
16124{
16125 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016126 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016127 int i;
16128
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016129 for (i = 0; i < cfg->num_inputs; i++) {
16130 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016131 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016132 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016133 }
16134}
16135
16136/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016137/* return 1 if successful, 0 if the proper config is not found,
16138 * or a negative error code
16139 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016140static int alc861_parse_auto_config(struct hda_codec *codec)
16141{
16142 struct alc_spec *spec = codec->spec;
16143 int err;
16144 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16145
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016146 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16147 alc861_ignore);
16148 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016149 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016150 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016151 return 0; /* can't find valid BIOS pin config */
16152
Takashi Iwai1c209302009-07-22 15:17:45 +020016153 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016154 if (err < 0)
16155 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016156 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016157 if (err < 0)
16158 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016159 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016160 if (err < 0)
16161 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016162 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016163 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016164 return err;
16165
16166 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16167
Takashi Iwai757899a2010-07-30 10:48:14 +020016168 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016169
Takashi Iwai603c4012008-07-30 15:01:44 +020016170 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016171 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016172
Takashi Iwaid88897e2008-10-31 15:01:37 +010016173 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016174
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016175 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016176 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016177
16178 spec->adc_nids = alc861_adc_nids;
16179 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016180 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016181
Kailang Yang6227cdc2010-02-25 08:36:52 +010016182 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016183
Kailang Yangdf694da2005-12-05 19:42:22 +010016184 return 1;
16185}
16186
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016187/* additional initialization for auto-configuration model */
16188static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016189{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016190 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016191 alc861_auto_init_multi_out(codec);
16192 alc861_auto_init_hp_out(codec);
16193 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016194 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016195 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016196 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016197}
16198
Takashi Iwaicb53c622007-08-10 17:21:45 +020016199#ifdef CONFIG_SND_HDA_POWER_SAVE
16200static struct hda_amp_list alc861_loopbacks[] = {
16201 { 0x15, HDA_INPUT, 0 },
16202 { 0x15, HDA_INPUT, 1 },
16203 { 0x15, HDA_INPUT, 2 },
16204 { 0x15, HDA_INPUT, 3 },
16205 { } /* end */
16206};
16207#endif
16208
Kailang Yangdf694da2005-12-05 19:42:22 +010016209
16210/*
16211 * configuration and preset
16212 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016213static const char *alc861_models[ALC861_MODEL_LAST] = {
16214 [ALC861_3ST] = "3stack",
16215 [ALC660_3ST] = "3stack-660",
16216 [ALC861_3ST_DIG] = "3stack-dig",
16217 [ALC861_6ST_DIG] = "6stack-dig",
16218 [ALC861_UNIWILL_M31] = "uniwill-m31",
16219 [ALC861_TOSHIBA] = "toshiba",
16220 [ALC861_ASUS] = "asus",
16221 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16222 [ALC861_AUTO] = "auto",
16223};
16224
16225static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016226 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016227 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16228 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16229 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016230 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016231 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016232 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016233 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16234 * Any other models that need this preset?
16235 */
16236 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016237 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16238 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016239 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16240 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16241 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16242 /* FIXME: the below seems conflict */
16243 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16244 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16245 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016246 {}
16247};
16248
16249static struct alc_config_preset alc861_presets[] = {
16250 [ALC861_3ST] = {
16251 .mixers = { alc861_3ST_mixer },
16252 .init_verbs = { alc861_threestack_init_verbs },
16253 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16254 .dac_nids = alc861_dac_nids,
16255 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16256 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016257 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016258 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16259 .adc_nids = alc861_adc_nids,
16260 .input_mux = &alc861_capture_source,
16261 },
16262 [ALC861_3ST_DIG] = {
16263 .mixers = { alc861_base_mixer },
16264 .init_verbs = { alc861_threestack_init_verbs },
16265 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16266 .dac_nids = alc861_dac_nids,
16267 .dig_out_nid = ALC861_DIGOUT_NID,
16268 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16269 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016270 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016271 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16272 .adc_nids = alc861_adc_nids,
16273 .input_mux = &alc861_capture_source,
16274 },
16275 [ALC861_6ST_DIG] = {
16276 .mixers = { alc861_base_mixer },
16277 .init_verbs = { alc861_base_init_verbs },
16278 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16279 .dac_nids = alc861_dac_nids,
16280 .dig_out_nid = ALC861_DIGOUT_NID,
16281 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16282 .channel_mode = alc861_8ch_modes,
16283 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16284 .adc_nids = alc861_adc_nids,
16285 .input_mux = &alc861_capture_source,
16286 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016287 [ALC660_3ST] = {
16288 .mixers = { alc861_3ST_mixer },
16289 .init_verbs = { alc861_threestack_init_verbs },
16290 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16291 .dac_nids = alc660_dac_nids,
16292 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16293 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016294 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016295 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16296 .adc_nids = alc861_adc_nids,
16297 .input_mux = &alc861_capture_source,
16298 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016299 [ALC861_UNIWILL_M31] = {
16300 .mixers = { alc861_uniwill_m31_mixer },
16301 .init_verbs = { alc861_uniwill_m31_init_verbs },
16302 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16303 .dac_nids = alc861_dac_nids,
16304 .dig_out_nid = ALC861_DIGOUT_NID,
16305 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16306 .channel_mode = alc861_uniwill_m31_modes,
16307 .need_dac_fix = 1,
16308 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16309 .adc_nids = alc861_adc_nids,
16310 .input_mux = &alc861_capture_source,
16311 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016312 [ALC861_TOSHIBA] = {
16313 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016314 .init_verbs = { alc861_base_init_verbs,
16315 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016316 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16317 .dac_nids = alc861_dac_nids,
16318 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16319 .channel_mode = alc883_3ST_2ch_modes,
16320 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16321 .adc_nids = alc861_adc_nids,
16322 .input_mux = &alc861_capture_source,
16323 .unsol_event = alc861_toshiba_unsol_event,
16324 .init_hook = alc861_toshiba_automute,
16325 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016326 [ALC861_ASUS] = {
16327 .mixers = { alc861_asus_mixer },
16328 .init_verbs = { alc861_asus_init_verbs },
16329 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16330 .dac_nids = alc861_dac_nids,
16331 .dig_out_nid = ALC861_DIGOUT_NID,
16332 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16333 .channel_mode = alc861_asus_modes,
16334 .need_dac_fix = 1,
16335 .hp_nid = 0x06,
16336 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16337 .adc_nids = alc861_adc_nids,
16338 .input_mux = &alc861_capture_source,
16339 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016340 [ALC861_ASUS_LAPTOP] = {
16341 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16342 .init_verbs = { alc861_asus_init_verbs,
16343 alc861_asus_laptop_init_verbs },
16344 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16345 .dac_nids = alc861_dac_nids,
16346 .dig_out_nid = ALC861_DIGOUT_NID,
16347 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16348 .channel_mode = alc883_3ST_2ch_modes,
16349 .need_dac_fix = 1,
16350 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16351 .adc_nids = alc861_adc_nids,
16352 .input_mux = &alc861_capture_source,
16353 },
16354};
Kailang Yangdf694da2005-12-05 19:42:22 +010016355
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016356/* Pin config fixes */
16357enum {
16358 PINFIX_FSC_AMILO_PI1505,
16359};
16360
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016361static const struct alc_fixup alc861_fixups[] = {
16362 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016363 .type = ALC_FIXUP_PINS,
16364 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016365 { 0x0b, 0x0221101f }, /* HP */
16366 { 0x0f, 0x90170310 }, /* speaker */
16367 { }
16368 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016369 },
16370};
16371
16372static struct snd_pci_quirk alc861_fixup_tbl[] = {
16373 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16374 {}
16375};
Kailang Yangdf694da2005-12-05 19:42:22 +010016376
16377static int patch_alc861(struct hda_codec *codec)
16378{
16379 struct alc_spec *spec;
16380 int board_config;
16381 int err;
16382
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016383 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016384 if (spec == NULL)
16385 return -ENOMEM;
16386
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016387 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016388
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016389 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16390 alc861_models,
16391 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016392
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016393 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016394 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16395 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016396 board_config = ALC861_AUTO;
16397 }
16398
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016399 if (board_config == ALC861_AUTO) {
16400 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16401 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16402 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016403
Kailang Yangdf694da2005-12-05 19:42:22 +010016404 if (board_config == ALC861_AUTO) {
16405 /* automatic parse from the BIOS config */
16406 err = alc861_parse_auto_config(codec);
16407 if (err < 0) {
16408 alc_free(codec);
16409 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016410 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016411 printk(KERN_INFO
16412 "hda_codec: Cannot set up configuration "
16413 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016414 board_config = ALC861_3ST_DIG;
16415 }
16416 }
16417
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016418 err = snd_hda_attach_beep_device(codec, 0x23);
16419 if (err < 0) {
16420 alc_free(codec);
16421 return err;
16422 }
16423
Kailang Yangdf694da2005-12-05 19:42:22 +010016424 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016425 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016426
Kailang Yangdf694da2005-12-05 19:42:22 +010016427 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16428 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16429
Kailang Yangdf694da2005-12-05 19:42:22 +010016430 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16431 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16432
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016433 if (!spec->cap_mixer)
16434 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016435 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16436
Takashi Iwai2134ea42008-01-10 16:53:55 +010016437 spec->vmaster_nid = 0x03;
16438
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016439 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016440
Kailang Yangdf694da2005-12-05 19:42:22 +010016441 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016442 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016443 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016444#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016445 spec->power_hook = alc_power_eapd;
16446#endif
16447 }
16448#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016449 if (!spec->loopback.amplist)
16450 spec->loopback.amplist = alc861_loopbacks;
16451#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016452
Kailang Yangdf694da2005-12-05 19:42:22 +010016453 return 0;
16454}
16455
16456/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016457 * ALC861-VD support
16458 *
16459 * Based on ALC882
16460 *
16461 * In addition, an independent DAC
16462 */
16463#define ALC861VD_DIGOUT_NID 0x06
16464
16465static hda_nid_t alc861vd_dac_nids[4] = {
16466 /* front, surr, clfe, side surr */
16467 0x02, 0x03, 0x04, 0x05
16468};
16469
16470/* dac_nids for ALC660vd are in a different order - according to
16471 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016472 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016473 * of ALC660vd codecs, but for now there is only 3stack mixer
16474 * - and it is the same as in 861vd.
16475 * adc_nids in ALC660vd are (is) the same as in 861vd
16476 */
16477static hda_nid_t alc660vd_dac_nids[3] = {
16478 /* front, rear, clfe, rear_surr */
16479 0x02, 0x04, 0x03
16480};
16481
16482static hda_nid_t alc861vd_adc_nids[1] = {
16483 /* ADC0 */
16484 0x09,
16485};
16486
Takashi Iwaie1406342008-02-11 18:32:32 +010016487static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16488
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016489/* input MUX */
16490/* FIXME: should be a matrix-type input source selection */
16491static struct hda_input_mux alc861vd_capture_source = {
16492 .num_items = 4,
16493 .items = {
16494 { "Mic", 0x0 },
16495 { "Front Mic", 0x1 },
16496 { "Line", 0x2 },
16497 { "CD", 0x4 },
16498 },
16499};
16500
Kailang Yang272a5272007-05-14 11:00:38 +020016501static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016502 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016503 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016504 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016505 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016506 },
16507};
16508
Kailang Yangd1a991a2007-08-15 16:21:59 +020016509static struct hda_input_mux alc861vd_hp_capture_source = {
16510 .num_items = 2,
16511 .items = {
16512 { "Front Mic", 0x0 },
16513 { "ATAPI Mic", 0x1 },
16514 },
16515};
16516
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016517/*
16518 * 2ch mode
16519 */
16520static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16521 { 2, NULL }
16522};
16523
16524/*
16525 * 6ch mode
16526 */
16527static struct hda_verb alc861vd_6stack_ch6_init[] = {
16528 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16529 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16530 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16531 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16532 { } /* end */
16533};
16534
16535/*
16536 * 8ch mode
16537 */
16538static struct hda_verb alc861vd_6stack_ch8_init[] = {
16539 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16540 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16541 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16542 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16543 { } /* end */
16544};
16545
16546static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16547 { 6, alc861vd_6stack_ch6_init },
16548 { 8, alc861vd_6stack_ch8_init },
16549};
16550
16551static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16552 {
16553 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16554 .name = "Channel Mode",
16555 .info = alc_ch_mode_info,
16556 .get = alc_ch_mode_get,
16557 .put = alc_ch_mode_put,
16558 },
16559 { } /* end */
16560};
16561
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016562/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16563 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16564 */
16565static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16566 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16567 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16568
16569 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16570 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16571
16572 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16573 HDA_OUTPUT),
16574 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16575 HDA_OUTPUT),
16576 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16577 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16578
16579 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16580 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16581
16582 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16583
David Henningsson5f99f862011-01-04 15:24:24 +010016584 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016585 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16586 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16587
David Henningsson5f99f862011-01-04 15:24:24 +010016588 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016589 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16590 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16591
16592 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16593 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16594
16595 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16596 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16597
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016598 { } /* end */
16599};
16600
16601static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16602 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16603 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16604
16605 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16606
David Henningsson5f99f862011-01-04 15:24:24 +010016607 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16610
David Henningsson5f99f862011-01-04 15:24:24 +010016611 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016612 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16613 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16614
16615 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16616 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16617
16618 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16619 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16620
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016621 { } /* end */
16622};
16623
Kailang Yangbdd148a2007-05-08 15:19:08 +020016624static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16625 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16626 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16627 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16628
16629 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16630
David Henningsson5f99f862011-01-04 15:24:24 +010016631 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16634
David Henningsson5f99f862011-01-04 15:24:24 +010016635 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016636 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16637 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16638
16639 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16640 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16641
16642 { } /* end */
16643};
16644
Tobin Davisb419f342008-03-07 11:57:51 +010016645/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016646 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016647 */
16648static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016649 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16650 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016651 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16652 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016653 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16655 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016656 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016657 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16658 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016659 { } /* end */
16660};
16661
Kailang Yangd1a991a2007-08-15 16:21:59 +020016662/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16663 * Front Mic=0x18, ATAPI Mic = 0x19,
16664 */
16665static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16666 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16667 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16668 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16669 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16670 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16671 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16672 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16673 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016674
Kailang Yangd1a991a2007-08-15 16:21:59 +020016675 { } /* end */
16676};
16677
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016678/*
16679 * generic initialization of ADC, input mixers and output mixers
16680 */
16681static struct hda_verb alc861vd_volume_init_verbs[] = {
16682 /*
16683 * Unmute ADC0 and set the default input to mic-in
16684 */
16685 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16686 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16687
16688 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16689 * the analog-loopback mixer widget
16690 */
16691 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016697
16698 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016699 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16700 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16701 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016702 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016703
16704 /*
16705 * Set up output mixers (0x02 - 0x05)
16706 */
16707 /* set vol=0 to output mixers */
16708 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16709 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16710 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16711 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16712
16713 /* set up input amps for analog loopback */
16714 /* Amp Indices: DAC = 0, mixer = 1 */
16715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16718 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16720 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16721 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16722 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16723
16724 { }
16725};
16726
16727/*
16728 * 3-stack pin configuration:
16729 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16730 */
16731static struct hda_verb alc861vd_3stack_init_verbs[] = {
16732 /*
16733 * Set pin mode and muting
16734 */
16735 /* set front pin widgets 0x14 for output */
16736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16738 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16739
16740 /* Mic (rear) pin: input vref at 80% */
16741 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16742 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16743 /* Front Mic pin: input vref at 80% */
16744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16745 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16746 /* Line In pin: input */
16747 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16749 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16750 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16751 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16752 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16753 /* CD pin widget for input */
16754 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16755
16756 { }
16757};
16758
16759/*
16760 * 6-stack pin configuration:
16761 */
16762static struct hda_verb alc861vd_6stack_init_verbs[] = {
16763 /*
16764 * Set pin mode and muting
16765 */
16766 /* set front pin widgets 0x14 for output */
16767 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16769 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16770
16771 /* Rear Pin: output 1 (0x0d) */
16772 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16774 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16775 /* CLFE Pin: output 2 (0x0e) */
16776 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16777 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16778 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16779 /* Side Pin: output 3 (0x0f) */
16780 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16781 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16782 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16783
16784 /* Mic (rear) pin: input vref at 80% */
16785 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16786 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16787 /* Front Mic pin: input vref at 80% */
16788 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16789 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16790 /* Line In pin: input */
16791 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16792 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16793 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16794 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16795 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16796 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16797 /* CD pin widget for input */
16798 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16799
16800 { }
16801};
16802
Kailang Yangbdd148a2007-05-08 15:19:08 +020016803static struct hda_verb alc861vd_eapd_verbs[] = {
16804 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16805 { }
16806};
16807
Kailang Yangf9423e72008-05-27 12:32:25 +020016808static struct hda_verb alc660vd_eapd_verbs[] = {
16809 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16810 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16811 { }
16812};
16813
Kailang Yangbdd148a2007-05-08 15:19:08 +020016814static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16815 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16817 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16818 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016819 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016820 {}
16821};
16822
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016823static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016824{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016825 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016826 spec->autocfg.hp_pins[0] = 0x1b;
16827 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016828}
16829
16830static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16831{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016832 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016833 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016834}
16835
16836static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16837 unsigned int res)
16838{
16839 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016840 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016841 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016842 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016843 default:
16844 alc_automute_amp_unsol_event(codec, res);
16845 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016846 }
16847}
16848
Kailang Yang272a5272007-05-14 11:00:38 +020016849static struct hda_verb alc861vd_dallas_verbs[] = {
16850 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16851 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16852 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16853 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16854
16855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16857 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16858 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16859 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16861 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16862 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016863
Kailang Yang272a5272007-05-14 11:00:38 +020016864 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16865 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16868 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16870 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16871 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16872
16873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16875 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16876 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16878 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16879 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16880 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16881
16882 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16886
16887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016888 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016889 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16890
16891 { } /* end */
16892};
16893
16894/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016895static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016896{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016897 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016898
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016899 spec->autocfg.hp_pins[0] = 0x15;
16900 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016901}
16902
Takashi Iwaicb53c622007-08-10 17:21:45 +020016903#ifdef CONFIG_SND_HDA_POWER_SAVE
16904#define alc861vd_loopbacks alc880_loopbacks
16905#endif
16906
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016907/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016908#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16909#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16910#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16911#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16912
16913/*
16914 * configuration and preset
16915 */
16916static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16917 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016918 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016919 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016920 [ALC861VD_3ST] = "3stack",
16921 [ALC861VD_3ST_DIG] = "3stack-digout",
16922 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016923 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016924 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016925 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016926 [ALC861VD_AUTO] = "auto",
16927};
16928
16929static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016930 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16931 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016932 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016933 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016934 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016935 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016936 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016937 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016938 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016939 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016940 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016941 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016942 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016943 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016944 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016945 {}
16946};
16947
16948static struct alc_config_preset alc861vd_presets[] = {
16949 [ALC660VD_3ST] = {
16950 .mixers = { alc861vd_3st_mixer },
16951 .init_verbs = { alc861vd_volume_init_verbs,
16952 alc861vd_3stack_init_verbs },
16953 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16954 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016955 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16956 .channel_mode = alc861vd_3stack_2ch_modes,
16957 .input_mux = &alc861vd_capture_source,
16958 },
Mike Crash6963f842007-06-25 12:12:51 +020016959 [ALC660VD_3ST_DIG] = {
16960 .mixers = { alc861vd_3st_mixer },
16961 .init_verbs = { alc861vd_volume_init_verbs,
16962 alc861vd_3stack_init_verbs },
16963 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16964 .dac_nids = alc660vd_dac_nids,
16965 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016966 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16967 .channel_mode = alc861vd_3stack_2ch_modes,
16968 .input_mux = &alc861vd_capture_source,
16969 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016970 [ALC861VD_3ST] = {
16971 .mixers = { alc861vd_3st_mixer },
16972 .init_verbs = { alc861vd_volume_init_verbs,
16973 alc861vd_3stack_init_verbs },
16974 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16975 .dac_nids = alc861vd_dac_nids,
16976 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16977 .channel_mode = alc861vd_3stack_2ch_modes,
16978 .input_mux = &alc861vd_capture_source,
16979 },
16980 [ALC861VD_3ST_DIG] = {
16981 .mixers = { alc861vd_3st_mixer },
16982 .init_verbs = { alc861vd_volume_init_verbs,
16983 alc861vd_3stack_init_verbs },
16984 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16985 .dac_nids = alc861vd_dac_nids,
16986 .dig_out_nid = ALC861VD_DIGOUT_NID,
16987 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16988 .channel_mode = alc861vd_3stack_2ch_modes,
16989 .input_mux = &alc861vd_capture_source,
16990 },
16991 [ALC861VD_6ST_DIG] = {
16992 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16993 .init_verbs = { alc861vd_volume_init_verbs,
16994 alc861vd_6stack_init_verbs },
16995 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16996 .dac_nids = alc861vd_dac_nids,
16997 .dig_out_nid = ALC861VD_DIGOUT_NID,
16998 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16999 .channel_mode = alc861vd_6stack_modes,
17000 .input_mux = &alc861vd_capture_source,
17001 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020017002 [ALC861VD_LENOVO] = {
17003 .mixers = { alc861vd_lenovo_mixer },
17004 .init_verbs = { alc861vd_volume_init_verbs,
17005 alc861vd_3stack_init_verbs,
17006 alc861vd_eapd_verbs,
17007 alc861vd_lenovo_unsol_verbs },
17008 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17009 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017010 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17011 .channel_mode = alc861vd_3stack_2ch_modes,
17012 .input_mux = &alc861vd_capture_source,
17013 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017014 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017015 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017016 },
Kailang Yang272a5272007-05-14 11:00:38 +020017017 [ALC861VD_DALLAS] = {
17018 .mixers = { alc861vd_dallas_mixer },
17019 .init_verbs = { alc861vd_dallas_verbs },
17020 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17021 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020017022 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17023 .channel_mode = alc861vd_3stack_2ch_modes,
17024 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017025 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017026 .setup = alc861vd_dallas_setup,
17027 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017028 },
17029 [ALC861VD_HP] = {
17030 .mixers = { alc861vd_hp_mixer },
17031 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17032 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17033 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017034 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017035 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17036 .channel_mode = alc861vd_3stack_2ch_modes,
17037 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017038 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017039 .setup = alc861vd_dallas_setup,
17040 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020017041 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017042 [ALC660VD_ASUS_V1S] = {
17043 .mixers = { alc861vd_lenovo_mixer },
17044 .init_verbs = { alc861vd_volume_init_verbs,
17045 alc861vd_3stack_init_verbs,
17046 alc861vd_eapd_verbs,
17047 alc861vd_lenovo_unsol_verbs },
17048 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17049 .dac_nids = alc660vd_dac_nids,
17050 .dig_out_nid = ALC861VD_DIGOUT_NID,
17051 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17052 .channel_mode = alc861vd_3stack_2ch_modes,
17053 .input_mux = &alc861vd_capture_source,
17054 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017055 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017056 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017057 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017058};
17059
17060/*
17061 * BIOS auto configuration
17062 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017063static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17064 const struct auto_pin_cfg *cfg)
17065{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017066 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017067}
17068
17069
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017070static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17071 hda_nid_t nid, int pin_type, int dac_idx)
17072{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017073 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017074}
17075
17076static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17077{
17078 struct alc_spec *spec = codec->spec;
17079 int i;
17080
17081 for (i = 0; i <= HDA_SIDE; i++) {
17082 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017083 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017084 if (nid)
17085 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017086 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017087 }
17088}
17089
17090
17091static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17092{
17093 struct alc_spec *spec = codec->spec;
17094 hda_nid_t pin;
17095
17096 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017097 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017098 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017099 pin = spec->autocfg.speaker_pins[0];
17100 if (pin)
17101 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017102}
17103
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017104#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17105
17106static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17107{
17108 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017109 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017110 int i;
17111
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017112 for (i = 0; i < cfg->num_inputs; i++) {
17113 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017114 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017115 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017116 if (nid != ALC861VD_PIN_CD_NID &&
17117 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017118 snd_hda_codec_write(codec, nid, 0,
17119 AC_VERB_SET_AMP_GAIN_MUTE,
17120 AMP_OUT_MUTE);
17121 }
17122 }
17123}
17124
Takashi Iwaif511b012008-08-15 16:46:42 +020017125#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17126
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017127#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17128#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17129
17130/* add playback controls from the parsed DAC table */
17131/* Based on ALC880 version. But ALC861VD has separate,
17132 * different NIDs for mute/unmute switch and volume control */
17133static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17134 const struct auto_pin_cfg *cfg)
17135{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017136 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017137 const char *pfx = alc_get_line_out_pfx(cfg, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017138 hda_nid_t nid_v, nid_s;
17139 int i, err;
17140
17141 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017142 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017143 continue;
17144 nid_v = alc861vd_idx_to_mixer_vol(
17145 alc880_dac_to_idx(
17146 spec->multiout.dac_nids[i]));
17147 nid_s = alc861vd_idx_to_mixer_switch(
17148 alc880_dac_to_idx(
17149 spec->multiout.dac_nids[i]));
17150
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017151 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017152 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017153 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17154 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017155 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17156 HDA_OUTPUT));
17157 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017158 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017159 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17160 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017161 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17162 HDA_OUTPUT));
17163 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017164 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017165 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17166 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017167 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17168 HDA_INPUT));
17169 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017170 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017171 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17172 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017173 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17174 HDA_INPUT));
17175 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017176 return err;
17177 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017178 const char *name = pfx;
17179 if (!name)
17180 name = chname[i];
17181 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17182 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017183 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17184 HDA_OUTPUT));
17185 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017186 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017187 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17188 name, i,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017189 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017190 HDA_INPUT));
17191 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017192 return err;
17193 }
17194 }
17195 return 0;
17196}
17197
17198/* add playback controls for speaker and HP outputs */
17199/* Based on ALC880 version. But ALC861VD has separate,
17200 * different NIDs for mute/unmute switch and volume control */
17201static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17202 hda_nid_t pin, const char *pfx)
17203{
17204 hda_nid_t nid_v, nid_s;
17205 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017206
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017207 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017208 return 0;
17209
17210 if (alc880_is_fixed_pin(pin)) {
17211 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17212 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017213 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017214 spec->multiout.hp_nid = nid_v;
17215 else
17216 spec->multiout.extra_out_nid[0] = nid_v;
17217 /* control HP volume/switch on the output mixer amp */
17218 nid_v = alc861vd_idx_to_mixer_vol(
17219 alc880_fixed_pin_idx(pin));
17220 nid_s = alc861vd_idx_to_mixer_switch(
17221 alc880_fixed_pin_idx(pin));
17222
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017223 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017224 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17225 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017226 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017227 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017228 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17229 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017230 return err;
17231 } else if (alc880_is_multi_pin(pin)) {
17232 /* set manual connection */
17233 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017234 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017235 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17236 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017237 return err;
17238 }
17239 return 0;
17240}
17241
17242/* parse the BIOS configuration and set up the alc_spec
17243 * return 1 if successful, 0 if the proper config is not found,
17244 * or a negative error code
17245 * Based on ALC880 version - had to change it to override
17246 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17247static int alc861vd_parse_auto_config(struct hda_codec *codec)
17248{
17249 struct alc_spec *spec = codec->spec;
17250 int err;
17251 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17252
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017253 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17254 alc861vd_ignore);
17255 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017256 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017257 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017258 return 0; /* can't find valid BIOS pin config */
17259
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017260 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17261 if (err < 0)
17262 return err;
17263 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17264 if (err < 0)
17265 return err;
17266 err = alc861vd_auto_create_extra_out(spec,
17267 spec->autocfg.speaker_pins[0],
17268 "Speaker");
17269 if (err < 0)
17270 return err;
17271 err = alc861vd_auto_create_extra_out(spec,
17272 spec->autocfg.hp_pins[0],
17273 "Headphone");
17274 if (err < 0)
17275 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017276 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017277 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017278 return err;
17279
17280 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17281
Takashi Iwai757899a2010-07-30 10:48:14 +020017282 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017283
Takashi Iwai603c4012008-07-30 15:01:44 +020017284 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017285 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017286
Takashi Iwaid88897e2008-10-31 15:01:37 +010017287 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017288
17289 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017290 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017291
Takashi Iwai776e1842007-08-29 15:07:11 +020017292 err = alc_auto_add_mic_boost(codec);
17293 if (err < 0)
17294 return err;
17295
Kailang Yang6227cdc2010-02-25 08:36:52 +010017296 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017297
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017298 return 1;
17299}
17300
17301/* additional initialization for auto-configuration model */
17302static void alc861vd_auto_init(struct hda_codec *codec)
17303{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017304 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017305 alc861vd_auto_init_multi_out(codec);
17306 alc861vd_auto_init_hp_out(codec);
17307 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017308 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017309 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017310 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017311 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017312}
17313
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017314enum {
17315 ALC660VD_FIX_ASUS_GPIO1
17316};
17317
17318/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017319static const struct alc_fixup alc861vd_fixups[] = {
17320 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017321 .type = ALC_FIXUP_VERBS,
17322 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017323 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17324 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17325 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17326 { }
17327 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017328 },
17329};
17330
17331static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17332 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17333 {}
17334};
17335
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017336static int patch_alc861vd(struct hda_codec *codec)
17337{
17338 struct alc_spec *spec;
17339 int err, board_config;
17340
17341 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17342 if (spec == NULL)
17343 return -ENOMEM;
17344
17345 codec->spec = spec;
17346
17347 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17348 alc861vd_models,
17349 alc861vd_cfg_tbl);
17350
17351 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017352 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17353 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017354 board_config = ALC861VD_AUTO;
17355 }
17356
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017357 if (board_config == ALC861VD_AUTO) {
17358 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17359 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17360 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017361
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017362 if (board_config == ALC861VD_AUTO) {
17363 /* automatic parse from the BIOS config */
17364 err = alc861vd_parse_auto_config(codec);
17365 if (err < 0) {
17366 alc_free(codec);
17367 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017368 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017369 printk(KERN_INFO
17370 "hda_codec: Cannot set up configuration "
17371 "from BIOS. Using base mode...\n");
17372 board_config = ALC861VD_3ST;
17373 }
17374 }
17375
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017376 err = snd_hda_attach_beep_device(codec, 0x23);
17377 if (err < 0) {
17378 alc_free(codec);
17379 return err;
17380 }
17381
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017382 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017383 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017384
Kailang Yang2f893282008-05-27 12:14:47 +020017385 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017386 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017387 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017388 }
17389
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017390 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17391 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17392
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017393 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17394 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17395
Takashi Iwaidd704692009-08-11 08:45:11 +020017396 if (!spec->adc_nids) {
17397 spec->adc_nids = alc861vd_adc_nids;
17398 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17399 }
17400 if (!spec->capsrc_nids)
17401 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017402
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017403 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017404 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017405
Takashi Iwai2134ea42008-01-10 16:53:55 +010017406 spec->vmaster_nid = 0x02;
17407
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017408 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017409
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017410 codec->patch_ops = alc_patch_ops;
17411
17412 if (board_config == ALC861VD_AUTO)
17413 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017414#ifdef CONFIG_SND_HDA_POWER_SAVE
17415 if (!spec->loopback.amplist)
17416 spec->loopback.amplist = alc861vd_loopbacks;
17417#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017418
17419 return 0;
17420}
17421
17422/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017423 * ALC662 support
17424 *
17425 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17426 * configuration. Each pin widget can choose any input DACs and a mixer.
17427 * Each ADC is connected from a mixer of all inputs. This makes possible
17428 * 6-channel independent captures.
17429 *
17430 * In addition, an independent DAC for the multi-playback (not used in this
17431 * driver yet).
17432 */
17433#define ALC662_DIGOUT_NID 0x06
17434#define ALC662_DIGIN_NID 0x0a
17435
17436static hda_nid_t alc662_dac_nids[4] = {
17437 /* front, rear, clfe, rear_surr */
17438 0x02, 0x03, 0x04
17439};
17440
Kailang Yang622e84c2009-04-21 07:39:04 +020017441static hda_nid_t alc272_dac_nids[2] = {
17442 0x02, 0x03
17443};
17444
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017445static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017446 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017447 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017448};
Takashi Iwaie1406342008-02-11 18:32:32 +010017449
Kailang Yang622e84c2009-04-21 07:39:04 +020017450static hda_nid_t alc272_adc_nids[1] = {
17451 /* ADC1-2 */
17452 0x08,
17453};
17454
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017455static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017456static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17457
Takashi Iwaie1406342008-02-11 18:32:32 +010017458
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017459/* input MUX */
17460/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017461static struct hda_input_mux alc662_capture_source = {
17462 .num_items = 4,
17463 .items = {
17464 { "Mic", 0x0 },
17465 { "Front Mic", 0x1 },
17466 { "Line", 0x2 },
17467 { "CD", 0x4 },
17468 },
17469};
17470
17471static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17472 .num_items = 2,
17473 .items = {
17474 { "Mic", 0x1 },
17475 { "Line", 0x2 },
17476 },
17477};
Kailang Yang291702f2007-10-16 14:28:03 +020017478
Kailang Yang6dda9f42008-05-27 12:05:31 +020017479static struct hda_input_mux alc663_capture_source = {
17480 .num_items = 3,
17481 .items = {
17482 { "Mic", 0x0 },
17483 { "Front Mic", 0x1 },
17484 { "Line", 0x2 },
17485 },
17486};
17487
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017488#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017489static struct hda_input_mux alc272_nc10_capture_source = {
17490 .num_items = 16,
17491 .items = {
17492 { "Autoselect Mic", 0x0 },
17493 { "Internal Mic", 0x1 },
17494 { "In-0x02", 0x2 },
17495 { "In-0x03", 0x3 },
17496 { "In-0x04", 0x4 },
17497 { "In-0x05", 0x5 },
17498 { "In-0x06", 0x6 },
17499 { "In-0x07", 0x7 },
17500 { "In-0x08", 0x8 },
17501 { "In-0x09", 0x9 },
17502 { "In-0x0a", 0x0a },
17503 { "In-0x0b", 0x0b },
17504 { "In-0x0c", 0x0c },
17505 { "In-0x0d", 0x0d },
17506 { "In-0x0e", 0x0e },
17507 { "In-0x0f", 0x0f },
17508 },
17509};
17510#endif
17511
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017512/*
17513 * 2ch mode
17514 */
17515static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17516 { 2, NULL }
17517};
17518
17519/*
17520 * 2ch mode
17521 */
17522static struct hda_verb alc662_3ST_ch2_init[] = {
17523 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17524 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17525 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17526 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17527 { } /* end */
17528};
17529
17530/*
17531 * 6ch mode
17532 */
17533static struct hda_verb alc662_3ST_ch6_init[] = {
17534 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17535 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17536 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17537 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17538 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17539 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17540 { } /* end */
17541};
17542
17543static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17544 { 2, alc662_3ST_ch2_init },
17545 { 6, alc662_3ST_ch6_init },
17546};
17547
17548/*
17549 * 2ch mode
17550 */
17551static struct hda_verb alc662_sixstack_ch6_init[] = {
17552 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17553 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17554 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17555 { } /* end */
17556};
17557
17558/*
17559 * 6ch mode
17560 */
17561static struct hda_verb alc662_sixstack_ch8_init[] = {
17562 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17563 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17564 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17565 { } /* end */
17566};
17567
17568static struct hda_channel_mode alc662_5stack_modes[2] = {
17569 { 2, alc662_sixstack_ch6_init },
17570 { 6, alc662_sixstack_ch8_init },
17571};
17572
17573/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17574 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17575 */
17576
17577static struct snd_kcontrol_new alc662_base_mixer[] = {
17578 /* output mixer control */
17579 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017580 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017581 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017582 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017583 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17584 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017585 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17586 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017587 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17588
17589 /*Input mixer control */
17590 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17591 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17592 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17593 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17594 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17595 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17596 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17597 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017598 { } /* end */
17599};
17600
17601static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17602 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017603 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017604 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17605 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17606 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17607 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17608 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17609 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17610 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17611 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17612 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017613 { } /* end */
17614};
17615
17616static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17617 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017618 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017619 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017620 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017621 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17622 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017623 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17624 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017625 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17626 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17627 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17628 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17629 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17632 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17633 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017634 { } /* end */
17635};
17636
17637static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17638 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17639 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017640 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17641 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17643 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17644 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017647 { } /* end */
17648};
17649
Kailang Yang291702f2007-10-16 14:28:03 +020017650static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017651 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17652 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017653
David Henningsson5f99f862011-01-04 15:24:24 +010017654 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017657
David Henningsson5f99f862011-01-04 15:24:24 +010017658 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017659 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17660 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017661 { } /* end */
17662};
17663
Kailang Yang8c427222008-01-10 13:03:59 +010017664static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017665 ALC262_HIPPO_MASTER_SWITCH,
17666 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017667 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017668 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17669 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017670 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17671 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17672 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17675 { } /* end */
17676};
17677
Kailang Yangf1d4e282008-08-26 14:03:29 +020017678static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17679 .ops = &snd_hda_bind_vol,
17680 .values = {
17681 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17682 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17683 0
17684 },
17685};
17686
17687static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17688 .ops = &snd_hda_bind_sw,
17689 .values = {
17690 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17691 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17692 0
17693 },
17694};
17695
Kailang Yang6dda9f42008-05-27 12:05:31 +020017696static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017697 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17698 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17700 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17701 { } /* end */
17702};
17703
17704static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17705 .ops = &snd_hda_bind_sw,
17706 .values = {
17707 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17708 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17709 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17710 0
17711 },
17712};
17713
17714static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17715 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17716 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17717 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17718 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17719 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17720 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17721
17722 { } /* end */
17723};
17724
17725static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17726 .ops = &snd_hda_bind_sw,
17727 .values = {
17728 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17729 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17730 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17731 0
17732 },
17733};
17734
17735static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17736 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17737 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17740 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17741 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17742 { } /* end */
17743};
17744
17745static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017746 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17747 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017748 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17749 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17750 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17751 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17752 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17753 { } /* end */
17754};
17755
17756static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17757 .ops = &snd_hda_bind_vol,
17758 .values = {
17759 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17760 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17761 0
17762 },
17763};
17764
17765static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17766 .ops = &snd_hda_bind_sw,
17767 .values = {
17768 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17769 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17770 0
17771 },
17772};
17773
17774static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17775 HDA_BIND_VOL("Master Playback Volume",
17776 &alc663_asus_two_bind_master_vol),
17777 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17778 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017782 { } /* end */
17783};
17784
17785static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17786 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17787 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17788 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17789 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17790 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17791 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017792 { } /* end */
17793};
17794
17795static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17796 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17797 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17798 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17799 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17801
17802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017804 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17805 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017806 { } /* end */
17807};
17808
17809static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17810 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17811 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17813
17814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017816 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17817 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17820 { } /* end */
17821};
17822
Kailang Yangebb83ee2009-12-17 12:23:00 +010017823static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17824 .ops = &snd_hda_bind_sw,
17825 .values = {
17826 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17827 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17828 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17829 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17830 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17831 0
17832 },
17833};
17834
17835static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17836 .ops = &snd_hda_bind_sw,
17837 .values = {
17838 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17839 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17840 0
17841 },
17842};
17843
17844static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17845 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17846 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17847 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17848 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17849 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17850 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17851 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17854 { } /* end */
17855};
17856
17857static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17858 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17859 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17860 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17861 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17862 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17865 { } /* end */
17866};
17867
17868
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017869static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17870 {
17871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17872 .name = "Channel Mode",
17873 .info = alc_ch_mode_info,
17874 .get = alc_ch_mode_get,
17875 .put = alc_ch_mode_put,
17876 },
17877 { } /* end */
17878};
17879
17880static struct hda_verb alc662_init_verbs[] = {
17881 /* ADC: mute amp left and right */
17882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17883 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017884
Kailang Yangb60dd392007-09-20 12:50:29 +020017885 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17887 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17889 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017891
17892 /* Front Pin: output 0 (0x0c) */
17893 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17894 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17895
17896 /* Rear Pin: output 1 (0x0d) */
17897 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17898 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17899
17900 /* CLFE Pin: output 2 (0x0e) */
17901 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17902 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17903
17904 /* Mic (rear) pin: input vref at 80% */
17905 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17906 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17907 /* Front Mic pin: input vref at 80% */
17908 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17909 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17910 /* Line In pin: input */
17911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17913 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17914 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17915 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17916 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17917 /* CD pin widget for input */
17918 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17919
17920 /* FIXME: use matrix-type input source selection */
17921 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17922 /* Input mixer */
17923 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017924 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017925
17926 /* always trun on EAPD */
17927 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17928 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17929
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017930 { }
17931};
17932
Kailang Yangcec27c82010-02-04 14:18:18 +010017933static struct hda_verb alc663_init_verbs[] = {
17934 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17935 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17936 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17937 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17938 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17939 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17940 { }
17941};
17942
17943static struct hda_verb alc272_init_verbs[] = {
17944 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17945 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17946 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17948 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17949 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17950 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17951 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17952 { }
17953};
17954
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017955static struct hda_verb alc662_sue_init_verbs[] = {
17956 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17957 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017958 {}
17959};
17960
17961static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17962 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17963 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17964 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017965};
17966
Kailang Yang8c427222008-01-10 13:03:59 +010017967/* Set Unsolicited Event*/
17968static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17969 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17970 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17971 {}
17972};
17973
Kailang Yang6dda9f42008-05-27 12:05:31 +020017974static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17976 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017977 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17978 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017979 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017982 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17983 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17984 {}
17985};
17986
Kailang Yangf1d4e282008-08-26 14:03:29 +020017987static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17988 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17989 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17990 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17991 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17993 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17994 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17995 {}
17996};
17997
17998static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17999 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18000 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18001 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18002 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18005 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18006 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18007 {}
18008};
18009
18010static struct hda_verb alc663_15jd_amic_init_verbs[] = {
18011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18015 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18016 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18017 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18018 {}
18019};
18020
18021static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
18022 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18023 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18024 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18025 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18026 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18028 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18029 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18030 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18031 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18032 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18033 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18034 {}
18035};
18036
18037static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18038 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18039 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18040 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18041 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18042 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18043 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18044 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18045 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18046 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18047 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18048 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18049 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18050 {}
18051};
18052
Kailang Yang6dda9f42008-05-27 12:05:31 +020018053static struct hda_verb alc663_g71v_init_verbs[] = {
18054 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18055 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18056 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18057
18058 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18059 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18060 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18061
18062 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18063 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18064 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18065 {}
18066};
18067
18068static struct hda_verb alc663_g50v_init_verbs[] = {
18069 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18070 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18071 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18072
18073 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18074 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18075 {}
18076};
18077
Kailang Yangf1d4e282008-08-26 14:03:29 +020018078static struct hda_verb alc662_ecs_init_verbs[] = {
18079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18081 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18082 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18083 {}
18084};
18085
Kailang Yang622e84c2009-04-21 07:39:04 +020018086static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18087 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18088 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18090 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18091 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18092 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18093 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18095 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18096 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18097 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18098 {}
18099};
18100
18101static struct hda_verb alc272_dell_init_verbs[] = {
18102 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18103 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18104 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18105 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18106 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18107 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18108 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18109 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18110 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18111 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18112 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18113 {}
18114};
18115
Kailang Yangebb83ee2009-12-17 12:23:00 +010018116static struct hda_verb alc663_mode7_init_verbs[] = {
18117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18118 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18119 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18120 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18121 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18122 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18123 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18124 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18125 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18126 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18127 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18129 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18130 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18131 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18132 {}
18133};
18134
18135static struct hda_verb alc663_mode8_init_verbs[] = {
18136 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18138 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18139 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18140 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18141 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18142 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18143 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18144 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18145 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18146 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18147 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18148 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18149 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18150 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18151 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18152 {}
18153};
18154
Kailang Yangf1d4e282008-08-26 14:03:29 +020018155static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18156 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18157 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18158 { } /* end */
18159};
18160
Kailang Yang622e84c2009-04-21 07:39:04 +020018161static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18162 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18163 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18164 { } /* end */
18165};
18166
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018167static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18168{
18169 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018170 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018171
Wu Fengguang864f92b2009-11-18 12:38:02 +080018172 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018173 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018174
Takashi Iwai47fd8302007-08-10 17:11:07 +020018175 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18176 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018177}
18178
18179static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18180{
18181 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018182 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018183
Wu Fengguang864f92b2009-11-18 12:38:02 +080018184 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018185 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018186
Takashi Iwai47fd8302007-08-10 17:11:07 +020018187 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18188 HDA_AMP_MUTE, bits);
18189 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18190 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018191}
18192
18193static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18194 unsigned int res)
18195{
18196 if ((res >> 26) == ALC880_HP_EVENT)
18197 alc662_lenovo_101e_all_automute(codec);
18198 if ((res >> 26) == ALC880_FRONT_EVENT)
18199 alc662_lenovo_101e_ispeaker_automute(codec);
18200}
18201
Kailang Yang291702f2007-10-16 14:28:03 +020018202/* unsolicited event for HP jack sensing */
18203static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18204 unsigned int res)
18205{
Kailang Yang291702f2007-10-16 14:28:03 +020018206 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018207 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018208 else
18209 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018210}
18211
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018212static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018213{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018214 struct alc_spec *spec = codec->spec;
18215
18216 alc262_hippo1_setup(codec);
18217 spec->ext_mic.pin = 0x18;
18218 spec->ext_mic.mux_idx = 0;
18219 spec->int_mic.pin = 0x19;
18220 spec->int_mic.mux_idx = 1;
18221 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018222}
18223
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018224static void alc662_eeepc_inithook(struct hda_codec *codec)
18225{
18226 alc262_hippo_automute(codec);
18227 alc_mic_automute(codec);
18228}
18229
18230static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018231{
Takashi Iwai42171c12009-05-08 14:11:43 +020018232 struct alc_spec *spec = codec->spec;
18233
18234 spec->autocfg.hp_pins[0] = 0x14;
18235 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018236}
18237
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018238#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18239
Kailang Yang6dda9f42008-05-27 12:05:31 +020018240static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18241{
18242 unsigned int present;
18243 unsigned char bits;
18244
Wu Fengguang864f92b2009-11-18 12:38:02 +080018245 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018246 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018247 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018248 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018249 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018250 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018251}
18252
18253static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18254{
18255 unsigned int present;
18256 unsigned char bits;
18257
Wu Fengguang864f92b2009-11-18 12:38:02 +080018258 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018259 bits = present ? HDA_AMP_MUTE : 0;
18260 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018261 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018262 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018263 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018264 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018265 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018266 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018267 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018268}
18269
18270static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18271{
18272 unsigned int present;
18273 unsigned char bits;
18274
Wu Fengguang864f92b2009-11-18 12:38:02 +080018275 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018276 bits = present ? HDA_AMP_MUTE : 0;
18277 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018278 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018279 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018280 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018281 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018282 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018283 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018284 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018285}
18286
18287static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18288{
18289 unsigned int present;
18290 unsigned char bits;
18291
Wu Fengguang864f92b2009-11-18 12:38:02 +080018292 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018293 bits = present ? 0 : PIN_OUT;
18294 snd_hda_codec_write(codec, 0x14, 0,
18295 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18296}
18297
18298static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18299{
18300 unsigned int present1, present2;
18301
Wu Fengguang864f92b2009-11-18 12:38:02 +080018302 present1 = snd_hda_jack_detect(codec, 0x21);
18303 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018304
18305 if (present1 || present2) {
18306 snd_hda_codec_write_cache(codec, 0x14, 0,
18307 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18308 } else {
18309 snd_hda_codec_write_cache(codec, 0x14, 0,
18310 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18311 }
18312}
18313
18314static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18315{
18316 unsigned int present1, present2;
18317
Wu Fengguang864f92b2009-11-18 12:38:02 +080018318 present1 = snd_hda_jack_detect(codec, 0x1b);
18319 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018320
18321 if (present1 || present2) {
18322 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018323 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018324 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018325 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018326 } else {
18327 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018328 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018329 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018330 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018331 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018332}
18333
Kailang Yangebb83ee2009-12-17 12:23:00 +010018334static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18335{
18336 unsigned int present1, present2;
18337
18338 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18339 AC_VERB_GET_PIN_SENSE, 0)
18340 & AC_PINSENSE_PRESENCE;
18341 present2 = snd_hda_codec_read(codec, 0x21, 0,
18342 AC_VERB_GET_PIN_SENSE, 0)
18343 & AC_PINSENSE_PRESENCE;
18344
18345 if (present1 || present2) {
18346 snd_hda_codec_write_cache(codec, 0x14, 0,
18347 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18348 snd_hda_codec_write_cache(codec, 0x17, 0,
18349 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18350 } else {
18351 snd_hda_codec_write_cache(codec, 0x14, 0,
18352 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18353 snd_hda_codec_write_cache(codec, 0x17, 0,
18354 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18355 }
18356}
18357
18358static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18359{
18360 unsigned int present1, present2;
18361
18362 present1 = snd_hda_codec_read(codec, 0x21, 0,
18363 AC_VERB_GET_PIN_SENSE, 0)
18364 & AC_PINSENSE_PRESENCE;
18365 present2 = snd_hda_codec_read(codec, 0x15, 0,
18366 AC_VERB_GET_PIN_SENSE, 0)
18367 & AC_PINSENSE_PRESENCE;
18368
18369 if (present1 || present2) {
18370 snd_hda_codec_write_cache(codec, 0x14, 0,
18371 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18372 snd_hda_codec_write_cache(codec, 0x17, 0,
18373 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18374 } else {
18375 snd_hda_codec_write_cache(codec, 0x14, 0,
18376 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18377 snd_hda_codec_write_cache(codec, 0x17, 0,
18378 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18379 }
18380}
18381
Kailang Yang6dda9f42008-05-27 12:05:31 +020018382static void alc663_m51va_unsol_event(struct hda_codec *codec,
18383 unsigned int res)
18384{
18385 switch (res >> 26) {
18386 case ALC880_HP_EVENT:
18387 alc663_m51va_speaker_automute(codec);
18388 break;
18389 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018390 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018391 break;
18392 }
18393}
18394
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018395static void alc663_m51va_setup(struct hda_codec *codec)
18396{
18397 struct alc_spec *spec = codec->spec;
18398 spec->ext_mic.pin = 0x18;
18399 spec->ext_mic.mux_idx = 0;
18400 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018401 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018402 spec->auto_mic = 1;
18403}
18404
Kailang Yang6dda9f42008-05-27 12:05:31 +020018405static void alc663_m51va_inithook(struct hda_codec *codec)
18406{
18407 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018408 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018409}
18410
Kailang Yangf1d4e282008-08-26 14:03:29 +020018411/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018412#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018413
18414static void alc663_mode1_setup(struct hda_codec *codec)
18415{
18416 struct alc_spec *spec = codec->spec;
18417 spec->ext_mic.pin = 0x18;
18418 spec->ext_mic.mux_idx = 0;
18419 spec->int_mic.pin = 0x19;
18420 spec->int_mic.mux_idx = 1;
18421 spec->auto_mic = 1;
18422}
18423
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018424#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018425
Kailang Yangf1d4e282008-08-26 14:03:29 +020018426/* ***************** Mode2 ******************************/
18427static void alc662_mode2_unsol_event(struct hda_codec *codec,
18428 unsigned int res)
18429{
18430 switch (res >> 26) {
18431 case ALC880_HP_EVENT:
18432 alc662_f5z_speaker_automute(codec);
18433 break;
18434 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018435 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018436 break;
18437 }
18438}
18439
Kailang Yangebb83ee2009-12-17 12:23:00 +010018440#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018441
Kailang Yangf1d4e282008-08-26 14:03:29 +020018442static void alc662_mode2_inithook(struct hda_codec *codec)
18443{
18444 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018445 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018446}
18447/* ***************** Mode3 ******************************/
18448static void alc663_mode3_unsol_event(struct hda_codec *codec,
18449 unsigned int res)
18450{
18451 switch (res >> 26) {
18452 case ALC880_HP_EVENT:
18453 alc663_two_hp_m1_speaker_automute(codec);
18454 break;
18455 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018456 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018457 break;
18458 }
18459}
18460
Kailang Yangebb83ee2009-12-17 12:23:00 +010018461#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018462
Kailang Yangf1d4e282008-08-26 14:03:29 +020018463static void alc663_mode3_inithook(struct hda_codec *codec)
18464{
18465 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018466 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018467}
18468/* ***************** Mode4 ******************************/
18469static void alc663_mode4_unsol_event(struct hda_codec *codec,
18470 unsigned int res)
18471{
18472 switch (res >> 26) {
18473 case ALC880_HP_EVENT:
18474 alc663_21jd_two_speaker_automute(codec);
18475 break;
18476 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018477 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018478 break;
18479 }
18480}
18481
Kailang Yangebb83ee2009-12-17 12:23:00 +010018482#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018483
Kailang Yangf1d4e282008-08-26 14:03:29 +020018484static void alc663_mode4_inithook(struct hda_codec *codec)
18485{
18486 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018487 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018488}
18489/* ***************** Mode5 ******************************/
18490static void alc663_mode5_unsol_event(struct hda_codec *codec,
18491 unsigned int res)
18492{
18493 switch (res >> 26) {
18494 case ALC880_HP_EVENT:
18495 alc663_15jd_two_speaker_automute(codec);
18496 break;
18497 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018498 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018499 break;
18500 }
18501}
18502
Kailang Yangebb83ee2009-12-17 12:23:00 +010018503#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018504
Kailang Yangf1d4e282008-08-26 14:03:29 +020018505static void alc663_mode5_inithook(struct hda_codec *codec)
18506{
18507 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018508 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018509}
18510/* ***************** Mode6 ******************************/
18511static void alc663_mode6_unsol_event(struct hda_codec *codec,
18512 unsigned int res)
18513{
18514 switch (res >> 26) {
18515 case ALC880_HP_EVENT:
18516 alc663_two_hp_m2_speaker_automute(codec);
18517 break;
18518 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018519 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018520 break;
18521 }
18522}
18523
Kailang Yangebb83ee2009-12-17 12:23:00 +010018524#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018525
Kailang Yangf1d4e282008-08-26 14:03:29 +020018526static void alc663_mode6_inithook(struct hda_codec *codec)
18527{
18528 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018529 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018530}
18531
Kailang Yangebb83ee2009-12-17 12:23:00 +010018532/* ***************** Mode7 ******************************/
18533static void alc663_mode7_unsol_event(struct hda_codec *codec,
18534 unsigned int res)
18535{
18536 switch (res >> 26) {
18537 case ALC880_HP_EVENT:
18538 alc663_two_hp_m7_speaker_automute(codec);
18539 break;
18540 case ALC880_MIC_EVENT:
18541 alc_mic_automute(codec);
18542 break;
18543 }
18544}
18545
18546#define alc663_mode7_setup alc663_mode1_setup
18547
18548static void alc663_mode7_inithook(struct hda_codec *codec)
18549{
18550 alc663_two_hp_m7_speaker_automute(codec);
18551 alc_mic_automute(codec);
18552}
18553
18554/* ***************** Mode8 ******************************/
18555static void alc663_mode8_unsol_event(struct hda_codec *codec,
18556 unsigned int res)
18557{
18558 switch (res >> 26) {
18559 case ALC880_HP_EVENT:
18560 alc663_two_hp_m8_speaker_automute(codec);
18561 break;
18562 case ALC880_MIC_EVENT:
18563 alc_mic_automute(codec);
18564 break;
18565 }
18566}
18567
18568#define alc663_mode8_setup alc663_m51va_setup
18569
18570static void alc663_mode8_inithook(struct hda_codec *codec)
18571{
18572 alc663_two_hp_m8_speaker_automute(codec);
18573 alc_mic_automute(codec);
18574}
18575
Kailang Yang6dda9f42008-05-27 12:05:31 +020018576static void alc663_g71v_hp_automute(struct hda_codec *codec)
18577{
18578 unsigned int present;
18579 unsigned char bits;
18580
Wu Fengguang864f92b2009-11-18 12:38:02 +080018581 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018582 bits = present ? HDA_AMP_MUTE : 0;
18583 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18584 HDA_AMP_MUTE, bits);
18585 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18586 HDA_AMP_MUTE, bits);
18587}
18588
18589static void alc663_g71v_front_automute(struct hda_codec *codec)
18590{
18591 unsigned int present;
18592 unsigned char bits;
18593
Wu Fengguang864f92b2009-11-18 12:38:02 +080018594 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018595 bits = present ? HDA_AMP_MUTE : 0;
18596 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18597 HDA_AMP_MUTE, bits);
18598}
18599
18600static void alc663_g71v_unsol_event(struct hda_codec *codec,
18601 unsigned int res)
18602{
18603 switch (res >> 26) {
18604 case ALC880_HP_EVENT:
18605 alc663_g71v_hp_automute(codec);
18606 break;
18607 case ALC880_FRONT_EVENT:
18608 alc663_g71v_front_automute(codec);
18609 break;
18610 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018611 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018612 break;
18613 }
18614}
18615
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018616#define alc663_g71v_setup alc663_m51va_setup
18617
Kailang Yang6dda9f42008-05-27 12:05:31 +020018618static void alc663_g71v_inithook(struct hda_codec *codec)
18619{
18620 alc663_g71v_front_automute(codec);
18621 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018622 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018623}
18624
18625static void alc663_g50v_unsol_event(struct hda_codec *codec,
18626 unsigned int res)
18627{
18628 switch (res >> 26) {
18629 case ALC880_HP_EVENT:
18630 alc663_m51va_speaker_automute(codec);
18631 break;
18632 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018633 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018634 break;
18635 }
18636}
18637
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018638#define alc663_g50v_setup alc663_m51va_setup
18639
Kailang Yang6dda9f42008-05-27 12:05:31 +020018640static void alc663_g50v_inithook(struct hda_codec *codec)
18641{
18642 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018643 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018644}
18645
Kailang Yangf1d4e282008-08-26 14:03:29 +020018646static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18647 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018648 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018649
David Henningsson5f99f862011-01-04 15:24:24 +010018650 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018651 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18652 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018653
David Henningsson5f99f862011-01-04 15:24:24 +010018654 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018655 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18656 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018657 { } /* end */
18658};
18659
Chris Pockelé9541ba12009-05-12 08:08:53 +020018660static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18661 /* Master Playback automatically created from Speaker and Headphone */
18662 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18663 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18664 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18666
David Henningsson8607f7c2010-12-20 14:43:54 +010018667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018669 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018670
David Henningsson28c4edb2010-12-20 14:24:29 +010018671 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18672 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018673 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018674 { } /* end */
18675};
18676
Takashi Iwaicb53c622007-08-10 17:21:45 +020018677#ifdef CONFIG_SND_HDA_POWER_SAVE
18678#define alc662_loopbacks alc880_loopbacks
18679#endif
18680
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018681
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018682/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018683#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18684#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18685#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18686#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18687
18688/*
18689 * configuration and preset
18690 */
18691static const char *alc662_models[ALC662_MODEL_LAST] = {
18692 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18693 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18694 [ALC662_3ST_6ch] = "3stack-6ch",
18695 [ALC662_5ST_DIG] = "6stack-dig",
18696 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018697 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018698 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018699 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018700 [ALC663_ASUS_M51VA] = "m51va",
18701 [ALC663_ASUS_G71V] = "g71v",
18702 [ALC663_ASUS_H13] = "h13",
18703 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018704 [ALC663_ASUS_MODE1] = "asus-mode1",
18705 [ALC662_ASUS_MODE2] = "asus-mode2",
18706 [ALC663_ASUS_MODE3] = "asus-mode3",
18707 [ALC663_ASUS_MODE4] = "asus-mode4",
18708 [ALC663_ASUS_MODE5] = "asus-mode5",
18709 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018710 [ALC663_ASUS_MODE7] = "asus-mode7",
18711 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018712 [ALC272_DELL] = "dell",
18713 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018714 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018715 [ALC662_AUTO] = "auto",
18716};
18717
18718static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018719 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018720 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18721 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018722 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18723 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018724 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018725 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18726 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18727 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18728 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018729 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18730 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018731 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018732 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18733 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18734 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18735 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18736 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018737 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018738 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18739 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018740 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18741 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18742 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18743 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018744 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018745 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18746 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18747 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018748 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18749 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18750 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18751 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018752 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018753 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18754 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018755 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018756 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18757 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18758 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018759 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018760 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018761 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18762 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018763 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18764 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18765 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018766 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018767 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18768 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018769 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018770 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018771 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018772 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18773 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18774 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018775 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018776 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18777 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018778 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018779 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018780 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018781 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018782 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18783 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018784 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018785 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018786 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18787 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018788 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018789 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018790 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018791 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018792 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018793 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018794 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18795 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018796 {}
18797};
18798
18799static struct alc_config_preset alc662_presets[] = {
18800 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018801 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018802 .init_verbs = { alc662_init_verbs },
18803 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18804 .dac_nids = alc662_dac_nids,
18805 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018806 .dig_in_nid = ALC662_DIGIN_NID,
18807 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18808 .channel_mode = alc662_3ST_2ch_modes,
18809 .input_mux = &alc662_capture_source,
18810 },
18811 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018812 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018813 .init_verbs = { alc662_init_verbs },
18814 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18815 .dac_nids = alc662_dac_nids,
18816 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018817 .dig_in_nid = ALC662_DIGIN_NID,
18818 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18819 .channel_mode = alc662_3ST_6ch_modes,
18820 .need_dac_fix = 1,
18821 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018822 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018823 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018824 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018825 .init_verbs = { alc662_init_verbs },
18826 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18827 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018828 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18829 .channel_mode = alc662_3ST_6ch_modes,
18830 .need_dac_fix = 1,
18831 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018832 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018833 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018834 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018835 .init_verbs = { alc662_init_verbs },
18836 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18837 .dac_nids = alc662_dac_nids,
18838 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018839 .dig_in_nid = ALC662_DIGIN_NID,
18840 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18841 .channel_mode = alc662_5stack_modes,
18842 .input_mux = &alc662_capture_source,
18843 },
18844 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018845 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018846 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18847 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18848 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018849 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18850 .channel_mode = alc662_3ST_2ch_modes,
18851 .input_mux = &alc662_lenovo_101e_capture_source,
18852 .unsol_event = alc662_lenovo_101e_unsol_event,
18853 .init_hook = alc662_lenovo_101e_all_automute,
18854 },
Kailang Yang291702f2007-10-16 14:28:03 +020018855 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018856 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018857 .init_verbs = { alc662_init_verbs,
18858 alc662_eeepc_sue_init_verbs },
18859 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18860 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018861 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18862 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018863 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018864 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018865 .init_hook = alc662_eeepc_inithook,
18866 },
Kailang Yang8c427222008-01-10 13:03:59 +010018867 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018868 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018869 alc662_chmode_mixer },
18870 .init_verbs = { alc662_init_verbs,
18871 alc662_eeepc_ep20_sue_init_verbs },
18872 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18873 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018874 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18875 .channel_mode = alc662_3ST_6ch_modes,
18876 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018877 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018878 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018879 .init_hook = alc662_eeepc_ep20_inithook,
18880 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018881 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018882 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018883 .init_verbs = { alc662_init_verbs,
18884 alc662_ecs_init_verbs },
18885 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18886 .dac_nids = alc662_dac_nids,
18887 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18888 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018889 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018890 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018891 .init_hook = alc662_eeepc_inithook,
18892 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018893 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018894 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018895 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18896 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18897 .dac_nids = alc662_dac_nids,
18898 .dig_out_nid = ALC662_DIGOUT_NID,
18899 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18900 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018901 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018902 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018903 .init_hook = alc663_m51va_inithook,
18904 },
18905 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018906 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018907 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18908 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18909 .dac_nids = alc662_dac_nids,
18910 .dig_out_nid = ALC662_DIGOUT_NID,
18911 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18912 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018913 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018914 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018915 .init_hook = alc663_g71v_inithook,
18916 },
18917 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018918 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018919 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18920 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18921 .dac_nids = alc662_dac_nids,
18922 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18923 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018924 .unsol_event = alc663_m51va_unsol_event,
18925 .init_hook = alc663_m51va_inithook,
18926 },
18927 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018928 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018929 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18930 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18931 .dac_nids = alc662_dac_nids,
18932 .dig_out_nid = ALC662_DIGOUT_NID,
18933 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18934 .channel_mode = alc662_3ST_6ch_modes,
18935 .input_mux = &alc663_capture_source,
18936 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018937 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018938 .init_hook = alc663_g50v_inithook,
18939 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018940 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018941 .mixers = { alc663_m51va_mixer },
18942 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018943 .init_verbs = { alc662_init_verbs,
18944 alc663_21jd_amic_init_verbs },
18945 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18946 .hp_nid = 0x03,
18947 .dac_nids = alc662_dac_nids,
18948 .dig_out_nid = ALC662_DIGOUT_NID,
18949 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18950 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018951 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018952 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018953 .init_hook = alc663_mode1_inithook,
18954 },
18955 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018956 .mixers = { alc662_1bjd_mixer },
18957 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018958 .init_verbs = { alc662_init_verbs,
18959 alc662_1bjd_amic_init_verbs },
18960 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18961 .dac_nids = alc662_dac_nids,
18962 .dig_out_nid = ALC662_DIGOUT_NID,
18963 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18964 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018965 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018966 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018967 .init_hook = alc662_mode2_inithook,
18968 },
18969 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018970 .mixers = { alc663_two_hp_m1_mixer },
18971 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018972 .init_verbs = { alc662_init_verbs,
18973 alc663_two_hp_amic_m1_init_verbs },
18974 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18975 .hp_nid = 0x03,
18976 .dac_nids = alc662_dac_nids,
18977 .dig_out_nid = ALC662_DIGOUT_NID,
18978 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18979 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018980 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018981 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018982 .init_hook = alc663_mode3_inithook,
18983 },
18984 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018985 .mixers = { alc663_asus_21jd_clfe_mixer },
18986 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018987 .init_verbs = { alc662_init_verbs,
18988 alc663_21jd_amic_init_verbs},
18989 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18990 .hp_nid = 0x03,
18991 .dac_nids = alc662_dac_nids,
18992 .dig_out_nid = ALC662_DIGOUT_NID,
18993 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18994 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018995 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018996 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018997 .init_hook = alc663_mode4_inithook,
18998 },
18999 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019000 .mixers = { alc663_asus_15jd_clfe_mixer },
19001 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019002 .init_verbs = { alc662_init_verbs,
19003 alc663_15jd_amic_init_verbs },
19004 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19005 .hp_nid = 0x03,
19006 .dac_nids = alc662_dac_nids,
19007 .dig_out_nid = ALC662_DIGOUT_NID,
19008 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19009 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019010 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019011 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019012 .init_hook = alc663_mode5_inithook,
19013 },
19014 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019015 .mixers = { alc663_two_hp_m2_mixer },
19016 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019017 .init_verbs = { alc662_init_verbs,
19018 alc663_two_hp_amic_m2_init_verbs },
19019 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19020 .hp_nid = 0x03,
19021 .dac_nids = alc662_dac_nids,
19022 .dig_out_nid = ALC662_DIGOUT_NID,
19023 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19024 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019025 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019026 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019027 .init_hook = alc663_mode6_inithook,
19028 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019029 [ALC663_ASUS_MODE7] = {
19030 .mixers = { alc663_mode7_mixer },
19031 .cap_mixer = alc662_auto_capture_mixer,
19032 .init_verbs = { alc662_init_verbs,
19033 alc663_mode7_init_verbs },
19034 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19035 .hp_nid = 0x03,
19036 .dac_nids = alc662_dac_nids,
19037 .dig_out_nid = ALC662_DIGOUT_NID,
19038 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19039 .channel_mode = alc662_3ST_2ch_modes,
19040 .unsol_event = alc663_mode7_unsol_event,
19041 .setup = alc663_mode7_setup,
19042 .init_hook = alc663_mode7_inithook,
19043 },
19044 [ALC663_ASUS_MODE8] = {
19045 .mixers = { alc663_mode8_mixer },
19046 .cap_mixer = alc662_auto_capture_mixer,
19047 .init_verbs = { alc662_init_verbs,
19048 alc663_mode8_init_verbs },
19049 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19050 .hp_nid = 0x03,
19051 .dac_nids = alc662_dac_nids,
19052 .dig_out_nid = ALC662_DIGOUT_NID,
19053 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19054 .channel_mode = alc662_3ST_2ch_modes,
19055 .unsol_event = alc663_mode8_unsol_event,
19056 .setup = alc663_mode8_setup,
19057 .init_hook = alc663_mode8_inithook,
19058 },
Kailang Yang622e84c2009-04-21 07:39:04 +020019059 [ALC272_DELL] = {
19060 .mixers = { alc663_m51va_mixer },
19061 .cap_mixer = alc272_auto_capture_mixer,
19062 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
19063 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19064 .dac_nids = alc662_dac_nids,
19065 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19066 .adc_nids = alc272_adc_nids,
19067 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19068 .capsrc_nids = alc272_capsrc_nids,
19069 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019070 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019071 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019072 .init_hook = alc663_m51va_inithook,
19073 },
19074 [ALC272_DELL_ZM1] = {
19075 .mixers = { alc663_m51va_mixer },
19076 .cap_mixer = alc662_auto_capture_mixer,
19077 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
19078 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19079 .dac_nids = alc662_dac_nids,
19080 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19081 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019082 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020019083 .capsrc_nids = alc662_capsrc_nids,
19084 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019085 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019086 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019087 .init_hook = alc663_m51va_inithook,
19088 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020019089 [ALC272_SAMSUNG_NC10] = {
19090 .mixers = { alc272_nc10_mixer },
19091 .init_verbs = { alc662_init_verbs,
19092 alc663_21jd_amic_init_verbs },
19093 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19094 .dac_nids = alc272_dac_nids,
19095 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19096 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019097 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020019098 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019099 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020019100 .init_hook = alc663_mode4_inithook,
19101 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019102};
19103
19104
19105/*
19106 * BIOS auto configuration
19107 */
19108
Takashi Iwai7085ec12009-10-02 09:03:58 +020019109/* convert from MIX nid to DAC */
19110static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19111{
19112 if (nid == 0x0f)
19113 return 0x02;
19114 else if (nid >= 0x0c && nid <= 0x0e)
19115 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019116 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19117 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019118 else
19119 return 0;
19120}
19121
19122/* get MIX nid connected to the given pin targeted to DAC */
19123static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19124 hda_nid_t dac)
19125{
David Henningssoncc1c4522010-11-24 14:17:47 +010019126 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019127 int i, num;
19128
19129 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19130 for (i = 0; i < num; i++) {
19131 if (alc662_mix_to_dac(mix[i]) == dac)
19132 return mix[i];
19133 }
19134 return 0;
19135}
19136
19137/* look for an empty DAC slot */
19138static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19139{
19140 struct alc_spec *spec = codec->spec;
19141 hda_nid_t srcs[5];
19142 int i, j, num;
19143
19144 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19145 if (num < 0)
19146 return 0;
19147 for (i = 0; i < num; i++) {
19148 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19149 if (!nid)
19150 continue;
19151 for (j = 0; j < spec->multiout.num_dacs; j++)
19152 if (spec->multiout.dac_nids[j] == nid)
19153 break;
19154 if (j >= spec->multiout.num_dacs)
19155 return nid;
19156 }
19157 return 0;
19158}
19159
19160/* fill in the dac_nids table from the parsed pin configuration */
19161static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19162 const struct auto_pin_cfg *cfg)
19163{
19164 struct alc_spec *spec = codec->spec;
19165 int i;
19166 hda_nid_t dac;
19167
19168 spec->multiout.dac_nids = spec->private_dac_nids;
19169 for (i = 0; i < cfg->line_outs; i++) {
19170 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19171 if (!dac)
19172 continue;
19173 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19174 }
19175 return 0;
19176}
19177
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019178static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19179 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019180{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019181 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019182 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19183}
19184
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019185static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19186 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019187{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019188 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019189 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19190}
19191
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019192#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19193 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19194#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19195 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019196#define alc662_add_stereo_vol(spec, pfx, nid) \
19197 alc662_add_vol_ctl(spec, pfx, nid, 3)
19198#define alc662_add_stereo_sw(spec, pfx, nid) \
19199 alc662_add_sw_ctl(spec, pfx, nid, 3)
19200
19201/* add playback controls from the parsed DAC table */
19202static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19203 const struct auto_pin_cfg *cfg)
19204{
19205 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019206 static const char *chname[4] = {
19207 "Front", "Surround", NULL /*CLFE*/, "Side"
19208 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019209 const char *pfx = alc_get_line_out_pfx(cfg, true);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019210 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019211 int i, err;
19212
19213 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019214 nid = spec->multiout.dac_nids[i];
19215 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019216 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019217 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19218 if (!mix)
19219 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019220 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019221 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019222 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019223 if (err < 0)
19224 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019225 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019226 if (err < 0)
19227 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019228 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019229 if (err < 0)
19230 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019231 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019232 if (err < 0)
19233 return err;
19234 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019235 const char *name = pfx;
19236 if (!name)
19237 name = chname[i];
19238 err = __alc662_add_vol_ctl(spec, name, nid, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019239 if (err < 0)
19240 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019241 err = __alc662_add_sw_ctl(spec, name, mix, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019242 if (err < 0)
19243 return err;
19244 }
19245 }
19246 return 0;
19247}
19248
19249/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019250/* return DAC nid if any new DAC is assigned */
19251static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019252 const char *pfx)
19253{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019254 struct alc_spec *spec = codec->spec;
19255 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019256 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019257
19258 if (!pin)
19259 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019260 nid = alc662_look_for_dac(codec, pin);
19261 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019262 /* the corresponding DAC is already occupied */
19263 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19264 return 0; /* no way */
19265 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019266 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019267 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19268 }
19269
19270 mix = alc662_dac_to_mix(codec, pin, nid);
19271 if (!mix)
19272 return 0;
19273 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19274 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019275 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019276 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19277 if (err < 0)
19278 return err;
19279 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019280}
19281
19282/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019283#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019284 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019285
19286static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19287 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019288 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019289{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019290 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019291 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019292
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019293 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019294 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019295 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19296 if (num <= 1)
19297 return;
19298 for (i = 0; i < num; i++) {
19299 if (alc662_mix_to_dac(srcs[i]) != dac)
19300 continue;
19301 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19302 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019303 }
19304}
19305
19306static void alc662_auto_init_multi_out(struct hda_codec *codec)
19307{
19308 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019309 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019310 int i;
19311
19312 for (i = 0; i <= HDA_SIDE; i++) {
19313 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19314 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019315 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019316 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019317 }
19318}
19319
19320static void alc662_auto_init_hp_out(struct hda_codec *codec)
19321{
19322 struct alc_spec *spec = codec->spec;
19323 hda_nid_t pin;
19324
19325 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019326 if (pin)
19327 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19328 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019329 pin = spec->autocfg.speaker_pins[0];
19330 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019331 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19332 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019333}
19334
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019335#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19336
19337static void alc662_auto_init_analog_input(struct hda_codec *codec)
19338{
19339 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019340 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019341 int i;
19342
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019343 for (i = 0; i < cfg->num_inputs; i++) {
19344 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019345 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019346 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019347 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019348 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019349 snd_hda_codec_write(codec, nid, 0,
19350 AC_VERB_SET_AMP_GAIN_MUTE,
19351 AMP_OUT_MUTE);
19352 }
19353 }
19354}
19355
Takashi Iwaif511b012008-08-15 16:46:42 +020019356#define alc662_auto_init_input_src alc882_auto_init_input_src
19357
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019358static int alc662_parse_auto_config(struct hda_codec *codec)
19359{
19360 struct alc_spec *spec = codec->spec;
19361 int err;
19362 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19363
19364 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19365 alc662_ignore);
19366 if (err < 0)
19367 return err;
19368 if (!spec->autocfg.line_outs)
19369 return 0; /* can't find valid BIOS pin config */
19370
Takashi Iwai7085ec12009-10-02 09:03:58 +020019371 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019372 if (err < 0)
19373 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019374 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019375 if (err < 0)
19376 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019377 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019378 spec->autocfg.speaker_pins[0],
19379 "Speaker");
19380 if (err < 0)
19381 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019382 if (err)
19383 spec->multiout.extra_out_nid[0] = err;
19384 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019385 "Headphone");
19386 if (err < 0)
19387 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019388 if (err)
19389 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019390 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019391 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019392 return err;
19393
19394 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19395
Takashi Iwai757899a2010-07-30 10:48:14 +020019396 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019397
Takashi Iwai603c4012008-07-30 15:01:44 +020019398 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019399 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019400
19401 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019402 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019403
Kailang Yangcec27c82010-02-04 14:18:18 +010019404 add_verb(spec, alc662_init_verbs);
19405 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019406 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019407 add_verb(spec, alc663_init_verbs);
19408
19409 if (codec->vendor_id == 0x10ec0272)
19410 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019411
19412 err = alc_auto_add_mic_boost(codec);
19413 if (err < 0)
19414 return err;
19415
Kailang Yang6227cdc2010-02-25 08:36:52 +010019416 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19417 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19418 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19419 else
19420 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019421
Takashi Iwai8c872862007-06-19 12:11:16 +020019422 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019423}
19424
19425/* additional initialization for auto-configuration model */
19426static void alc662_auto_init(struct hda_codec *codec)
19427{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019428 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019429 alc662_auto_init_multi_out(codec);
19430 alc662_auto_init_hp_out(codec);
19431 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019432 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019433 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019434 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019435 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019436}
19437
Todd Broch6be79482010-12-07 16:51:05 -080019438static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019439 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019440{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019441 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019442 return;
Todd Broch6be79482010-12-07 16:51:05 -080019443 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19444 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19445 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19446 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19447 (0 << AC_AMPCAP_MUTE_SHIFT)))
19448 printk(KERN_WARNING
19449 "hda_codec: failed to override amp caps for NID 0x2\n");
19450}
19451
David Henningsson6cb3b702010-09-09 08:51:44 +020019452enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019453 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019454 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019455 ALC272_FIXUP_MARIO,
David Henningsson6cb3b702010-09-09 08:51:44 +020019456};
19457
19458static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019459 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019460 .type = ALC_FIXUP_PINS,
19461 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019462 { 0x15, 0x99130112 }, /* subwoofer */
19463 { }
19464 }
19465 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019466 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019467 .type = ALC_FIXUP_PINS,
19468 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019469 { 0x17, 0x99130112 }, /* subwoofer */
19470 { }
19471 }
19472 },
Todd Broch6be79482010-12-07 16:51:05 -080019473 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019474 .type = ALC_FIXUP_FUNC,
19475 .v.func = alc272_fixup_mario,
Todd Broch6be79482010-12-07 16:51:05 -080019476 }
David Henningsson6cb3b702010-09-09 08:51:44 +020019477};
19478
19479static struct snd_pci_quirk alc662_fixup_tbl[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019480 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019481 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019482 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019483 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19484 {}
19485};
19486
Todd Broch6be79482010-12-07 16:51:05 -080019487static const struct alc_model_fixup alc662_fixup_models[] = {
19488 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19489 {}
19490};
David Henningsson6cb3b702010-09-09 08:51:44 +020019491
19492
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019493static int patch_alc662(struct hda_codec *codec)
19494{
19495 struct alc_spec *spec;
19496 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019497 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019498
19499 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19500 if (!spec)
19501 return -ENOMEM;
19502
19503 codec->spec = spec;
19504
Kailang Yangda00c242010-03-19 11:23:45 +010019505 alc_auto_parse_customize_define(codec);
19506
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019507 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19508
Kailang Yang693194f2010-10-21 08:51:48 +020019509 coef = alc_read_coef_idx(codec, 0);
19510 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019511 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019512 else if (coef & (1 << 14) &&
19513 codec->bus->pci->subsystem_vendor == 0x1025 &&
19514 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019515 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019516 else if (coef == 0x4011)
19517 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019518
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019519 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19520 alc662_models,
19521 alc662_cfg_tbl);
19522 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019523 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19524 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019525 board_config = ALC662_AUTO;
19526 }
19527
19528 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019529 alc_pick_fixup(codec, alc662_fixup_models,
19530 alc662_fixup_tbl, alc662_fixups);
19531 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019532 /* automatic parse from the BIOS config */
19533 err = alc662_parse_auto_config(codec);
19534 if (err < 0) {
19535 alc_free(codec);
19536 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020019537 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019538 printk(KERN_INFO
19539 "hda_codec: Cannot set up configuration "
19540 "from BIOS. Using base mode...\n");
19541 board_config = ALC662_3ST_2ch_DIG;
19542 }
19543 }
19544
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019545 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019546 err = snd_hda_attach_beep_device(codec, 0x1);
19547 if (err < 0) {
19548 alc_free(codec);
19549 return err;
19550 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019551 }
19552
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019553 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019554 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019555
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019556 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19557 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19558
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019559 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19560 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19561
Takashi Iwaidd704692009-08-11 08:45:11 +020019562 if (!spec->adc_nids) {
19563 spec->adc_nids = alc662_adc_nids;
19564 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19565 }
19566 if (!spec->capsrc_nids)
19567 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019568
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019569 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019570 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019571
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019572 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019573 switch (codec->vendor_id) {
19574 case 0x10ec0662:
19575 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19576 break;
19577 case 0x10ec0272:
19578 case 0x10ec0663:
19579 case 0x10ec0665:
19580 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19581 break;
19582 case 0x10ec0273:
19583 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19584 break;
19585 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019586 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019587 spec->vmaster_nid = 0x02;
19588
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019589 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19590
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019591 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019592 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019593 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019594
Kailang Yangbf1b0222010-10-21 08:49:56 +020019595 alc_init_jacks(codec);
19596
Takashi Iwaicb53c622007-08-10 17:21:45 +020019597#ifdef CONFIG_SND_HDA_POWER_SAVE
19598 if (!spec->loopback.amplist)
19599 spec->loopback.amplist = alc662_loopbacks;
19600#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019601
19602 return 0;
19603}
19604
Kailang Yang274693f2009-12-03 10:07:50 +010019605static int patch_alc888(struct hda_codec *codec)
19606{
19607 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19608 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019609 if (codec->vendor_id == 0x10ec0887)
19610 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19611 else
19612 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019613 if (!codec->chip_name) {
19614 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019615 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019616 }
19617 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019618 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019619 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019620}
19621
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019622/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019623 * ALC680 support
19624 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019625#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019626#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19627#define alc680_modes alc260_modes
19628
19629static hda_nid_t alc680_dac_nids[3] = {
19630 /* Lout1, Lout2, hp */
19631 0x02, 0x03, 0x04
19632};
19633
19634static hda_nid_t alc680_adc_nids[3] = {
19635 /* ADC0-2 */
19636 /* DMIC, MIC, Line-in*/
19637 0x07, 0x08, 0x09
19638};
19639
Kailang Yangc69aefa2010-08-17 10:39:22 +020019640/*
19641 * Analog capture ADC cgange
19642 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019643static void alc680_rec_autoswitch(struct hda_codec *codec)
19644{
19645 struct alc_spec *spec = codec->spec;
19646 struct auto_pin_cfg *cfg = &spec->autocfg;
19647 int pin_found = 0;
19648 int type_found = AUTO_PIN_LAST;
19649 hda_nid_t nid;
19650 int i;
19651
19652 for (i = 0; i < cfg->num_inputs; i++) {
19653 nid = cfg->inputs[i].pin;
19654 if (!(snd_hda_query_pin_caps(codec, nid) &
19655 AC_PINCAP_PRES_DETECT))
19656 continue;
19657 if (snd_hda_jack_detect(codec, nid)) {
19658 if (cfg->inputs[i].type < type_found) {
19659 type_found = cfg->inputs[i].type;
19660 pin_found = nid;
19661 }
19662 }
19663 }
19664
19665 nid = 0x07;
19666 if (pin_found)
19667 snd_hda_get_connections(codec, pin_found, &nid, 1);
19668
19669 if (nid != spec->cur_adc)
19670 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19671 spec->cur_adc = nid;
19672 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19673 spec->cur_adc_format);
19674}
19675
Kailang Yangc69aefa2010-08-17 10:39:22 +020019676static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19677 struct hda_codec *codec,
19678 unsigned int stream_tag,
19679 unsigned int format,
19680 struct snd_pcm_substream *substream)
19681{
19682 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019683
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019684 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019685 spec->cur_adc_stream_tag = stream_tag;
19686 spec->cur_adc_format = format;
19687
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019688 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019689 return 0;
19690}
19691
19692static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19693 struct hda_codec *codec,
19694 struct snd_pcm_substream *substream)
19695{
19696 snd_hda_codec_cleanup_stream(codec, 0x07);
19697 snd_hda_codec_cleanup_stream(codec, 0x08);
19698 snd_hda_codec_cleanup_stream(codec, 0x09);
19699 return 0;
19700}
19701
19702static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19703 .substreams = 1, /* can be overridden */
19704 .channels_min = 2,
19705 .channels_max = 2,
19706 /* NID is set in alc_build_pcms */
19707 .ops = {
19708 .prepare = alc680_capture_pcm_prepare,
19709 .cleanup = alc680_capture_pcm_cleanup
19710 },
19711};
19712
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019713static struct snd_kcontrol_new alc680_base_mixer[] = {
19714 /* output mixer control */
19715 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19716 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19717 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019719 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19720 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19721 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019722 { }
19723};
19724
Kailang Yangc69aefa2010-08-17 10:39:22 +020019725static struct hda_bind_ctls alc680_bind_cap_vol = {
19726 .ops = &snd_hda_bind_vol,
19727 .values = {
19728 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19729 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19730 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19731 0
19732 },
19733};
19734
19735static struct hda_bind_ctls alc680_bind_cap_switch = {
19736 .ops = &snd_hda_bind_sw,
19737 .values = {
19738 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19739 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19740 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19741 0
19742 },
19743};
19744
19745static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19746 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19747 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019748 { } /* end */
19749};
19750
19751/*
19752 * generic initialization of ADC, input mixers and output mixers
19753 */
19754static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019755 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19756 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19757 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019758
Kailang Yangc69aefa2010-08-17 10:39:22 +020019759 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19762 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19763 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019765
19766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19768 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19769 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19770 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019771
19772 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19773 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019774 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019775
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019776 { }
19777};
19778
Kailang Yangc69aefa2010-08-17 10:39:22 +020019779/* toggle speaker-output according to the hp-jack state */
19780static void alc680_base_setup(struct hda_codec *codec)
19781{
19782 struct alc_spec *spec = codec->spec;
19783
19784 spec->autocfg.hp_pins[0] = 0x16;
19785 spec->autocfg.speaker_pins[0] = 0x14;
19786 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019787 spec->autocfg.num_inputs = 2;
19788 spec->autocfg.inputs[0].pin = 0x18;
19789 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19790 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019791 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019792}
19793
19794static void alc680_unsol_event(struct hda_codec *codec,
19795 unsigned int res)
19796{
19797 if ((res >> 26) == ALC880_HP_EVENT)
19798 alc_automute_amp(codec);
19799 if ((res >> 26) == ALC880_MIC_EVENT)
19800 alc680_rec_autoswitch(codec);
19801}
19802
19803static void alc680_inithook(struct hda_codec *codec)
19804{
19805 alc_automute_amp(codec);
19806 alc680_rec_autoswitch(codec);
19807}
19808
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019809/* create input playback/capture controls for the given pin */
19810static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19811 const char *ctlname, int idx)
19812{
19813 hda_nid_t dac;
19814 int err;
19815
19816 switch (nid) {
19817 case 0x14:
19818 dac = 0x02;
19819 break;
19820 case 0x15:
19821 dac = 0x03;
19822 break;
19823 case 0x16:
19824 dac = 0x04;
19825 break;
19826 default:
19827 return 0;
19828 }
19829 if (spec->multiout.dac_nids[0] != dac &&
19830 spec->multiout.dac_nids[1] != dac) {
19831 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19832 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19833 HDA_OUTPUT));
19834 if (err < 0)
19835 return err;
19836
19837 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19838 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19839
19840 if (err < 0)
19841 return err;
19842 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19843 }
19844
19845 return 0;
19846}
19847
19848/* add playback controls from the parsed DAC table */
19849static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19850 const struct auto_pin_cfg *cfg)
19851{
19852 hda_nid_t nid;
19853 int err;
19854
19855 spec->multiout.dac_nids = spec->private_dac_nids;
19856
19857 nid = cfg->line_out_pins[0];
19858 if (nid) {
19859 const char *name;
19860 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19861 name = "Speaker";
19862 else
19863 name = "Front";
19864 err = alc680_new_analog_output(spec, nid, name, 0);
19865 if (err < 0)
19866 return err;
19867 }
19868
19869 nid = cfg->speaker_pins[0];
19870 if (nid) {
19871 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19872 if (err < 0)
19873 return err;
19874 }
19875 nid = cfg->hp_pins[0];
19876 if (nid) {
19877 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19878 if (err < 0)
19879 return err;
19880 }
19881
19882 return 0;
19883}
19884
19885static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19886 hda_nid_t nid, int pin_type)
19887{
19888 alc_set_pin_output(codec, nid, pin_type);
19889}
19890
19891static void alc680_auto_init_multi_out(struct hda_codec *codec)
19892{
19893 struct alc_spec *spec = codec->spec;
19894 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19895 if (nid) {
19896 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19897 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19898 }
19899}
19900
19901static void alc680_auto_init_hp_out(struct hda_codec *codec)
19902{
19903 struct alc_spec *spec = codec->spec;
19904 hda_nid_t pin;
19905
19906 pin = spec->autocfg.hp_pins[0];
19907 if (pin)
19908 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19909 pin = spec->autocfg.speaker_pins[0];
19910 if (pin)
19911 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19912}
19913
19914/* pcm configuration: identical with ALC880 */
19915#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19916#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19917#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19918#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019919#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019920
19921/*
19922 * BIOS auto configuration
19923 */
19924static int alc680_parse_auto_config(struct hda_codec *codec)
19925{
19926 struct alc_spec *spec = codec->spec;
19927 int err;
19928 static hda_nid_t alc680_ignore[] = { 0 };
19929
19930 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19931 alc680_ignore);
19932 if (err < 0)
19933 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019934
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019935 if (!spec->autocfg.line_outs) {
19936 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19937 spec->multiout.max_channels = 2;
19938 spec->no_analog = 1;
19939 goto dig_only;
19940 }
19941 return 0; /* can't find valid BIOS pin config */
19942 }
19943 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19944 if (err < 0)
19945 return err;
19946
19947 spec->multiout.max_channels = 2;
19948
19949 dig_only:
19950 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019951 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019952 if (spec->kctls.list)
19953 add_mixer(spec, spec->kctls.list);
19954
19955 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019956
19957 err = alc_auto_add_mic_boost(codec);
19958 if (err < 0)
19959 return err;
19960
19961 return 1;
19962}
19963
19964#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19965
19966/* init callback for auto-configuration model -- overriding the default init */
19967static void alc680_auto_init(struct hda_codec *codec)
19968{
19969 struct alc_spec *spec = codec->spec;
19970 alc680_auto_init_multi_out(codec);
19971 alc680_auto_init_hp_out(codec);
19972 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019973 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019974 if (spec->unsol_event)
19975 alc_inithook(codec);
19976}
19977
19978/*
19979 * configuration and preset
19980 */
19981static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019982 [ALC680_BASE] = "base",
19983 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019984};
19985
19986static struct snd_pci_quirk alc680_cfg_tbl[] = {
19987 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19988 {}
19989};
19990
19991static struct alc_config_preset alc680_presets[] = {
19992 [ALC680_BASE] = {
19993 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019994 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019995 .init_verbs = { alc680_init_verbs },
19996 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19997 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019998 .dig_out_nid = ALC680_DIGOUT_NID,
19999 .num_channel_mode = ARRAY_SIZE(alc680_modes),
20000 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020020001 .unsol_event = alc680_unsol_event,
20002 .setup = alc680_base_setup,
20003 .init_hook = alc680_inithook,
20004
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020005 },
20006};
20007
20008static int patch_alc680(struct hda_codec *codec)
20009{
20010 struct alc_spec *spec;
20011 int board_config;
20012 int err;
20013
20014 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
20015 if (spec == NULL)
20016 return -ENOMEM;
20017
20018 codec->spec = spec;
20019
20020 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
20021 alc680_models,
20022 alc680_cfg_tbl);
20023
20024 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
20025 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
20026 codec->chip_name);
20027 board_config = ALC680_AUTO;
20028 }
20029
20030 if (board_config == ALC680_AUTO) {
20031 /* automatic parse from the BIOS config */
20032 err = alc680_parse_auto_config(codec);
20033 if (err < 0) {
20034 alc_free(codec);
20035 return err;
20036 } else if (!err) {
20037 printk(KERN_INFO
20038 "hda_codec: Cannot set up configuration "
20039 "from BIOS. Using base mode...\n");
20040 board_config = ALC680_BASE;
20041 }
20042 }
20043
20044 if (board_config != ALC680_AUTO)
20045 setup_preset(codec, &alc680_presets[board_config]);
20046
20047 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020048 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020049 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020050 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020051
20052 if (!spec->adc_nids) {
20053 spec->adc_nids = alc680_adc_nids;
20054 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20055 }
20056
20057 if (!spec->cap_mixer)
20058 set_capture_mixer(codec);
20059
20060 spec->vmaster_nid = 0x02;
20061
20062 codec->patch_ops = alc_patch_ops;
20063 if (board_config == ALC680_AUTO)
20064 spec->init_hook = alc680_auto_init;
20065
20066 return 0;
20067}
20068
20069/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020070 * patch entries
20071 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020072static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020073 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020074 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020075 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020076 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020077 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020078 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020079 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020080 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020081 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020082 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020083 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20084 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20085 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020086 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020087 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020088 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20089 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020090 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020091 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020092 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020093 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020094 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020095 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020096 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020097 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020098 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020099 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020100 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020101 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020102 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020103 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020104 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020105 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020106 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020107 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020108 {} /* terminator */
20109};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020110
20111MODULE_ALIAS("snd-hda-codec-id:10ec*");
20112
20113MODULE_LICENSE("GPL");
20114MODULE_DESCRIPTION("Realtek HD-audio codec");
20115
20116static struct hda_codec_preset_list realtek_list = {
20117 .preset = snd_hda_preset_realtek,
20118 .owner = THIS_MODULE,
20119};
20120
20121static int __init patch_realtek_init(void)
20122{
20123 return snd_hda_add_codec_preset(&realtek_list);
20124}
20125
20126static void __exit patch_realtek_exit(void)
20127{
20128 snd_hda_delete_codec_preset(&realtek_list);
20129}
20130
20131module_init(patch_realtek_init)
20132module_exit(patch_realtek_exit)