blob: 4261bb8eec1d524b283346ef6effa181134601e8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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;
David Henningssonf0ce2792011-02-28 15:58:07 +01001136 alc_report_jack(codec, nid);
1137 spec->jack_present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001138 }
1139
1140 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1141 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001142 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1143 nid = spec->autocfg.speaker_pins[i];
1144 if (!nid)
1145 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001146 if (pinctl) {
1147 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001148 AC_VERB_SET_PIN_WIDGET_CONTROL,
1149 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001150 } else {
1151 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1152 HDA_AMP_MUTE, mute);
1153 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001154 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001155}
1156
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001157static void alc_automute_pin(struct hda_codec *codec)
1158{
1159 alc_automute_speaker(codec, 1);
1160}
1161
Takashi Iwai6c819492009-08-10 18:47:44 +02001162static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1163 hda_nid_t nid)
1164{
1165 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1166 int i, nums;
1167
1168 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1169 for (i = 0; i < nums; i++)
1170 if (conn[i] == nid)
1171 return i;
1172 return -1;
1173}
1174
Takashi Iwai840b64c2010-07-13 22:49:01 +02001175/* switch the current ADC according to the jack state */
1176static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1177{
1178 struct alc_spec *spec = codec->spec;
1179 unsigned int present;
1180 hda_nid_t new_adc;
1181
1182 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1183 if (present)
1184 spec->cur_adc_idx = 1;
1185 else
1186 spec->cur_adc_idx = 0;
1187 new_adc = spec->adc_nids[spec->cur_adc_idx];
1188 if (spec->cur_adc && spec->cur_adc != new_adc) {
1189 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001190 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001191 spec->cur_adc = new_adc;
1192 snd_hda_codec_setup_stream(codec, new_adc,
1193 spec->cur_adc_stream_tag, 0,
1194 spec->cur_adc_format);
1195 }
1196}
1197
Kailang Yang7fb0d782008-10-15 11:12:35 +02001198static void alc_mic_automute(struct hda_codec *codec)
1199{
1200 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001201 struct alc_mic_route *dead, *alive;
1202 unsigned int present, type;
1203 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001204
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001205 if (!spec->auto_mic)
1206 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001207 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1208 return;
1209 if (snd_BUG_ON(!spec->adc_nids))
1210 return;
1211
Takashi Iwai840b64c2010-07-13 22:49:01 +02001212 if (spec->dual_adc_switch) {
1213 alc_dual_mic_adc_auto_switch(codec);
1214 return;
1215 }
1216
Takashi Iwai6c819492009-08-10 18:47:44 +02001217 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1218
Wu Fengguang864f92b2009-11-18 12:38:02 +08001219 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001220 if (present) {
1221 alive = &spec->ext_mic;
1222 dead = &spec->int_mic;
1223 } else {
1224 alive = &spec->int_mic;
1225 dead = &spec->ext_mic;
1226 }
1227
Takashi Iwai6c819492009-08-10 18:47:44 +02001228 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1229 if (type == AC_WID_AUD_MIX) {
1230 /* Matrix-mixer style (e.g. ALC882) */
1231 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1232 alive->mux_idx,
1233 HDA_AMP_MUTE, 0);
1234 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1235 dead->mux_idx,
1236 HDA_AMP_MUTE, HDA_AMP_MUTE);
1237 } else {
1238 /* MUX style (e.g. ALC880) */
1239 snd_hda_codec_write_cache(codec, cap_nid, 0,
1240 AC_VERB_SET_CONNECT_SEL,
1241 alive->mux_idx);
1242 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001243 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001244
1245 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001246}
1247
Kailang Yangc9b58002007-10-16 14:30:01 +02001248/* unsolicited event for HP jack sensing */
1249static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1250{
1251 if (codec->vendor_id == 0x10ec0880)
1252 res >>= 28;
1253 else
1254 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001255 switch (res) {
1256 case ALC880_HP_EVENT:
1257 alc_automute_pin(codec);
1258 break;
1259 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001260 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001261 break;
1262 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001263}
1264
1265static void alc_inithook(struct hda_codec *codec)
1266{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001267 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001268 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001269}
1270
Kailang Yangf9423e72008-05-27 12:32:25 +02001271/* additional initialization for ALC888 variants */
1272static void alc888_coef_init(struct hda_codec *codec)
1273{
1274 unsigned int tmp;
1275
1276 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1277 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1278 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001279 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001280 /* alc888S-VC */
1281 snd_hda_codec_read(codec, 0x20, 0,
1282 AC_VERB_SET_PROC_COEF, 0x830);
1283 else
1284 /* alc888-VB */
1285 snd_hda_codec_read(codec, 0x20, 0,
1286 AC_VERB_SET_PROC_COEF, 0x3030);
1287}
1288
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001289static void alc889_coef_init(struct hda_codec *codec)
1290{
1291 unsigned int tmp;
1292
1293 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1294 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1295 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1296 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1297}
1298
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001299/* turn on/off EAPD control (only if available) */
1300static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1301{
1302 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1303 return;
1304 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1305 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1306 on ? 2 : 0);
1307}
1308
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001309static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001310{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001311 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001312
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001313 switch (type) {
1314 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001315 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1316 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001317 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001318 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1319 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001320 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001321 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1322 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001323 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001324 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001325 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001326 set_eapd(codec, 0x0f, 1);
1327 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001328 break;
1329 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001330 case 0x10ec0267:
1331 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001332 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001333 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001334 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001335 case 0x10ec0660:
1336 case 0x10ec0662:
1337 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001339 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001340 set_eapd(codec, 0x14, 1);
1341 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001342 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001343 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001344 switch (codec->vendor_id) {
1345 case 0x10ec0260:
1346 snd_hda_codec_write(codec, 0x1a, 0,
1347 AC_VERB_SET_COEF_INDEX, 7);
1348 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1349 AC_VERB_GET_PROC_COEF, 0);
1350 snd_hda_codec_write(codec, 0x1a, 0,
1351 AC_VERB_SET_COEF_INDEX, 7);
1352 snd_hda_codec_write(codec, 0x1a, 0,
1353 AC_VERB_SET_PROC_COEF,
1354 tmp | 0x2010);
1355 break;
1356 case 0x10ec0262:
1357 case 0x10ec0880:
1358 case 0x10ec0882:
1359 case 0x10ec0883:
1360 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001361 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001362 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001363 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001364 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001365 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001366 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001367 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001368#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001369 case 0x10ec0267:
1370 case 0x10ec0268:
1371 snd_hda_codec_write(codec, 0x20, 0,
1372 AC_VERB_SET_COEF_INDEX, 7);
1373 tmp = snd_hda_codec_read(codec, 0x20, 0,
1374 AC_VERB_GET_PROC_COEF, 0);
1375 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001376 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001377 snd_hda_codec_write(codec, 0x20, 0,
1378 AC_VERB_SET_PROC_COEF,
1379 tmp | 0x3000);
1380 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001381#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001382 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001383 break;
1384 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001385}
Kailang Yangea1fb292008-08-26 12:58:38 +02001386
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001387static void alc_init_auto_hp(struct hda_codec *codec)
1388{
1389 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001390 struct auto_pin_cfg *cfg = &spec->autocfg;
1391 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001392
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001393 if (!cfg->hp_pins[0]) {
1394 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001395 return;
1396 }
1397
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001398 if (!cfg->speaker_pins[0]) {
1399 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1400 return;
1401 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1402 sizeof(cfg->speaker_pins));
1403 cfg->speaker_outs = cfg->line_outs;
1404 }
1405
1406 if (!cfg->hp_pins[0]) {
1407 memcpy(cfg->hp_pins, cfg->line_out_pins,
1408 sizeof(cfg->hp_pins));
1409 cfg->hp_outs = cfg->line_outs;
1410 }
1411
1412 for (i = 0; i < cfg->hp_outs; i++) {
1413 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1414 cfg->hp_pins[i]);
1415 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001416 AC_VERB_SET_UNSOLICITED_ENABLE,
1417 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001418 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001419 spec->unsol_event = alc_sku_unsol_event;
1420}
1421
Takashi Iwai6c819492009-08-10 18:47:44 +02001422static void alc_init_auto_mic(struct hda_codec *codec)
1423{
1424 struct alc_spec *spec = codec->spec;
1425 struct auto_pin_cfg *cfg = &spec->autocfg;
1426 hda_nid_t fixed, ext;
1427 int i;
1428
1429 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001430 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001431 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001432 return;
1433
1434 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001435 for (i = 0; i < cfg->num_inputs; i++) {
1436 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001437 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001438 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001439 switch (snd_hda_get_input_pin_attr(defcfg)) {
1440 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001441 if (fixed)
1442 return; /* already occupied */
1443 fixed = nid;
1444 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001445 case INPUT_PIN_ATTR_UNUSED:
1446 return; /* invalid entry */
1447 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001448 if (ext)
1449 return; /* already occupied */
1450 ext = nid;
1451 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001452 }
1453 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001454 if (!ext || !fixed)
1455 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001456 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1457 return; /* no unsol support */
1458 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1459 ext, fixed);
1460 spec->ext_mic.pin = ext;
1461 spec->int_mic.pin = fixed;
1462 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1463 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1464 spec->auto_mic = 1;
1465 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1466 AC_VERB_SET_UNSOLICITED_ENABLE,
1467 AC_USRSP_EN | ALC880_MIC_EVENT);
1468 spec->unsol_event = alc_sku_unsol_event;
1469}
1470
David Henningsson90622912010-10-14 14:50:18 +02001471/* Could be any non-zero and even value. When used as fixup, tells
1472 * the driver to ignore any present sku defines.
1473 */
1474#define ALC_FIXUP_SKU_IGNORE (2)
1475
Kailang Yangda00c242010-03-19 11:23:45 +01001476static int alc_auto_parse_customize_define(struct hda_codec *codec)
1477{
1478 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001479 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001480 struct alc_spec *spec = codec->spec;
1481
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001482 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1483
David Henningsson90622912010-10-14 14:50:18 +02001484 if (spec->cdefine.fixup) {
1485 ass = spec->cdefine.sku_cfg;
1486 if (ass == ALC_FIXUP_SKU_IGNORE)
1487 return -1;
1488 goto do_sku;
1489 }
1490
Kailang Yangda00c242010-03-19 11:23:45 +01001491 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001492 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001493 goto do_sku;
1494
1495 nid = 0x1d;
1496 if (codec->vendor_id == 0x10ec0260)
1497 nid = 0x17;
1498 ass = snd_hda_codec_get_pincfg(codec, nid);
1499
1500 if (!(ass & 1)) {
1501 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1502 codec->chip_name, ass);
1503 return -1;
1504 }
1505
1506 /* check sum */
1507 tmp = 0;
1508 for (i = 1; i < 16; i++) {
1509 if ((ass >> i) & 1)
1510 tmp++;
1511 }
1512 if (((ass >> 16) & 0xf) != tmp)
1513 return -1;
1514
1515 spec->cdefine.port_connectivity = ass >> 30;
1516 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1517 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1518 spec->cdefine.customization = ass >> 8;
1519do_sku:
1520 spec->cdefine.sku_cfg = ass;
1521 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1522 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1523 spec->cdefine.swap = (ass & 0x2) >> 1;
1524 spec->cdefine.override = ass & 0x1;
1525
1526 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1527 nid, spec->cdefine.sku_cfg);
1528 snd_printd("SKU: port_connectivity=0x%x\n",
1529 spec->cdefine.port_connectivity);
1530 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1531 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1532 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1533 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1534 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1535 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1536 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1537
1538 return 0;
1539}
1540
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001541/* check subsystem ID and set up device-specific initialization;
1542 * return 1 if initialized, 0 if invalid SSID
1543 */
1544/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1545 * 31 ~ 16 : Manufacture ID
1546 * 15 ~ 8 : SKU ID
1547 * 7 ~ 0 : Assembly ID
1548 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1549 */
1550static int alc_subsystem_id(struct hda_codec *codec,
1551 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001552 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001553{
1554 unsigned int ass, tmp, i;
1555 unsigned nid;
1556 struct alc_spec *spec = codec->spec;
1557
David Henningsson90622912010-10-14 14:50:18 +02001558 if (spec->cdefine.fixup) {
1559 ass = spec->cdefine.sku_cfg;
1560 if (ass == ALC_FIXUP_SKU_IGNORE)
1561 return 0;
1562 goto do_sku;
1563 }
1564
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001565 ass = codec->subsystem_id & 0xffff;
1566 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1567 goto do_sku;
1568
1569 /* invalid SSID, check the special NID pin defcfg instead */
1570 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001571 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001572 * 29~21 : reserve
1573 * 20 : PCBEEP input
1574 * 19~16 : Check sum (15:1)
1575 * 15~1 : Custom
1576 * 0 : override
1577 */
1578 nid = 0x1d;
1579 if (codec->vendor_id == 0x10ec0260)
1580 nid = 0x17;
1581 ass = snd_hda_codec_get_pincfg(codec, nid);
1582 snd_printd("realtek: No valid SSID, "
1583 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001584 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001585 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001586 return 0;
1587 if ((ass >> 30) != 1) /* no physical connection */
1588 return 0;
1589
1590 /* check sum */
1591 tmp = 0;
1592 for (i = 1; i < 16; i++) {
1593 if ((ass >> i) & 1)
1594 tmp++;
1595 }
1596 if (((ass >> 16) & 0xf) != tmp)
1597 return 0;
1598do_sku:
1599 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1600 ass & 0xffff, codec->vendor_id);
1601 /*
1602 * 0 : override
1603 * 1 : Swap Jack
1604 * 2 : 0 --> Desktop, 1 --> Laptop
1605 * 3~5 : External Amplifier control
1606 * 7~6 : Reserved
1607 */
1608 tmp = (ass & 0x38) >> 3; /* external Amp control */
1609 switch (tmp) {
1610 case 1:
1611 spec->init_amp = ALC_INIT_GPIO1;
1612 break;
1613 case 3:
1614 spec->init_amp = ALC_INIT_GPIO2;
1615 break;
1616 case 7:
1617 spec->init_amp = ALC_INIT_GPIO3;
1618 break;
1619 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001620 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001621 spec->init_amp = ALC_INIT_DEFAULT;
1622 break;
1623 }
1624
1625 /* is laptop or Desktop and enable the function "Mute internal speaker
1626 * when the external headphone out jack is plugged"
1627 */
1628 if (!(ass & 0x8000))
1629 return 1;
1630 /*
1631 * 10~8 : Jack location
1632 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1633 * 14~13: Resvered
1634 * 15 : 1 --> enable the function "Mute internal speaker
1635 * when the external headphone out jack is plugged"
1636 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001637 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001638 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001639 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1640 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001641 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001642 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001643 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001644 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001645 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001646 else if (tmp == 3)
1647 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001648 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001649 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001650 for (i = 0; i < spec->autocfg.line_outs; i++)
1651 if (spec->autocfg.line_out_pins[i] == nid)
1652 return 1;
1653 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001654 }
1655
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001656 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001657 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001658 return 1;
1659}
Kailang Yangea1fb292008-08-26 12:58:38 +02001660
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001661static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001662 hda_nid_t porta, hda_nid_t porte,
1663 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001664{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001665 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001666 struct alc_spec *spec = codec->spec;
1667 snd_printd("realtek: "
1668 "Enable default setup for auto mode as fallback\n");
1669 spec->init_amp = ALC_INIT_DEFAULT;
1670 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001671 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001672 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001673}
1674
Takashi Iwai41e41f12005-06-08 14:48:49 +02001675/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001676 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001677 */
1678
1679struct alc_pincfg {
1680 hda_nid_t nid;
1681 u32 val;
1682};
1683
Todd Broche1eb5f12010-12-06 11:19:51 -08001684struct alc_model_fixup {
1685 const int id;
1686 const char *name;
1687};
1688
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001689struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001690 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001691 bool chained;
1692 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001693 union {
1694 unsigned int sku;
1695 const struct alc_pincfg *pins;
1696 const struct hda_verb *verbs;
1697 void (*func)(struct hda_codec *codec,
1698 const struct alc_fixup *fix,
1699 int action);
1700 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001701};
1702
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001703enum {
1704 ALC_FIXUP_INVALID,
1705 ALC_FIXUP_SKU,
1706 ALC_FIXUP_PINS,
1707 ALC_FIXUP_VERBS,
1708 ALC_FIXUP_FUNC,
1709};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001710
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001711enum {
1712 ALC_FIXUP_ACT_PRE_PROBE,
1713 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001714 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001715};
1716
1717static void alc_apply_fixup(struct hda_codec *codec, int action)
1718{
1719 struct alc_spec *spec = codec->spec;
1720 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001721#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001722 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001723#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001724 int depth = 0;
1725
1726 if (!spec->fixup_list)
1727 return;
1728
1729 while (id >= 0) {
1730 const struct alc_fixup *fix = spec->fixup_list + id;
1731 const struct alc_pincfg *cfg;
1732
1733 switch (fix->type) {
1734 case ALC_FIXUP_SKU:
1735 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1736 break;;
1737 snd_printdd(KERN_INFO "hda_codec: %s: "
1738 "Apply sku override for %s\n",
1739 codec->chip_name, modelname);
1740 spec->cdefine.sku_cfg = fix->v.sku;
1741 spec->cdefine.fixup = 1;
1742 break;
1743 case ALC_FIXUP_PINS:
1744 cfg = fix->v.pins;
1745 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1746 break;
1747 snd_printdd(KERN_INFO "hda_codec: %s: "
1748 "Apply pincfg for %s\n",
1749 codec->chip_name, modelname);
1750 for (; cfg->nid; cfg++)
1751 snd_hda_codec_set_pincfg(codec, cfg->nid,
1752 cfg->val);
1753 break;
1754 case ALC_FIXUP_VERBS:
1755 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1756 break;
1757 snd_printdd(KERN_INFO "hda_codec: %s: "
1758 "Apply fix-verbs for %s\n",
1759 codec->chip_name, modelname);
1760 add_verb(codec->spec, fix->v.verbs);
1761 break;
1762 case ALC_FIXUP_FUNC:
1763 if (!fix->v.func)
1764 break;
1765 snd_printdd(KERN_INFO "hda_codec: %s: "
1766 "Apply fix-func for %s\n",
1767 codec->chip_name, modelname);
1768 fix->v.func(codec, fix, action);
1769 break;
1770 default:
1771 snd_printk(KERN_ERR "hda_codec: %s: "
1772 "Invalid fixup type %d\n",
1773 codec->chip_name, fix->type);
1774 break;
1775 }
1776 if (!fix[id].chained)
1777 break;
1778 if (++depth > 10)
1779 break;
1780 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001781 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001782}
1783
Todd Broche1eb5f12010-12-06 11:19:51 -08001784static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001785 const struct alc_model_fixup *models,
1786 const struct snd_pci_quirk *quirk,
1787 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001788{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001789 struct alc_spec *spec = codec->spec;
1790 int id = -1;
1791 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001792
Todd Broche1eb5f12010-12-06 11:19:51 -08001793 if (codec->modelname && models) {
1794 while (models->name) {
1795 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001796 id = models->id;
1797 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001798 break;
1799 }
1800 models++;
1801 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001802 }
1803 if (id < 0) {
1804 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1805 if (quirk) {
1806 id = quirk->value;
1807#ifdef CONFIG_SND_DEBUG_VERBOSE
1808 name = quirk->name;
1809#endif
1810 }
1811 }
1812
1813 spec->fixup_id = id;
1814 if (id >= 0) {
1815 spec->fixup_list = fixlist;
1816 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001817 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001818}
1819
Kailang Yang274693f2009-12-03 10:07:50 +01001820static int alc_read_coef_idx(struct hda_codec *codec,
1821 unsigned int coef_idx)
1822{
1823 unsigned int val;
1824 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1825 coef_idx);
1826 val = snd_hda_codec_read(codec, 0x20, 0,
1827 AC_VERB_GET_PROC_COEF, 0);
1828 return val;
1829}
1830
Kailang Yang977ddd62010-09-15 10:02:29 +02001831static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1832 unsigned int coef_val)
1833{
1834 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1835 coef_idx);
1836 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1837 coef_val);
1838}
1839
Takashi Iwai757899a2010-07-30 10:48:14 +02001840/* set right pin controls for digital I/O */
1841static void alc_auto_init_digital(struct hda_codec *codec)
1842{
1843 struct alc_spec *spec = codec->spec;
1844 int i;
1845 hda_nid_t pin;
1846
1847 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1848 pin = spec->autocfg.dig_out_pins[i];
1849 if (pin) {
1850 snd_hda_codec_write(codec, pin, 0,
1851 AC_VERB_SET_PIN_WIDGET_CONTROL,
1852 PIN_OUT);
1853 }
1854 }
1855 pin = spec->autocfg.dig_in_pin;
1856 if (pin)
1857 snd_hda_codec_write(codec, pin, 0,
1858 AC_VERB_SET_PIN_WIDGET_CONTROL,
1859 PIN_IN);
1860}
1861
1862/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1863static void alc_auto_parse_digital(struct hda_codec *codec)
1864{
1865 struct alc_spec *spec = codec->spec;
1866 int i, err;
1867 hda_nid_t dig_nid;
1868
1869 /* support multiple SPDIFs; the secondary is set up as a slave */
1870 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1871 err = snd_hda_get_connections(codec,
1872 spec->autocfg.dig_out_pins[i],
1873 &dig_nid, 1);
1874 if (err < 0)
1875 continue;
1876 if (!i) {
1877 spec->multiout.dig_out_nid = dig_nid;
1878 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1879 } else {
1880 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1881 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1882 break;
1883 spec->slave_dig_outs[i - 1] = dig_nid;
1884 }
1885 }
1886
1887 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001888 dig_nid = codec->start_nid;
1889 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1890 unsigned int wcaps = get_wcaps(codec, dig_nid);
1891 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1892 continue;
1893 if (!(wcaps & AC_WCAP_DIGITAL))
1894 continue;
1895 if (!(wcaps & AC_WCAP_CONN_LIST))
1896 continue;
1897 err = get_connection_index(codec, dig_nid,
1898 spec->autocfg.dig_in_pin);
1899 if (err >= 0) {
1900 spec->dig_in_nid = dig_nid;
1901 break;
1902 }
1903 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001904 }
1905}
1906
Takashi Iwaif95474e2007-07-10 00:47:43 +02001907/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001908 * ALC888
1909 */
1910
1911/*
1912 * 2ch mode
1913 */
1914static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1915/* Mic-in jack as mic in */
1916 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1917 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1918/* Line-in jack as Line in */
1919 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1920 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1921/* Line-Out as Front */
1922 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1923 { } /* end */
1924};
1925
1926/*
1927 * 4ch mode
1928 */
1929static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1930/* Mic-in jack as mic in */
1931 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1932 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1933/* Line-in jack as Surround */
1934 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1935 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1936/* Line-Out as Front */
1937 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1938 { } /* end */
1939};
1940
1941/*
1942 * 6ch mode
1943 */
1944static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1945/* Mic-in jack as CLFE */
1946 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1947 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1948/* Line-in jack as Surround */
1949 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1950 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1951/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1952 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1953 { } /* end */
1954};
1955
1956/*
1957 * 8ch mode
1958 */
1959static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1960/* Mic-in jack as CLFE */
1961 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1962 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1963/* Line-in jack as Surround */
1964 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1965 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1966/* Line-Out as Side */
1967 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1968 { } /* end */
1969};
1970
1971static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1972 { 2, alc888_4ST_ch2_intel_init },
1973 { 4, alc888_4ST_ch4_intel_init },
1974 { 6, alc888_4ST_ch6_intel_init },
1975 { 8, alc888_4ST_ch8_intel_init },
1976};
1977
1978/*
1979 * ALC888 Fujitsu Siemens Amillo xa3530
1980 */
1981
1982static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1983/* Front Mic: set to PIN_IN (empty by default) */
1984 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1985/* Connect Internal HP to Front */
1986 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1987 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1988 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1989/* Connect Bass HP to Front */
1990 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1991 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1992 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1993/* Connect Line-Out side jack (SPDIF) to Side */
1994 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1995 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1997/* Connect Mic jack to CLFE */
1998 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1999 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2000 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
2001/* Connect Line-in jack to Surround */
2002 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2003 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2004 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
2005/* Connect HP out jack to Front */
2006 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2007 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2008 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2009/* Enable unsolicited event for HP jack and Line-out jack */
2010 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2011 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2012 {}
2013};
2014
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002015static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002016{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02002017 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002018}
2019
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002020static void alc_automute_amp_unsol_event(struct hda_codec *codec,
2021 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002022{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002023 if (codec->vendor_id == 0x10ec0880)
2024 res >>= 28;
2025 else
2026 res >>= 26;
2027 if (res == ALC880_HP_EVENT)
2028 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002029}
2030
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002031static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02002032{
2033 struct alc_spec *spec = codec->spec;
2034
2035 spec->autocfg.hp_pins[0] = 0x15;
2036 spec->autocfg.speaker_pins[0] = 0x14;
2037 spec->autocfg.speaker_pins[1] = 0x16;
2038 spec->autocfg.speaker_pins[2] = 0x17;
2039 spec->autocfg.speaker_pins[3] = 0x19;
2040 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02002041}
2042
2043static void alc889_intel_init_hook(struct hda_codec *codec)
2044{
2045 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002046 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02002047}
2048
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002049static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002050{
2051 struct alc_spec *spec = codec->spec;
2052
2053 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
2054 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
2055 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
2056 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002057}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002058
2059/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002060 * ALC888 Acer Aspire 4930G model
2061 */
2062
2063static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
2064/* Front Mic: set to PIN_IN (empty by default) */
2065 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2066/* Unselect Front Mic by default in input mixer 3 */
2067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002068/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002069 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2070/* Connect Internal HP to front */
2071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2072 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2073 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2074/* Connect HP out to front */
2075 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2076 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2077 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002078 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002079 { }
2080};
2081
Hector Martin3b315d72009-06-02 10:54:19 +02002082/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002083 * ALC888 Acer Aspire 6530G model
2084 */
2085
2086static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002087/* Route to built-in subwoofer as well as speakers */
2088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2090 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002092/* Bias voltage on for external mic port */
2093 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002094/* Front Mic: set to PIN_IN (empty by default) */
2095 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2096/* Unselect Front Mic by default in input mixer 3 */
2097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002098/* Enable unsolicited event for HP jack */
2099 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2100/* Enable speaker output */
2101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2102 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002103 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002104/* Enable headphone output */
2105 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2107 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002108 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002109 { }
2110};
2111
2112/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002113 *ALC888 Acer Aspire 7730G model
2114 */
2115
2116static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2117/* Bias voltage on for external mic port */
2118 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2119/* Front Mic: set to PIN_IN (empty by default) */
2120 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2121/* Unselect Front Mic by default in input mixer 3 */
2122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2123/* Enable unsolicited event for HP jack */
2124 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2125/* Enable speaker output */
2126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2127 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2128 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2129/* Enable headphone output */
2130 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2132 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2133 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2134/*Enable internal subwoofer */
2135 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2136 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2137 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2138 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2139 { }
2140};
2141
2142/*
Hector Martin018df412009-06-04 00:13:40 +02002143 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002144 */
2145
Hector Martin018df412009-06-04 00:13:40 +02002146static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002147/* Front Mic: set to PIN_IN (empty by default) */
2148 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2149/* Unselect Front Mic by default in input mixer 3 */
2150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2151/* Enable unsolicited event for HP jack */
2152 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2153/* Connect Internal Front to Front */
2154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2156 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2157/* Connect Internal Rear to Rear */
2158 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2159 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2160 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2161/* Connect Internal CLFE to CLFE */
2162 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2163 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2164 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2165/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002166 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002167 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2168 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2169/* Enable all DACs */
2170/* DAC DISABLE/MUTE 1? */
2171/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2172 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2173 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2174/* DAC DISABLE/MUTE 2? */
2175/* some bit here disables the other DACs. Init=0x4900 */
2176 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2177 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002178/* DMIC fix
2179 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2180 * which makes the stereo useless. However, either the mic or the ALC889
2181 * makes the signal become a difference/sum signal instead of standard
2182 * stereo, which is annoying. So instead we flip this bit which makes the
2183 * codec replicate the sum signal to both channels, turning it into a
2184 * normal mono mic.
2185 */
2186/* DMIC_CONTROL? Init value = 0x0001 */
2187 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2188 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002189 { }
2190};
2191
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002192static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002193 /* Front mic only available on one ADC */
2194 {
2195 .num_items = 4,
2196 .items = {
2197 { "Mic", 0x0 },
2198 { "Line", 0x2 },
2199 { "CD", 0x4 },
2200 { "Front Mic", 0xb },
2201 },
2202 },
2203 {
2204 .num_items = 3,
2205 .items = {
2206 { "Mic", 0x0 },
2207 { "Line", 0x2 },
2208 { "CD", 0x4 },
2209 },
2210 }
2211};
2212
Tony Vroond2fd4b02009-06-21 00:40:10 +01002213static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2214 /* Interal mic only available on one ADC */
2215 {
Tony Vroon684a8842009-06-26 09:27:50 +01002216 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002217 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002218 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002219 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002220 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002221 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002222 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002223 },
2224 },
2225 {
Tony Vroon684a8842009-06-26 09:27:50 +01002226 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002227 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002228 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002229 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002230 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002231 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002232 },
2233 }
2234};
2235
Hector Martin018df412009-06-04 00:13:40 +02002236static struct hda_input_mux alc889_capture_sources[3] = {
2237 /* Digital mic only available on first "ADC" */
2238 {
2239 .num_items = 5,
2240 .items = {
2241 { "Mic", 0x0 },
2242 { "Line", 0x2 },
2243 { "CD", 0x4 },
2244 { "Front Mic", 0xb },
2245 { "Input Mix", 0xa },
2246 },
2247 },
2248 {
2249 .num_items = 4,
2250 .items = {
2251 { "Mic", 0x0 },
2252 { "Line", 0x2 },
2253 { "CD", 0x4 },
2254 { "Input Mix", 0xa },
2255 },
2256 },
2257 {
2258 .num_items = 4,
2259 .items = {
2260 { "Mic", 0x0 },
2261 { "Line", 0x2 },
2262 { "CD", 0x4 },
2263 { "Input Mix", 0xa },
2264 },
2265 }
2266};
2267
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002268static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002269 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2270 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2271 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2272 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2273 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2274 HDA_OUTPUT),
2275 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2276 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2277 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2279 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2280 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2281 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2282 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2283 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002285 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002286 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002287 { } /* end */
2288};
2289
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002290static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2291 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2292 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2293 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2294 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2295 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0f, 2, 0x0,
2296 HDA_OUTPUT),
2297 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0f, 2, 2, HDA_INPUT),
2298 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2299 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
2300 HDA_CODEC_VOLUME("Side Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2301 HDA_BIND_MUTE("Side Playback Switch", 0x0e, 2, HDA_INPUT),
2302 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2303 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2304 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2305 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2307 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2308 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2309 { } /* end */
2310};
2311
2312
Hector Martin556eea92009-12-20 22:51:23 +01002313static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2314 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2315 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2317 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2318 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2319 HDA_OUTPUT),
2320 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2321 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2322 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2323 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2324 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2325 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002326 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002327 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2328 { } /* end */
2329};
2330
2331
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002332static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002333{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002334 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002335
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002336 spec->autocfg.hp_pins[0] = 0x15;
2337 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002338 spec->autocfg.speaker_pins[1] = 0x16;
2339 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002340}
2341
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002342static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002343{
2344 struct alc_spec *spec = codec->spec;
2345
2346 spec->autocfg.hp_pins[0] = 0x15;
2347 spec->autocfg.speaker_pins[0] = 0x14;
2348 spec->autocfg.speaker_pins[1] = 0x16;
2349 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002350}
2351
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002352static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2353{
2354 struct alc_spec *spec = codec->spec;
2355
2356 spec->autocfg.hp_pins[0] = 0x15;
2357 spec->autocfg.speaker_pins[0] = 0x14;
2358 spec->autocfg.speaker_pins[1] = 0x16;
2359 spec->autocfg.speaker_pins[2] = 0x17;
2360}
2361
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002362static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002363{
2364 struct alc_spec *spec = codec->spec;
2365
2366 spec->autocfg.hp_pins[0] = 0x15;
2367 spec->autocfg.speaker_pins[0] = 0x14;
2368 spec->autocfg.speaker_pins[1] = 0x16;
2369 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002370}
2371
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002372/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002373 * ALC880 3-stack model
2374 *
2375 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002376 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2377 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 */
2379
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002380static hda_nid_t alc880_dac_nids[4] = {
2381 /* front, rear, clfe, rear_surr */
2382 0x02, 0x05, 0x04, 0x03
2383};
2384
2385static hda_nid_t alc880_adc_nids[3] = {
2386 /* ADC0-2 */
2387 0x07, 0x08, 0x09,
2388};
2389
2390/* The datasheet says the node 0x07 is connected from inputs,
2391 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002392 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002394static hda_nid_t alc880_adc_nids_alt[2] = {
2395 /* ADC1-2 */
2396 0x08, 0x09,
2397};
2398
2399#define ALC880_DIGOUT_NID 0x06
2400#define ALC880_DIGIN_NID 0x0a
2401
2402static struct hda_input_mux alc880_capture_source = {
2403 .num_items = 4,
2404 .items = {
2405 { "Mic", 0x0 },
2406 { "Front Mic", 0x3 },
2407 { "Line", 0x2 },
2408 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002410};
2411
2412/* channel source setting (2/6 channel selection for 3-stack) */
2413/* 2ch mode */
2414static struct hda_verb alc880_threestack_ch2_init[] = {
2415 /* set line-in to input, mute it */
2416 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2417 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2418 /* set mic-in to input vref 80%, mute it */
2419 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2420 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421 { } /* end */
2422};
2423
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002424/* 6ch mode */
2425static struct hda_verb alc880_threestack_ch6_init[] = {
2426 /* set line-in to output, unmute it */
2427 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2428 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2429 /* set mic-in to output, unmute it */
2430 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2431 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2432 { } /* end */
2433};
2434
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002435static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002436 { 2, alc880_threestack_ch2_init },
2437 { 6, alc880_threestack_ch6_init },
2438};
2439
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002440static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002441 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002442 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002443 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002444 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002445 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2446 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002447 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2448 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2450 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2451 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2452 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2455 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2456 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002458 {
2459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2460 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002461 .info = alc_ch_mode_info,
2462 .get = alc_ch_mode_get,
2463 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002464 },
2465 { } /* end */
2466};
2467
2468/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002469static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2470 struct snd_ctl_elem_info *uinfo)
2471{
2472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2473 struct alc_spec *spec = codec->spec;
2474 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002475
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002476 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002477 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2478 HDA_INPUT);
2479 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002480 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002481 return err;
2482}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002484static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2485 unsigned int size, unsigned int __user *tlv)
2486{
2487 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2488 struct alc_spec *spec = codec->spec;
2489 int err;
2490
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002491 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002492 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2493 HDA_INPUT);
2494 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002495 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002496 return err;
2497}
2498
2499typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2500 struct snd_ctl_elem_value *ucontrol);
2501
2502static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2503 struct snd_ctl_elem_value *ucontrol,
2504 getput_call_t func)
2505{
2506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2507 struct alc_spec *spec = codec->spec;
2508 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2509 int err;
2510
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002511 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002512 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2513 3, 0, HDA_INPUT);
2514 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002515 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002516 return err;
2517}
2518
2519static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2520 struct snd_ctl_elem_value *ucontrol)
2521{
2522 return alc_cap_getput_caller(kcontrol, ucontrol,
2523 snd_hda_mixer_amp_volume_get);
2524}
2525
2526static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2527 struct snd_ctl_elem_value *ucontrol)
2528{
2529 return alc_cap_getput_caller(kcontrol, ucontrol,
2530 snd_hda_mixer_amp_volume_put);
2531}
2532
2533/* capture mixer elements */
2534#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2535
2536static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2537 struct snd_ctl_elem_value *ucontrol)
2538{
2539 return alc_cap_getput_caller(kcontrol, ucontrol,
2540 snd_hda_mixer_amp_switch_get);
2541}
2542
2543static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2544 struct snd_ctl_elem_value *ucontrol)
2545{
2546 return alc_cap_getput_caller(kcontrol, ucontrol,
2547 snd_hda_mixer_amp_switch_put);
2548}
2549
Takashi Iwaia23b6882009-03-23 15:21:36 +01002550#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002551 { \
2552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2553 .name = "Capture Switch", \
2554 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2555 .count = num, \
2556 .info = alc_cap_sw_info, \
2557 .get = alc_cap_sw_get, \
2558 .put = alc_cap_sw_put, \
2559 }, \
2560 { \
2561 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2562 .name = "Capture Volume", \
2563 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2564 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2565 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2566 .count = num, \
2567 .info = alc_cap_vol_info, \
2568 .get = alc_cap_vol_get, \
2569 .put = alc_cap_vol_put, \
2570 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002571 }
2572
2573#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002574 { \
2575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2576 /* .name = "Capture Source", */ \
2577 .name = "Input Source", \
2578 .count = num, \
2579 .info = alc_mux_enum_info, \
2580 .get = alc_mux_enum_get, \
2581 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002582 }
2583
2584#define DEFINE_CAPMIX(num) \
2585static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2586 _DEFINE_CAPMIX(num), \
2587 _DEFINE_CAPSRC(num), \
2588 { } /* end */ \
2589}
2590
2591#define DEFINE_CAPMIX_NOSRC(num) \
2592static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2593 _DEFINE_CAPMIX(num), \
2594 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002595}
2596
2597/* up to three ADCs */
2598DEFINE_CAPMIX(1);
2599DEFINE_CAPMIX(2);
2600DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002601DEFINE_CAPMIX_NOSRC(1);
2602DEFINE_CAPMIX_NOSRC(2);
2603DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002604
2605/*
2606 * ALC880 5-stack model
2607 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002608 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2609 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002610 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2611 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2612 */
2613
2614/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002615static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002616 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002617 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618 { } /* end */
2619};
2620
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002621/* channel source setting (6/8 channel selection for 5-stack) */
2622/* 6ch mode */
2623static struct hda_verb alc880_fivestack_ch6_init[] = {
2624 /* set line-in to input, mute it */
2625 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2626 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002627 { } /* end */
2628};
2629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630/* 8ch mode */
2631static struct hda_verb alc880_fivestack_ch8_init[] = {
2632 /* set line-in to output, unmute it */
2633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2635 { } /* end */
2636};
2637
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002638static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002639 { 6, alc880_fivestack_ch6_init },
2640 { 8, alc880_fivestack_ch8_init },
2641};
2642
2643
2644/*
2645 * ALC880 6-stack model
2646 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002647 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2648 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002649 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2650 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2651 */
2652
2653static hda_nid_t alc880_6st_dac_nids[4] = {
2654 /* front, rear, clfe, rear_surr */
2655 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002656};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002657
2658static struct hda_input_mux alc880_6stack_capture_source = {
2659 .num_items = 4,
2660 .items = {
2661 { "Mic", 0x0 },
2662 { "Front Mic", 0x1 },
2663 { "Line", 0x2 },
2664 { "CD", 0x4 },
2665 },
2666};
2667
2668/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002669static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 { 8, NULL },
2671};
2672
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002673static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002675 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002676 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002677 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002678 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2679 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002680 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2681 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002682 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002683 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2685 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2686 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2687 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2690 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2691 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002692 {
2693 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2694 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002695 .info = alc_ch_mode_info,
2696 .get = alc_ch_mode_get,
2697 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002698 },
2699 { } /* end */
2700};
2701
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702
2703/*
2704 * ALC880 W810 model
2705 *
2706 * W810 has rear IO for:
2707 * Front (DAC 02)
2708 * Surround (DAC 03)
2709 * Center/LFE (DAC 04)
2710 * Digital out (06)
2711 *
2712 * The system also has a pair of internal speakers, and a headphone jack.
2713 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002714 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002715 * There is a variable resistor to control the speaker or headphone
2716 * volume. This is a hardware-only device without a software API.
2717 *
2718 * Plugging headphones in will disable the internal speakers. This is
2719 * implemented in hardware, not via the driver using jack sense. In
2720 * a similar fashion, plugging into the rear socket marked "front" will
2721 * disable both the speakers and headphones.
2722 *
2723 * For input, there's a microphone jack, and an "audio in" jack.
2724 * These may not do anything useful with this driver yet, because I
2725 * haven't setup any initialization verbs for these yet...
2726 */
2727
2728static hda_nid_t alc880_w810_dac_nids[3] = {
2729 /* front, rear/surround, clfe */
2730 0x02, 0x03, 0x04
2731};
2732
2733/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002734static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002735 { 6, NULL }
2736};
2737
2738/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002739static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002740 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002741 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002742 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002743 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002744 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2745 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002746 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2747 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002748 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2749 { } /* end */
2750};
2751
2752
2753/*
2754 * Z710V model
2755 *
2756 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002757 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2758 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002759 */
2760
2761static hda_nid_t alc880_z71v_dac_nids[1] = {
2762 0x02
2763};
2764#define ALC880_Z71V_HP_DAC 0x03
2765
2766/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002767static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002768 { 2, NULL }
2769};
2770
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002771static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002773 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002774 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002775 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2777 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2780 { } /* end */
2781};
2782
2783
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002784/*
2785 * ALC880 F1734 model
2786 *
2787 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2788 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2789 */
2790
2791static hda_nid_t alc880_f1734_dac_nids[1] = {
2792 0x03
2793};
2794#define ALC880_F1734_HP_DAC 0x02
2795
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002796static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002797 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002798 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002799 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2800 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2802 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002805 { } /* end */
2806};
2807
Takashi Iwai937b4162008-02-11 14:52:36 +01002808static struct hda_input_mux alc880_f1734_capture_source = {
2809 .num_items = 2,
2810 .items = {
2811 { "Mic", 0x1 },
2812 { "CD", 0x4 },
2813 },
2814};
2815
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002816
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002817/*
2818 * ALC880 ASUS model
2819 *
2820 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2821 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2822 * Mic = 0x18, Line = 0x1a
2823 */
2824
2825#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2826#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2827
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002828static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002829 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002830 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002831 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002832 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002833 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2834 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002835 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2836 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002837 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2838 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2839 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2840 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002843 {
2844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2845 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002846 .info = alc_ch_mode_info,
2847 .get = alc_ch_mode_get,
2848 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002849 },
2850 { } /* end */
2851};
2852
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002853/*
2854 * ALC880 ASUS W1V model
2855 *
2856 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2857 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2858 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2859 */
2860
2861/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002862static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002863 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2864 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002865 { } /* end */
2866};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002867
Kailang Yangdf694da2005-12-05 19:42:22 +01002868/* TCL S700 */
2869static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2870 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2871 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2872 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2873 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2874 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2877 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2878 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002879 { } /* end */
2880};
2881
Kailang Yangccc656c2006-10-17 12:32:26 +02002882/* Uniwill */
2883static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002884 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2885 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2886 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2887 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002888 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2889 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2890 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2891 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2892 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2893 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2897 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2898 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2899 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002900 {
2901 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2902 .name = "Channel Mode",
2903 .info = alc_ch_mode_info,
2904 .get = alc_ch_mode_get,
2905 .put = alc_ch_mode_put,
2906 },
2907 { } /* end */
2908};
2909
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002910static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2911 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2912 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2913 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2914 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002919 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2920 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002921 { } /* end */
2922};
2923
Kailang Yangccc656c2006-10-17 12:32:26 +02002924static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002925 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2926 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2927 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2928 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2931 { } /* end */
2932};
2933
Linus Torvalds1da177e2005-04-16 15:20:36 -07002934/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002935 * virtual master controls
2936 */
2937
2938/*
2939 * slave controls for virtual master
2940 */
Takashi Iwaiea734962011-01-17 11:29:34 +01002941static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002942 "Front Playback Volume",
2943 "Surround Playback Volume",
2944 "Center Playback Volume",
2945 "LFE Playback Volume",
2946 "Side Playback Volume",
2947 "Headphone Playback Volume",
2948 "Speaker Playback Volume",
2949 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002950 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002951 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002952 NULL,
2953};
2954
Takashi Iwaiea734962011-01-17 11:29:34 +01002955static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002956 "Front Playback Switch",
2957 "Surround Playback Switch",
2958 "Center Playback Switch",
2959 "LFE Playback Switch",
2960 "Side Playback Switch",
2961 "Headphone Playback Switch",
2962 "Speaker Playback Switch",
2963 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002964 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002965 "Line-Out Playback Switch",
2966 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002967 NULL,
2968};
2969
2970/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002971 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002973
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002974#define NID_MAPPING (-1)
2975
2976#define SUBDEV_SPEAKER_ (0 << 6)
2977#define SUBDEV_HP_ (1 << 6)
2978#define SUBDEV_LINE_ (2 << 6)
2979#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2980#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2981#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2982
Takashi Iwai603c4012008-07-30 15:01:44 +02002983static void alc_free_kctls(struct hda_codec *codec);
2984
Takashi Iwai67d634c2009-11-16 15:35:59 +01002985#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002986/* additional beep mixers; the actual parameters are overwritten at build */
2987static struct snd_kcontrol_new alc_beep_mixer[] = {
2988 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002989 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002990 { } /* end */
2991};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002992#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002993
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994static int alc_build_controls(struct hda_codec *codec)
2995{
2996 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002997 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002998 struct snd_kcontrol_new *knew;
2999 int i, j, err;
3000 unsigned int u;
3001 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003002
3003 for (i = 0; i < spec->num_mixers; i++) {
3004 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
3005 if (err < 0)
3006 return err;
3007 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003008 if (spec->cap_mixer) {
3009 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
3010 if (err < 0)
3011 return err;
3012 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003013 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003014 err = snd_hda_create_spdif_out_ctls(codec,
3015 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003016 if (err < 0)
3017 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003018 if (!spec->no_analog) {
3019 err = snd_hda_create_spdif_share_sw(codec,
3020 &spec->multiout);
3021 if (err < 0)
3022 return err;
3023 spec->multiout.share_spdif = 1;
3024 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003025 }
3026 if (spec->dig_in_nid) {
3027 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
3028 if (err < 0)
3029 return err;
3030 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01003031
Takashi Iwai67d634c2009-11-16 15:35:59 +01003032#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003033 /* create beep controls if needed */
3034 if (spec->beep_amp) {
3035 struct snd_kcontrol_new *knew;
3036 for (knew = alc_beep_mixer; knew->name; knew++) {
3037 struct snd_kcontrol *kctl;
3038 kctl = snd_ctl_new1(knew, codec);
3039 if (!kctl)
3040 return -ENOMEM;
3041 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003042 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003043 if (err < 0)
3044 return err;
3045 }
3046 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01003047#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003048
Takashi Iwai2134ea42008-01-10 16:53:55 +01003049 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003050 if (!spec->no_analog &&
3051 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003052 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01003053 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003054 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003055 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003056 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003057 if (err < 0)
3058 return err;
3059 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003060 if (!spec->no_analog &&
3061 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003062 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
3063 NULL, alc_slave_sws);
3064 if (err < 0)
3065 return err;
3066 }
3067
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003068 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02003069 if (spec->capsrc_nids || spec->adc_nids) {
3070 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3071 if (!kctl)
3072 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3073 for (i = 0; kctl && i < kctl->count; i++) {
3074 hda_nid_t *nids = spec->capsrc_nids;
3075 if (!nids)
3076 nids = spec->adc_nids;
3077 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3078 if (err < 0)
3079 return err;
3080 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003081 }
3082 if (spec->cap_mixer) {
3083 const char *kname = kctl ? kctl->id.name : NULL;
3084 for (knew = spec->cap_mixer; knew->name; knew++) {
3085 if (kname && strcmp(knew->name, kname) == 0)
3086 continue;
3087 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3088 for (i = 0; kctl && i < kctl->count; i++) {
3089 err = snd_hda_add_nid(codec, kctl, i,
3090 spec->adc_nids[i]);
3091 if (err < 0)
3092 return err;
3093 }
3094 }
3095 }
3096
3097 /* other nid->control mapping */
3098 for (i = 0; i < spec->num_mixers; i++) {
3099 for (knew = spec->mixers[i]; knew->name; knew++) {
3100 if (knew->iface != NID_MAPPING)
3101 continue;
3102 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3103 if (kctl == NULL)
3104 continue;
3105 u = knew->subdevice;
3106 for (j = 0; j < 4; j++, u >>= 8) {
3107 nid = u & 0x3f;
3108 if (nid == 0)
3109 continue;
3110 switch (u & 0xc0) {
3111 case SUBDEV_SPEAKER_:
3112 nid = spec->autocfg.speaker_pins[nid];
3113 break;
3114 case SUBDEV_LINE_:
3115 nid = spec->autocfg.line_out_pins[nid];
3116 break;
3117 case SUBDEV_HP_:
3118 nid = spec->autocfg.hp_pins[nid];
3119 break;
3120 default:
3121 continue;
3122 }
3123 err = snd_hda_add_nid(codec, kctl, 0, nid);
3124 if (err < 0)
3125 return err;
3126 }
3127 u = knew->private_value;
3128 for (j = 0; j < 4; j++, u >>= 8) {
3129 nid = u & 0xff;
3130 if (nid == 0)
3131 continue;
3132 err = snd_hda_add_nid(codec, kctl, 0, nid);
3133 if (err < 0)
3134 return err;
3135 }
3136 }
3137 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003138
3139 alc_free_kctls(codec); /* no longer needed */
3140
Linus Torvalds1da177e2005-04-16 15:20:36 -07003141 return 0;
3142}
3143
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003144
Linus Torvalds1da177e2005-04-16 15:20:36 -07003145/*
3146 * initialize the codec volumes, etc
3147 */
3148
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003149/*
3150 * generic initialization of ADC, input mixers and output mixers
3151 */
3152static struct hda_verb alc880_volume_init_verbs[] = {
3153 /*
3154 * Unmute ADC0-2 and set the default input to mic-in
3155 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003156 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003158 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003160 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003162
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003163 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3164 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003165 * Note: PASD motherboards uses the Line In 2 as the input for front
3166 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003167 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003168 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3172 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3173 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3174 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3175 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003176
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177 /*
3178 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003179 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003180 /* set vol=0 to output mixers */
3181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3182 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3183 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3184 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3185 /* set up input amps for analog loopback */
3186 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3188 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003189 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3190 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003191 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3192 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003193 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3194 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003195
3196 { }
3197};
3198
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003199/*
3200 * 3-stack pin configuration:
3201 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3202 */
3203static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3204 /*
3205 * preset connection lists of input pins
3206 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3207 */
3208 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3209 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3210 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3211
3212 /*
3213 * Set pin mode and muting
3214 */
3215 /* set front pin widgets 0x14 for output */
3216 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3217 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3218 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3219 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3220 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3221 /* Mic2 (as headphone out) for HP output */
3222 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3224 /* Line In pin widget for input */
3225 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3227 /* Line2 (as front mic) pin widget for input and vref at 80% */
3228 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3229 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3230 /* CD pin widget for input */
3231 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3232
3233 { }
3234};
3235
3236/*
3237 * 5-stack pin configuration:
3238 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3239 * line-in/side = 0x1a, f-mic = 0x1b
3240 */
3241static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3242 /*
3243 * preset connection lists of input pins
3244 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3245 */
3246 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3247 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3248
3249 /*
3250 * Set pin mode and muting
3251 */
3252 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3255 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3256 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 /* unmute pins for output (no gain on this amp) */
3258 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3260 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3261 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3262
Linus Torvalds1da177e2005-04-16 15:20:36 -07003263 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003264 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3266 /* Mic2 (as headphone out) for HP output */
3267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003269 /* Line In pin widget for input */
3270 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3272 /* Line2 (as front mic) pin widget for input and vref at 80% */
3273 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3274 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3275 /* CD pin widget for input */
3276 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003277
3278 { }
3279};
3280
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003281/*
3282 * W810 pin configuration:
3283 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3284 */
3285static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003286 /* hphone/speaker input selector: front DAC */
3287 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3288
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3292 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3293 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3294 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3295
3296 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003297 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003298
Linus Torvalds1da177e2005-04-16 15:20:36 -07003299 { }
3300};
3301
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003302/*
3303 * Z71V pin configuration:
3304 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3305 */
3306static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003307 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003308 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003311
Takashi Iwai16ded522005-06-10 19:58:24 +02003312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003315 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003316
3317 { }
3318};
3319
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320/*
3321 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003322 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3323 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003324 */
3325static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3326 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3327
Takashi Iwai16ded522005-06-10 19:58:24 +02003328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003329 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003330 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003332 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003333 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003334 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003335 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3336
Takashi Iwai16ded522005-06-10 19:58:24 +02003337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003343 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003344 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003345 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003346
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003347 { }
3348};
Takashi Iwai16ded522005-06-10 19:58:24 +02003349
Kailang Yangccc656c2006-10-17 12:32:26 +02003350/*
3351 * Uniwill pin configuration:
3352 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3353 * line = 0x1a
3354 */
3355static struct hda_verb alc880_uniwill_init_verbs[] = {
3356 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3357
3358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3359 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3362 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3363 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3364 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3365 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3368 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3372
3373 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3374 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3375 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3377 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3379 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3380 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3381 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3382
3383 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3384 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3385
3386 { }
3387};
3388
3389/*
3390* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003391* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003392 */
3393static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3394 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3395
3396 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3397 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3398 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3400 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3401 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3405 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3407 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3408
3409 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3410 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3411 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3412 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3413 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3414 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3415
3416 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3417 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3418
3419 { }
3420};
3421
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003422static struct hda_verb alc880_beep_init_verbs[] = {
3423 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3424 { }
3425};
3426
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003427/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003428static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003429{
3430 unsigned int present;
3431 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003432
Wu Fengguang864f92b2009-11-18 12:38:02 +08003433 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003434 bits = present ? HDA_AMP_MUTE : 0;
3435 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003436}
3437
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003438static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003439{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003440 struct alc_spec *spec = codec->spec;
3441
3442 spec->autocfg.hp_pins[0] = 0x14;
3443 spec->autocfg.speaker_pins[0] = 0x15;
3444 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003445}
3446
3447static void alc880_uniwill_init_hook(struct hda_codec *codec)
3448{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003449 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003450 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003451}
3452
3453static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3454 unsigned int res)
3455{
3456 /* Looks like the unsol event is incompatible with the standard
3457 * definition. 4bit tag is placed at 28 bit!
3458 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003459 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003460 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003461 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003462 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003463 default:
3464 alc_automute_amp_unsol_event(codec, res);
3465 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003466 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003467}
3468
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003469static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003470{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003471 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003472
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003473 spec->autocfg.hp_pins[0] = 0x14;
3474 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003475}
3476
3477static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3478{
3479 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003480
Kailang Yangccc656c2006-10-17 12:32:26 +02003481 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003482 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3483 present &= HDA_AMP_VOLMASK;
3484 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3485 HDA_AMP_VOLMASK, present);
3486 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3487 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003488}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003489
Kailang Yangccc656c2006-10-17 12:32:26 +02003490static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3491 unsigned int res)
3492{
3493 /* Looks like the unsol event is incompatible with the standard
3494 * definition. 4bit tag is placed at 28 bit!
3495 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003496 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003497 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003498 else
3499 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003500}
3501
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003502/*
3503 * F1734 pin configuration:
3504 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3505 */
3506static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003507 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003508 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3509 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3510 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3511 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3512
3513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3514 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3516 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3517
3518 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3519 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003520 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003521 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3522 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3523 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3525 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3526 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003527
Takashi Iwai937b4162008-02-11 14:52:36 +01003528 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3529 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3530
Takashi Iwai16ded522005-06-10 19:58:24 +02003531 { }
3532};
3533
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003534/*
3535 * ASUS pin configuration:
3536 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3537 */
3538static struct hda_verb alc880_pin_asus_init_verbs[] = {
3539 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3540 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3541 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3542 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3543
3544 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3545 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3546 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3548 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3549 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3550 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3551 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3552
3553 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3554 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3555 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3556 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3557 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3558 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3561 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003562
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003563 { }
3564};
3565
3566/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003567#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3568#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003569#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570
Kailang Yangdf694da2005-12-05 19:42:22 +01003571/* Clevo m520g init */
3572static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3573 /* headphone output */
3574 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3575 /* line-out */
3576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3578 /* Line-in */
3579 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3580 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3581 /* CD */
3582 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3583 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3584 /* Mic1 (rear panel) */
3585 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3586 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3587 /* Mic2 (front panel) */
3588 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3589 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3590 /* headphone */
3591 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3592 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3593 /* change to EAPD mode */
3594 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3595 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3596
3597 { }
3598};
3599
3600static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003601 /* change to EAPD mode */
3602 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3603 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3604
Kailang Yangdf694da2005-12-05 19:42:22 +01003605 /* Headphone output */
3606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3607 /* Front output*/
3608 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3609 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3610
3611 /* Line In pin widget for input */
3612 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3613 /* CD pin widget for input */
3614 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3615 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3616 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3617
3618 /* change to EAPD mode */
3619 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3620 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3621
3622 { }
3623};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003624
3625/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003626 * LG m1 express dual
3627 *
3628 * Pin assignment:
3629 * Rear Line-In/Out (blue): 0x14
3630 * Build-in Mic-In: 0x15
3631 * Speaker-out: 0x17
3632 * HP-Out (green): 0x1b
3633 * Mic-In/Out (red): 0x19
3634 * SPDIF-Out: 0x1e
3635 */
3636
3637/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3638static hda_nid_t alc880_lg_dac_nids[3] = {
3639 0x05, 0x02, 0x03
3640};
3641
3642/* seems analog CD is not working */
3643static struct hda_input_mux alc880_lg_capture_source = {
3644 .num_items = 3,
3645 .items = {
3646 { "Mic", 0x1 },
3647 { "Line", 0x5 },
3648 { "Internal Mic", 0x6 },
3649 },
3650};
3651
3652/* 2,4,6 channel modes */
3653static struct hda_verb alc880_lg_ch2_init[] = {
3654 /* set line-in and mic-in to input */
3655 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3656 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3657 { }
3658};
3659
3660static struct hda_verb alc880_lg_ch4_init[] = {
3661 /* set line-in to out and mic-in to input */
3662 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3663 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3664 { }
3665};
3666
3667static struct hda_verb alc880_lg_ch6_init[] = {
3668 /* set line-in and mic-in to output */
3669 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3670 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3671 { }
3672};
3673
3674static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3675 { 2, alc880_lg_ch2_init },
3676 { 4, alc880_lg_ch4_init },
3677 { 6, alc880_lg_ch6_init },
3678};
3679
3680static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003681 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3682 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003683 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3684 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3685 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3686 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3687 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3688 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3689 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3690 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3691 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3692 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3693 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3694 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3695 {
3696 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3697 .name = "Channel Mode",
3698 .info = alc_ch_mode_info,
3699 .get = alc_ch_mode_get,
3700 .put = alc_ch_mode_put,
3701 },
3702 { } /* end */
3703};
3704
3705static struct hda_verb alc880_lg_init_verbs[] = {
3706 /* set capture source to mic-in */
3707 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3708 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3709 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3710 /* mute all amp mixer inputs */
3711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003714 /* line-in to input */
3715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3717 /* built-in mic */
3718 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3719 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3720 /* speaker-out */
3721 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3722 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3723 /* mic-in to input */
3724 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3726 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3727 /* HP-out */
3728 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3731 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003732 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003733 { }
3734};
3735
3736/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003737static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003738{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003739 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003740
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003741 spec->autocfg.hp_pins[0] = 0x1b;
3742 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003743}
3744
3745/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003746 * LG LW20
3747 *
3748 * Pin assignment:
3749 * Speaker-out: 0x14
3750 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003751 * Built-in Mic-In: 0x19
3752 * Line-In: 0x1b
3753 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003754 * SPDIF-Out: 0x1e
3755 */
3756
Takashi Iwaid6815182006-03-23 16:06:23 +01003757static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003758 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003759 .items = {
3760 { "Mic", 0x0 },
3761 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003762 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003763 },
3764};
3765
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003766#define alc880_lg_lw_modes alc880_threestack_modes
3767
Takashi Iwaid6815182006-03-23 16:06:23 +01003768static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003769 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3770 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3771 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3772 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3773 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3774 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3775 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3776 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3777 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3778 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3780 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3781 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3782 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003783 {
3784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3785 .name = "Channel Mode",
3786 .info = alc_ch_mode_info,
3787 .get = alc_ch_mode_get,
3788 .put = alc_ch_mode_put,
3789 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003790 { } /* end */
3791};
3792
3793static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003794 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3795 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3796 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3797
Takashi Iwaid6815182006-03-23 16:06:23 +01003798 /* set capture source to mic-in */
3799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3800 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3801 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003802 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003803 /* speaker-out */
3804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3806 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3808 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3809 /* mic-in to input */
3810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3812 /* built-in mic */
3813 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3814 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3815 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003816 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003817 { }
3818};
3819
3820/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003821static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003822{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003823 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003824
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003825 spec->autocfg.hp_pins[0] = 0x1b;
3826 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003827}
3828
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003829static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3830 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3831 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3834 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3835 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3836 { } /* end */
3837};
3838
3839static struct hda_input_mux alc880_medion_rim_capture_source = {
3840 .num_items = 2,
3841 .items = {
3842 { "Mic", 0x0 },
3843 { "Internal Mic", 0x1 },
3844 },
3845};
3846
3847static struct hda_verb alc880_medion_rim_init_verbs[] = {
3848 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3849
3850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3852
3853 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3854 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3856 /* Mic2 (as headphone out) for HP output */
3857 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3859 /* Internal Speaker */
3860 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3861 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3862
3863 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3864 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3865
3866 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3867 { }
3868};
3869
3870/* toggle speaker-output according to the hp-jack state */
3871static void alc880_medion_rim_automute(struct hda_codec *codec)
3872{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003873 struct alc_spec *spec = codec->spec;
3874 alc_automute_amp(codec);
3875 /* toggle EAPD */
3876 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003877 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3878 else
3879 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3880}
3881
3882static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3883 unsigned int res)
3884{
3885 /* Looks like the unsol event is incompatible with the standard
3886 * definition. 4bit tag is placed at 28 bit!
3887 */
3888 if ((res >> 28) == ALC880_HP_EVENT)
3889 alc880_medion_rim_automute(codec);
3890}
3891
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003892static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003893{
3894 struct alc_spec *spec = codec->spec;
3895
3896 spec->autocfg.hp_pins[0] = 0x14;
3897 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003898}
3899
Takashi Iwaicb53c622007-08-10 17:21:45 +02003900#ifdef CONFIG_SND_HDA_POWER_SAVE
3901static struct hda_amp_list alc880_loopbacks[] = {
3902 { 0x0b, HDA_INPUT, 0 },
3903 { 0x0b, HDA_INPUT, 1 },
3904 { 0x0b, HDA_INPUT, 2 },
3905 { 0x0b, HDA_INPUT, 3 },
3906 { 0x0b, HDA_INPUT, 4 },
3907 { } /* end */
3908};
3909
3910static struct hda_amp_list alc880_lg_loopbacks[] = {
3911 { 0x0b, HDA_INPUT, 1 },
3912 { 0x0b, HDA_INPUT, 6 },
3913 { 0x0b, HDA_INPUT, 7 },
3914 { } /* end */
3915};
3916#endif
3917
Takashi Iwaid6815182006-03-23 16:06:23 +01003918/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003919 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003920 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003921
Linus Torvalds1da177e2005-04-16 15:20:36 -07003922static int alc_init(struct hda_codec *codec)
3923{
3924 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003925 unsigned int i;
3926
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003927 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003928 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003929
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003930 for (i = 0; i < spec->num_init_verbs; i++)
3931 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003932
3933 if (spec->init_hook)
3934 spec->init_hook(codec);
3935
Takashi Iwai58701122011-01-13 15:41:45 +01003936 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
3937
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003938 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003939 return 0;
3940}
3941
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003942static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3943{
3944 struct alc_spec *spec = codec->spec;
3945
3946 if (spec->unsol_event)
3947 spec->unsol_event(codec, res);
3948}
3949
Takashi Iwaicb53c622007-08-10 17:21:45 +02003950#ifdef CONFIG_SND_HDA_POWER_SAVE
3951static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3952{
3953 struct alc_spec *spec = codec->spec;
3954 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3955}
3956#endif
3957
Linus Torvalds1da177e2005-04-16 15:20:36 -07003958/*
3959 * Analog playback callbacks
3960 */
3961static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3962 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003963 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003964{
3965 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003966 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3967 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003968}
3969
3970static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3971 struct hda_codec *codec,
3972 unsigned int stream_tag,
3973 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003974 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003975{
3976 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003977 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3978 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003979}
3980
3981static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3982 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003983 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003984{
3985 struct alc_spec *spec = codec->spec;
3986 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3987}
3988
3989/*
3990 * Digital out
3991 */
3992static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3993 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003994 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003995{
3996 struct alc_spec *spec = codec->spec;
3997 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3998}
3999
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004000static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4001 struct hda_codec *codec,
4002 unsigned int stream_tag,
4003 unsigned int format,
4004 struct snd_pcm_substream *substream)
4005{
4006 struct alc_spec *spec = codec->spec;
4007 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
4008 stream_tag, format, substream);
4009}
4010
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004011static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4012 struct hda_codec *codec,
4013 struct snd_pcm_substream *substream)
4014{
4015 struct alc_spec *spec = codec->spec;
4016 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
4017}
4018
Linus Torvalds1da177e2005-04-16 15:20:36 -07004019static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
4020 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004021 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004022{
4023 struct alc_spec *spec = codec->spec;
4024 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
4025}
4026
4027/*
4028 * Analog capture
4029 */
Takashi Iwai63300792008-01-24 15:31:36 +01004030static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004031 struct hda_codec *codec,
4032 unsigned int stream_tag,
4033 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004034 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004035{
4036 struct alc_spec *spec = codec->spec;
4037
Takashi Iwai63300792008-01-24 15:31:36 +01004038 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07004039 stream_tag, 0, format);
4040 return 0;
4041}
4042
Takashi Iwai63300792008-01-24 15:31:36 +01004043static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004044 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004045 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004046{
4047 struct alc_spec *spec = codec->spec;
4048
Takashi Iwai888afa12008-03-18 09:57:50 +01004049 snd_hda_codec_cleanup_stream(codec,
4050 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004051 return 0;
4052}
4053
Takashi Iwai840b64c2010-07-13 22:49:01 +02004054/* analog capture with dynamic dual-adc changes */
4055static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
4056 struct hda_codec *codec,
4057 unsigned int stream_tag,
4058 unsigned int format,
4059 struct snd_pcm_substream *substream)
4060{
4061 struct alc_spec *spec = codec->spec;
4062 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
4063 spec->cur_adc_stream_tag = stream_tag;
4064 spec->cur_adc_format = format;
4065 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
4066 return 0;
4067}
4068
4069static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
4070 struct hda_codec *codec,
4071 struct snd_pcm_substream *substream)
4072{
4073 struct alc_spec *spec = codec->spec;
4074 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4075 spec->cur_adc = 0;
4076 return 0;
4077}
4078
4079static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4080 .substreams = 1,
4081 .channels_min = 2,
4082 .channels_max = 2,
4083 .nid = 0, /* fill later */
4084 .ops = {
4085 .prepare = dualmic_capture_pcm_prepare,
4086 .cleanup = dualmic_capture_pcm_cleanup
4087 },
4088};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004089
4090/*
4091 */
4092static struct hda_pcm_stream alc880_pcm_analog_playback = {
4093 .substreams = 1,
4094 .channels_min = 2,
4095 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004096 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004097 .ops = {
4098 .open = alc880_playback_pcm_open,
4099 .prepare = alc880_playback_pcm_prepare,
4100 .cleanup = alc880_playback_pcm_cleanup
4101 },
4102};
4103
4104static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004105 .substreams = 1,
4106 .channels_min = 2,
4107 .channels_max = 2,
4108 /* NID is set in alc_build_pcms */
4109};
4110
4111static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4112 .substreams = 1,
4113 .channels_min = 2,
4114 .channels_max = 2,
4115 /* NID is set in alc_build_pcms */
4116};
4117
4118static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4119 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004120 .channels_min = 2,
4121 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004122 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004123 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004124 .prepare = alc880_alt_capture_pcm_prepare,
4125 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004126 },
4127};
4128
4129static struct hda_pcm_stream alc880_pcm_digital_playback = {
4130 .substreams = 1,
4131 .channels_min = 2,
4132 .channels_max = 2,
4133 /* NID is set in alc_build_pcms */
4134 .ops = {
4135 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004136 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004137 .prepare = alc880_dig_playback_pcm_prepare,
4138 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004139 },
4140};
4141
4142static struct hda_pcm_stream alc880_pcm_digital_capture = {
4143 .substreams = 1,
4144 .channels_min = 2,
4145 .channels_max = 2,
4146 /* NID is set in alc_build_pcms */
4147};
4148
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004149/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004150static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004151 .substreams = 0,
4152 .channels_min = 0,
4153 .channels_max = 0,
4154};
4155
Linus Torvalds1da177e2005-04-16 15:20:36 -07004156static int alc_build_pcms(struct hda_codec *codec)
4157{
4158 struct alc_spec *spec = codec->spec;
4159 struct hda_pcm *info = spec->pcm_rec;
4160 int i;
4161
4162 codec->num_pcms = 1;
4163 codec->pcm_info = info;
4164
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004165 if (spec->no_analog)
4166 goto skip_analog;
4167
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004168 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4169 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004170 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004171
Takashi Iwai4a471b72005-12-07 13:56:29 +01004172 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004173 if (snd_BUG_ON(!spec->multiout.dac_nids))
4174 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004175 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4176 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4177 }
4178 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004179 if (snd_BUG_ON(!spec->adc_nids))
4180 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004181 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4182 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4183 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004184
Takashi Iwai4a471b72005-12-07 13:56:29 +01004185 if (spec->channel_mode) {
4186 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4187 for (i = 0; i < spec->num_channel_mode; i++) {
4188 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4189 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4190 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004191 }
4192 }
4193
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004194 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004195 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004196 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004197 snprintf(spec->stream_name_digital,
4198 sizeof(spec->stream_name_digital),
4199 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004200 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004201 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004202 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004203 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004204 if (spec->dig_out_type)
4205 info->pcm_type = spec->dig_out_type;
4206 else
4207 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004208 if (spec->multiout.dig_out_nid &&
4209 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004210 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4211 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4212 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004213 if (spec->dig_in_nid &&
4214 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004215 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4216 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4217 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004218 /* FIXME: do we need this for all Realtek codec models? */
4219 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004220 }
4221
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004222 if (spec->no_analog)
4223 return 0;
4224
Takashi Iwaie08a0072006-09-07 17:52:14 +02004225 /* If the use of more than one ADC is requested for the current
4226 * model, configure a second analog capture-only PCM.
4227 */
4228 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004229 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4230 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004231 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004232 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004233 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004234 if (spec->alt_dac_nid) {
4235 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4236 *spec->stream_analog_alt_playback;
4237 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4238 spec->alt_dac_nid;
4239 } else {
4240 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4241 alc_pcm_null_stream;
4242 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4243 }
4244 if (spec->num_adc_nids > 1) {
4245 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4246 *spec->stream_analog_alt_capture;
4247 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4248 spec->adc_nids[1];
4249 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4250 spec->num_adc_nids - 1;
4251 } else {
4252 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4253 alc_pcm_null_stream;
4254 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004255 }
4256 }
4257
Linus Torvalds1da177e2005-04-16 15:20:36 -07004258 return 0;
4259}
4260
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004261static inline void alc_shutup(struct hda_codec *codec)
4262{
4263 snd_hda_shutup_pins(codec);
4264}
4265
Takashi Iwai603c4012008-07-30 15:01:44 +02004266static void alc_free_kctls(struct hda_codec *codec)
4267{
4268 struct alc_spec *spec = codec->spec;
4269
4270 if (spec->kctls.list) {
4271 struct snd_kcontrol_new *kctl = spec->kctls.list;
4272 int i;
4273 for (i = 0; i < spec->kctls.used; i++)
4274 kfree(kctl[i].name);
4275 }
4276 snd_array_free(&spec->kctls);
4277}
4278
Linus Torvalds1da177e2005-04-16 15:20:36 -07004279static void alc_free(struct hda_codec *codec)
4280{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004283 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004284 return;
4285
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004286 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004287 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004289 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004290}
4291
Hector Martinf5de24b2009-12-20 22:51:31 +01004292#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004293static void alc_power_eapd(struct hda_codec *codec)
4294{
4295 /* We currently only handle front, HP */
4296 switch (codec->vendor_id) {
4297 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004298 set_eapd(codec, 0x0f, 0);
4299 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004300 break;
4301 case 0x10ec0262:
4302 case 0x10ec0267:
4303 case 0x10ec0268:
4304 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004305 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004306 case 0x10ec0272:
4307 case 0x10ec0660:
4308 case 0x10ec0662:
4309 case 0x10ec0663:
4310 case 0x10ec0862:
4311 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004312 set_eapd(codec, 0x14, 0);
4313 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004314 break;
4315 }
4316}
4317
Hector Martinf5de24b2009-12-20 22:51:31 +01004318static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4319{
4320 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004321 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004322 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004323 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004324 return 0;
4325}
4326#endif
4327
Takashi Iwaie044c392008-10-27 16:56:24 +01004328#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004329static int alc_resume(struct hda_codec *codec)
4330{
Takashi Iwaie044c392008-10-27 16:56:24 +01004331 codec->patch_ops.init(codec);
4332 snd_hda_codec_resume_amp(codec);
4333 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004334 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004335 return 0;
4336}
Takashi Iwaie044c392008-10-27 16:56:24 +01004337#endif
4338
Linus Torvalds1da177e2005-04-16 15:20:36 -07004339/*
4340 */
4341static struct hda_codec_ops alc_patch_ops = {
4342 .build_controls = alc_build_controls,
4343 .build_pcms = alc_build_pcms,
4344 .init = alc_init,
4345 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004346 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004347#ifdef SND_HDA_NEEDS_RESUME
4348 .resume = alc_resume,
4349#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004350#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004351 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004352 .check_power_status = alc_check_power_status,
4353#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004354 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004355};
4356
Kailang Yangc027ddc2010-03-19 11:33:06 +01004357/* replace the codec chip_name with the given string */
4358static int alc_codec_rename(struct hda_codec *codec, const char *name)
4359{
4360 kfree(codec->chip_name);
4361 codec->chip_name = kstrdup(name, GFP_KERNEL);
4362 if (!codec->chip_name) {
4363 alc_free(codec);
4364 return -ENOMEM;
4365 }
4366 return 0;
4367}
4368
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004369/*
4370 * Test configuration for debugging
4371 *
4372 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4373 * enum controls.
4374 */
4375#ifdef CONFIG_SND_DEBUG
4376static hda_nid_t alc880_test_dac_nids[4] = {
4377 0x02, 0x03, 0x04, 0x05
4378};
4379
4380static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004381 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004382 .items = {
4383 { "In-1", 0x0 },
4384 { "In-2", 0x1 },
4385 { "In-3", 0x2 },
4386 { "In-4", 0x3 },
4387 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004388 { "Front", 0x5 },
4389 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004390 },
4391};
4392
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004393static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004394 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004395 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004396 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004397 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004398};
4399
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004400static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4401 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004402{
4403 static char *texts[] = {
4404 "N/A", "Line Out", "HP Out",
4405 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4406 };
4407 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4408 uinfo->count = 1;
4409 uinfo->value.enumerated.items = 8;
4410 if (uinfo->value.enumerated.item >= 8)
4411 uinfo->value.enumerated.item = 7;
4412 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4413 return 0;
4414}
4415
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004416static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4417 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004418{
4419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4420 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4421 unsigned int pin_ctl, item = 0;
4422
4423 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4424 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4425 if (pin_ctl & AC_PINCTL_OUT_EN) {
4426 if (pin_ctl & AC_PINCTL_HP_EN)
4427 item = 2;
4428 else
4429 item = 1;
4430 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4431 switch (pin_ctl & AC_PINCTL_VREFEN) {
4432 case AC_PINCTL_VREF_HIZ: item = 3; break;
4433 case AC_PINCTL_VREF_50: item = 4; break;
4434 case AC_PINCTL_VREF_GRD: item = 5; break;
4435 case AC_PINCTL_VREF_80: item = 6; break;
4436 case AC_PINCTL_VREF_100: item = 7; break;
4437 }
4438 }
4439 ucontrol->value.enumerated.item[0] = item;
4440 return 0;
4441}
4442
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004443static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4444 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004445{
4446 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4447 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4448 static unsigned int ctls[] = {
4449 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4450 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4451 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4452 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4453 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4454 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4455 };
4456 unsigned int old_ctl, new_ctl;
4457
4458 old_ctl = snd_hda_codec_read(codec, nid, 0,
4459 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4460 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4461 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004462 int val;
4463 snd_hda_codec_write_cache(codec, nid, 0,
4464 AC_VERB_SET_PIN_WIDGET_CONTROL,
4465 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004466 val = ucontrol->value.enumerated.item[0] >= 3 ?
4467 HDA_AMP_MUTE : 0;
4468 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4469 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004470 return 1;
4471 }
4472 return 0;
4473}
4474
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004475static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4476 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004477{
4478 static char *texts[] = {
4479 "Front", "Surround", "CLFE", "Side"
4480 };
4481 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4482 uinfo->count = 1;
4483 uinfo->value.enumerated.items = 4;
4484 if (uinfo->value.enumerated.item >= 4)
4485 uinfo->value.enumerated.item = 3;
4486 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4487 return 0;
4488}
4489
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004490static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4491 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004492{
4493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4494 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4495 unsigned int sel;
4496
4497 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4498 ucontrol->value.enumerated.item[0] = sel & 3;
4499 return 0;
4500}
4501
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004502static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4503 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004504{
4505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4506 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4507 unsigned int sel;
4508
4509 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4510 if (ucontrol->value.enumerated.item[0] != sel) {
4511 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004512 snd_hda_codec_write_cache(codec, nid, 0,
4513 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004514 return 1;
4515 }
4516 return 0;
4517}
4518
4519#define PIN_CTL_TEST(xname,nid) { \
4520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4521 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004522 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004523 .info = alc_test_pin_ctl_info, \
4524 .get = alc_test_pin_ctl_get, \
4525 .put = alc_test_pin_ctl_put, \
4526 .private_value = nid \
4527 }
4528
4529#define PIN_SRC_TEST(xname,nid) { \
4530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4531 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004532 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004533 .info = alc_test_pin_src_info, \
4534 .get = alc_test_pin_src_get, \
4535 .put = alc_test_pin_src_put, \
4536 .private_value = nid \
4537 }
4538
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004539static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4541 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4542 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4543 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004544 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4545 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4546 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4547 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004548 PIN_CTL_TEST("Front Pin Mode", 0x14),
4549 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4550 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4551 PIN_CTL_TEST("Side Pin Mode", 0x17),
4552 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4553 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4554 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4555 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4556 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4557 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4558 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4559 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4560 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4561 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4562 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4563 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4564 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4565 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4566 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4567 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4568 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4569 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004570 {
4571 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4572 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004573 .info = alc_ch_mode_info,
4574 .get = alc_ch_mode_get,
4575 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004576 },
4577 { } /* end */
4578};
4579
4580static struct hda_verb alc880_test_init_verbs[] = {
4581 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4588 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4589 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004590 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4592 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004595 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4598 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4599 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004600 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4603 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4604 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004605 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004606 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4607 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004608 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4609 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4610 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004611 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4613 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4614 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4615 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004616 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004618 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004619 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004620 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004621 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004622 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004623 /* Analog input/passthru */
4624 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4627 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004629 { }
4630};
4631#endif
4632
Linus Torvalds1da177e2005-04-16 15:20:36 -07004633/*
4634 */
4635
Takashi Iwaiea734962011-01-17 11:29:34 +01004636static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004637 [ALC880_3ST] = "3stack",
4638 [ALC880_TCL_S700] = "tcl",
4639 [ALC880_3ST_DIG] = "3stack-digout",
4640 [ALC880_CLEVO] = "clevo",
4641 [ALC880_5ST] = "5stack",
4642 [ALC880_5ST_DIG] = "5stack-digout",
4643 [ALC880_W810] = "w810",
4644 [ALC880_Z71V] = "z71v",
4645 [ALC880_6ST] = "6stack",
4646 [ALC880_6ST_DIG] = "6stack-digout",
4647 [ALC880_ASUS] = "asus",
4648 [ALC880_ASUS_W1V] = "asus-w1v",
4649 [ALC880_ASUS_DIG] = "asus-dig",
4650 [ALC880_ASUS_DIG2] = "asus-dig2",
4651 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004652 [ALC880_UNIWILL_P53] = "uniwill-p53",
4653 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004654 [ALC880_F1734] = "F1734",
4655 [ALC880_LG] = "lg",
4656 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004657 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004658#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004659 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004660#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004661 [ALC880_AUTO] = "auto",
4662};
4663
4664static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004665 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004666 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4667 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4668 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4669 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4670 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4671 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4672 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4673 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004674 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4675 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004676 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4677 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4678 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4679 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4680 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4681 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4682 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4683 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4684 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4685 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004686 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004687 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4688 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4689 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004690 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004691 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004692 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4693 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004694 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4695 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004696 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4697 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4698 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4699 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004700 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4701 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004702 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004703 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004704 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004705 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004706 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4707 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004708 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004709 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004710 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004711 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004712 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004713 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004714 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004715 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004716 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004717 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004718 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004719 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004720 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004721 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4722 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4723 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4724 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004725 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4726 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004727 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004728 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004729 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4730 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004731 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4732 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4733 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004734 /* default Intel */
4735 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004736 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4737 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004738 {}
4739};
4740
Takashi Iwai16ded522005-06-10 19:58:24 +02004741/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004742 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004743 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004744static struct alc_config_preset alc880_presets[] = {
4745 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004746 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004747 .init_verbs = { alc880_volume_init_verbs,
4748 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004749 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004750 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004751 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4752 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004753 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004754 .input_mux = &alc880_capture_source,
4755 },
4756 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004758 .init_verbs = { alc880_volume_init_verbs,
4759 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004760 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004761 .dac_nids = alc880_dac_nids,
4762 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004763 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4764 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004765 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004766 .input_mux = &alc880_capture_source,
4767 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004768 [ALC880_TCL_S700] = {
4769 .mixers = { alc880_tcl_s700_mixer },
4770 .init_verbs = { alc880_volume_init_verbs,
4771 alc880_pin_tcl_S700_init_verbs,
4772 alc880_gpio2_init_verbs },
4773 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4774 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004775 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4776 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004777 .hp_nid = 0x03,
4778 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4779 .channel_mode = alc880_2_jack_modes,
4780 .input_mux = &alc880_capture_source,
4781 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004782 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004783 .mixers = { alc880_three_stack_mixer,
4784 alc880_five_stack_mixer},
4785 .init_verbs = { alc880_volume_init_verbs,
4786 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004787 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4788 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004789 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4790 .channel_mode = alc880_fivestack_modes,
4791 .input_mux = &alc880_capture_source,
4792 },
4793 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004794 .mixers = { alc880_three_stack_mixer,
4795 alc880_five_stack_mixer },
4796 .init_verbs = { alc880_volume_init_verbs,
4797 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004798 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4799 .dac_nids = alc880_dac_nids,
4800 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004801 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4802 .channel_mode = alc880_fivestack_modes,
4803 .input_mux = &alc880_capture_source,
4804 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004805 [ALC880_6ST] = {
4806 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004807 .init_verbs = { alc880_volume_init_verbs,
4808 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004809 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4810 .dac_nids = alc880_6st_dac_nids,
4811 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4812 .channel_mode = alc880_sixstack_modes,
4813 .input_mux = &alc880_6stack_capture_source,
4814 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004815 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004817 .init_verbs = { alc880_volume_init_verbs,
4818 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004819 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4820 .dac_nids = alc880_6st_dac_nids,
4821 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004822 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4823 .channel_mode = alc880_sixstack_modes,
4824 .input_mux = &alc880_6stack_capture_source,
4825 },
4826 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004827 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004828 .init_verbs = { alc880_volume_init_verbs,
4829 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004830 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004831 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4832 .dac_nids = alc880_w810_dac_nids,
4833 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004834 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4835 .channel_mode = alc880_w810_modes,
4836 .input_mux = &alc880_capture_source,
4837 },
4838 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004839 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004840 .init_verbs = { alc880_volume_init_verbs,
4841 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004842 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4843 .dac_nids = alc880_z71v_dac_nids,
4844 .dig_out_nid = ALC880_DIGOUT_NID,
4845 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004846 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4847 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004848 .input_mux = &alc880_capture_source,
4849 },
4850 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004851 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004852 .init_verbs = { alc880_volume_init_verbs,
4853 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4855 .dac_nids = alc880_f1734_dac_nids,
4856 .hp_nid = 0x02,
4857 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4858 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004859 .input_mux = &alc880_f1734_capture_source,
4860 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004861 .setup = alc880_uniwill_p53_setup,
4862 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004863 },
4864 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004865 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004866 .init_verbs = { alc880_volume_init_verbs,
4867 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004868 alc880_gpio1_init_verbs },
4869 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4870 .dac_nids = alc880_asus_dac_nids,
4871 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4872 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004873 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004874 .input_mux = &alc880_capture_source,
4875 },
4876 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004877 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004878 .init_verbs = { alc880_volume_init_verbs,
4879 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004880 alc880_gpio1_init_verbs },
4881 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4882 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004883 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004884 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4885 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004886 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004887 .input_mux = &alc880_capture_source,
4888 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004889 [ALC880_ASUS_DIG2] = {
4890 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004891 .init_verbs = { alc880_volume_init_verbs,
4892 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004893 alc880_gpio2_init_verbs }, /* use GPIO2 */
4894 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4895 .dac_nids = alc880_asus_dac_nids,
4896 .dig_out_nid = ALC880_DIGOUT_NID,
4897 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4898 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004899 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004900 .input_mux = &alc880_capture_source,
4901 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004902 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004903 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004904 .init_verbs = { alc880_volume_init_verbs,
4905 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004906 alc880_gpio1_init_verbs },
4907 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4908 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004909 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004910 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4911 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004912 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004913 .input_mux = &alc880_capture_source,
4914 },
4915 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004916 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004917 .init_verbs = { alc880_volume_init_verbs,
4918 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004919 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4920 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004921 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004922 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4923 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004924 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004925 .input_mux = &alc880_capture_source,
4926 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004927 [ALC880_UNIWILL] = {
4928 .mixers = { alc880_uniwill_mixer },
4929 .init_verbs = { alc880_volume_init_verbs,
4930 alc880_uniwill_init_verbs },
4931 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4932 .dac_nids = alc880_asus_dac_nids,
4933 .dig_out_nid = ALC880_DIGOUT_NID,
4934 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4935 .channel_mode = alc880_threestack_modes,
4936 .need_dac_fix = 1,
4937 .input_mux = &alc880_capture_source,
4938 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004939 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004940 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004941 },
4942 [ALC880_UNIWILL_P53] = {
4943 .mixers = { alc880_uniwill_p53_mixer },
4944 .init_verbs = { alc880_volume_init_verbs,
4945 alc880_uniwill_p53_init_verbs },
4946 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4947 .dac_nids = alc880_asus_dac_nids,
4948 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004949 .channel_mode = alc880_threestack_modes,
4950 .input_mux = &alc880_capture_source,
4951 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004952 .setup = alc880_uniwill_p53_setup,
4953 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004954 },
4955 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004956 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004957 .init_verbs = { alc880_volume_init_verbs,
4958 alc880_uniwill_p53_init_verbs,
4959 alc880_beep_init_verbs },
4960 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4961 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004962 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004963 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4964 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004965 .input_mux = &alc880_capture_source,
4966 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004967 .setup = alc880_uniwill_p53_setup,
4968 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004969 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004970 [ALC880_CLEVO] = {
4971 .mixers = { alc880_three_stack_mixer },
4972 .init_verbs = { alc880_volume_init_verbs,
4973 alc880_pin_clevo_init_verbs },
4974 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4975 .dac_nids = alc880_dac_nids,
4976 .hp_nid = 0x03,
4977 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4978 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004979 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004980 .input_mux = &alc880_capture_source,
4981 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004982 [ALC880_LG] = {
4983 .mixers = { alc880_lg_mixer },
4984 .init_verbs = { alc880_volume_init_verbs,
4985 alc880_lg_init_verbs },
4986 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4987 .dac_nids = alc880_lg_dac_nids,
4988 .dig_out_nid = ALC880_DIGOUT_NID,
4989 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4990 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004991 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004992 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004993 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004994 .setup = alc880_lg_setup,
4995 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004996#ifdef CONFIG_SND_HDA_POWER_SAVE
4997 .loopbacks = alc880_lg_loopbacks,
4998#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004999 },
Takashi Iwaid6815182006-03-23 16:06:23 +01005000 [ALC880_LG_LW] = {
5001 .mixers = { alc880_lg_lw_mixer },
5002 .init_verbs = { alc880_volume_init_verbs,
5003 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005004 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01005005 .dac_nids = alc880_dac_nids,
5006 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005007 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
5008 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01005009 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02005010 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005011 .setup = alc880_lg_lw_setup,
5012 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01005013 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005014 [ALC880_MEDION_RIM] = {
5015 .mixers = { alc880_medion_rim_mixer },
5016 .init_verbs = { alc880_volume_init_verbs,
5017 alc880_medion_rim_init_verbs,
5018 alc_gpio2_init_verbs },
5019 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5020 .dac_nids = alc880_dac_nids,
5021 .dig_out_nid = ALC880_DIGOUT_NID,
5022 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5023 .channel_mode = alc880_2_jack_modes,
5024 .input_mux = &alc880_medion_rim_capture_source,
5025 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005026 .setup = alc880_medion_rim_setup,
5027 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005028 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005029#ifdef CONFIG_SND_DEBUG
5030 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005031 .mixers = { alc880_test_mixer },
5032 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005033 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
5034 .dac_nids = alc880_test_dac_nids,
5035 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005036 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
5037 .channel_mode = alc880_test_modes,
5038 .input_mux = &alc880_test_capture_source,
5039 },
5040#endif
5041};
5042
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005043/*
5044 * Automatic parse of I/O pins from the BIOS configuration
5045 */
5046
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005047enum {
5048 ALC_CTL_WIDGET_VOL,
5049 ALC_CTL_WIDGET_MUTE,
5050 ALC_CTL_BIND_MUTE,
5051};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005052static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
5054 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01005055 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005056};
5057
5058/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005059static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005060 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005061{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005062 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005063
Takashi Iwai603c4012008-07-30 15:01:44 +02005064 snd_array_init(&spec->kctls, sizeof(*knew), 32);
5065 knew = snd_array_new(&spec->kctls);
5066 if (!knew)
5067 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005068 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07005069 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005070 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005071 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005072 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005073 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005074 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005075 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005076 return 0;
5077}
5078
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005079static int add_control_with_pfx(struct alc_spec *spec, int type,
5080 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005081 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005082{
5083 char name[32];
5084 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005085 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005086}
5087
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005088#define add_pb_vol_ctrl(spec, type, pfx, val) \
5089 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5090#define add_pb_sw_ctrl(spec, type, pfx, val) \
5091 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5092#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5093 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5094#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5095 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005097#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5098#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5099#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5100#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005101#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5102#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5103#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5104#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5105#define ALC880_PIN_CD_NID 0x1c
5106
5107/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005108static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5109 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110{
5111 hda_nid_t nid;
5112 int assigned[4];
5113 int i, j;
5114
5115 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005116 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005117
5118 /* check the pins hardwired to audio widget */
5119 for (i = 0; i < cfg->line_outs; i++) {
5120 nid = cfg->line_out_pins[i];
5121 if (alc880_is_fixed_pin(nid)) {
5122 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005123 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005124 assigned[idx] = 1;
5125 }
5126 }
5127 /* left pins can be connect to any audio widget */
5128 for (i = 0; i < cfg->line_outs; i++) {
5129 nid = cfg->line_out_pins[i];
5130 if (alc880_is_fixed_pin(nid))
5131 continue;
5132 /* search for an empty channel */
5133 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005134 if (!assigned[j]) {
5135 spec->multiout.dac_nids[i] =
5136 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005137 assigned[j] = 1;
5138 break;
5139 }
5140 }
5141 }
5142 spec->multiout.num_dacs = cfg->line_outs;
5143 return 0;
5144}
5145
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005146static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg,
5147 bool can_be_master)
5148{
5149 if (!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
5150 return "Master";
5151
5152 switch (cfg->line_out_type) {
5153 case AUTO_PIN_SPEAKER_OUT:
5154 return "Speaker";
5155 case AUTO_PIN_HP_OUT:
5156 return "Headphone";
5157 default:
5158 if (cfg->line_outs == 1)
5159 return "PCM";
5160 break;
5161 }
5162 return NULL;
5163}
5164
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005165/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005166static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5167 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005168{
Takashi Iwaiea734962011-01-17 11:29:34 +01005169 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005170 "Front", "Surround", NULL /*CLFE*/, "Side"
5171 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005172 const char *pfx = alc_get_line_out_pfx(cfg, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005173 hda_nid_t nid;
5174 int i, err;
5175
5176 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005177 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005178 continue;
5179 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005180 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005181 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005182 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5183 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005184 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5185 HDA_OUTPUT));
5186 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005187 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005188 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5189 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005190 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5191 HDA_OUTPUT));
5192 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005193 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005194 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5195 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005196 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5197 HDA_INPUT));
5198 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005199 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005200 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5201 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005202 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5203 HDA_INPUT));
5204 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005205 return err;
5206 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005207 const char *name = pfx;
5208 if (!name)
5209 name = chname[i];
5210 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5211 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005212 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5213 HDA_OUTPUT));
5214 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005215 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005216 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5217 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005218 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5219 HDA_INPUT));
5220 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005221 return err;
5222 }
5223 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005224 return 0;
5225}
5226
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005227/* add playback controls for speaker and HP outputs */
5228static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5229 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005230{
5231 hda_nid_t nid;
5232 int err;
5233
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005234 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005235 return 0;
5236
5237 if (alc880_is_fixed_pin(pin)) {
5238 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005239 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005240 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005241 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005242 else
5243 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005244 /* control HP volume/switch on the output mixer amp */
5245 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005246 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005247 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5248 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005249 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005250 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005251 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5252 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005253 return err;
5254 } else if (alc880_is_multi_pin(pin)) {
5255 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005256 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005257 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005258 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5259 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005260 return err;
5261 }
5262 return 0;
5263}
5264
5265/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005266static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005267 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005268 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005269{
Kailang Yangdf694da2005-12-05 19:42:22 +01005270 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005271
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005272 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005273 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5274 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005275 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005276 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005277 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5278 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005279 return err;
5280 return 0;
5281}
5282
Takashi Iwai05f5f472009-08-25 13:10:18 +02005283static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005284{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005285 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5286 return (pincap & AC_PINCAP_IN) != 0;
5287}
5288
5289/* create playback/capture controls for input pins */
5290static int alc_auto_create_input_ctls(struct hda_codec *codec,
5291 const struct auto_pin_cfg *cfg,
5292 hda_nid_t mixer,
5293 hda_nid_t cap1, hda_nid_t cap2)
5294{
5295 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005296 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005297 int i, err, idx, type_idx = 0;
5298 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005299
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005300 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005301 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005302 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005303
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005304 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005305 if (!alc_is_input_pin(codec, pin))
5306 continue;
5307
David Henningsson5322bf22011-01-05 11:03:56 +01005308 label = hda_get_autocfg_input_label(codec, cfg, i);
5309 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005310 type_idx++;
5311 else
5312 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005313 prev_label = label;
5314
Takashi Iwai05f5f472009-08-25 13:10:18 +02005315 if (mixer) {
5316 idx = get_connection_index(codec, mixer, pin);
5317 if (idx >= 0) {
5318 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005319 label, type_idx,
5320 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005321 if (err < 0)
5322 return err;
5323 }
5324 }
5325
5326 if (!cap1)
5327 continue;
5328 idx = get_connection_index(codec, cap1, pin);
5329 if (idx < 0 && cap2)
5330 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005331 if (idx >= 0)
5332 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005333 }
5334 return 0;
5335}
5336
Takashi Iwai05f5f472009-08-25 13:10:18 +02005337static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5338 const struct auto_pin_cfg *cfg)
5339{
5340 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5341}
5342
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005343static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5344 unsigned int pin_type)
5345{
5346 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5347 pin_type);
5348 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005349 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5350 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005351}
5352
Kailang Yangdf694da2005-12-05 19:42:22 +01005353static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5354 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005355 int dac_idx)
5356{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005357 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005358 /* need the manual connection? */
5359 if (alc880_is_multi_pin(nid)) {
5360 struct alc_spec *spec = codec->spec;
5361 int idx = alc880_multi_pin_idx(nid);
5362 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5363 AC_VERB_SET_CONNECT_SEL,
5364 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5365 }
5366}
5367
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005368static int get_pin_type(int line_out_type)
5369{
5370 if (line_out_type == AUTO_PIN_HP_OUT)
5371 return PIN_HP;
5372 else
5373 return PIN_OUT;
5374}
5375
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005376static void alc880_auto_init_multi_out(struct hda_codec *codec)
5377{
5378 struct alc_spec *spec = codec->spec;
5379 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005380
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005381 for (i = 0; i < spec->autocfg.line_outs; i++) {
5382 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005383 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5384 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005385 }
5386}
5387
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005388static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005389{
5390 struct alc_spec *spec = codec->spec;
5391 hda_nid_t pin;
5392
Takashi Iwai82bc9552006-03-21 11:24:42 +01005393 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005394 if (pin) /* connect to front */
5395 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005396 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005397 if (pin) /* connect to front */
5398 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5399}
5400
5401static void alc880_auto_init_analog_input(struct hda_codec *codec)
5402{
5403 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005404 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005405 int i;
5406
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005407 for (i = 0; i < cfg->num_inputs; i++) {
5408 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005409 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005410 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005411 if (nid != ALC880_PIN_CD_NID &&
5412 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005413 snd_hda_codec_write(codec, nid, 0,
5414 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005415 AMP_OUT_MUTE);
5416 }
5417 }
5418}
5419
Takashi Iwai7f311a42010-04-09 17:32:23 +02005420static void alc880_auto_init_input_src(struct hda_codec *codec)
5421{
5422 struct alc_spec *spec = codec->spec;
5423 int c;
5424
5425 for (c = 0; c < spec->num_adc_nids; c++) {
5426 unsigned int mux_idx;
5427 const struct hda_input_mux *imux;
5428 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5429 imux = &spec->input_mux[mux_idx];
5430 if (!imux->num_items && mux_idx > 0)
5431 imux = &spec->input_mux[0];
5432 if (imux)
5433 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5434 AC_VERB_SET_CONNECT_SEL,
5435 imux->items[0].index);
5436 }
5437}
5438
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005439/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005440/* return 1 if successful, 0 if the proper config is not found,
5441 * or a negative error code
5442 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005443static int alc880_parse_auto_config(struct hda_codec *codec)
5444{
5445 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005446 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005447 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005448
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005449 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5450 alc880_ignore);
5451 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005452 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005453 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005454 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005455
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005456 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5457 if (err < 0)
5458 return err;
5459 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5460 if (err < 0)
5461 return err;
5462 err = alc880_auto_create_extra_out(spec,
5463 spec->autocfg.speaker_pins[0],
5464 "Speaker");
5465 if (err < 0)
5466 return err;
5467 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5468 "Headphone");
5469 if (err < 0)
5470 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005471 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005472 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005473 return err;
5474
5475 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5476
Takashi Iwai757899a2010-07-30 10:48:14 +02005477 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005478
Takashi Iwai603c4012008-07-30 15:01:44 +02005479 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005480 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005481
Takashi Iwaid88897e2008-10-31 15:01:37 +01005482 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005483
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005484 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005485 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005486
Kailang Yang6227cdc2010-02-25 08:36:52 +01005487 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005488
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005489 return 1;
5490}
5491
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005492/* additional initialization for auto-configuration model */
5493static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005494{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005495 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005496 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005497 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005498 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005499 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005500 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005501 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005502 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005503}
5504
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005505/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5506 * one of two digital mic pins, e.g. on ALC272
5507 */
5508static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005509{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005510 struct alc_spec *spec = codec->spec;
5511 int i;
5512
5513 for (i = 0; i < spec->num_adc_nids; i++) {
5514 hda_nid_t cap = spec->capsrc_nids ?
5515 spec->capsrc_nids[i] : spec->adc_nids[i];
5516 int iidx, eidx;
5517
5518 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5519 if (iidx < 0)
5520 continue;
5521 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5522 if (eidx < 0)
5523 continue;
5524 spec->int_mic.mux_idx = iidx;
5525 spec->ext_mic.mux_idx = eidx;
5526 if (spec->capsrc_nids)
5527 spec->capsrc_nids += i;
5528 spec->adc_nids += i;
5529 spec->num_adc_nids = 1;
5530 return;
5531 }
5532 snd_printd(KERN_INFO "hda_codec: %s: "
5533 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5534 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5535 spec->auto_mic = 0; /* disable auto-mic to be sure */
5536}
5537
Takashi Iwai748cce42010-08-04 07:37:39 +02005538/* select or unmute the given capsrc route */
5539static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5540 int idx)
5541{
5542 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5543 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5544 HDA_AMP_MUTE, 0);
5545 } else {
5546 snd_hda_codec_write_cache(codec, cap, 0,
5547 AC_VERB_SET_CONNECT_SEL, idx);
5548 }
5549}
5550
Takashi Iwai840b64c2010-07-13 22:49:01 +02005551/* set the default connection to that pin */
5552static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5553{
5554 struct alc_spec *spec = codec->spec;
5555 int i;
5556
5557 for (i = 0; i < spec->num_adc_nids; i++) {
5558 hda_nid_t cap = spec->capsrc_nids ?
5559 spec->capsrc_nids[i] : spec->adc_nids[i];
5560 int idx;
5561
5562 idx = get_connection_index(codec, cap, pin);
5563 if (idx < 0)
5564 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005565 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005566 return i; /* return the found index */
5567 }
5568 return -1; /* not found */
5569}
5570
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005571/* choose the ADC/MUX containing the input pin and initialize the setup */
5572static void fixup_single_adc(struct hda_codec *codec)
5573{
5574 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005575 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005576 int i;
5577
5578 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005579 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005580 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005581 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005582 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005583 /* use only this ADC */
5584 if (spec->capsrc_nids)
5585 spec->capsrc_nids += i;
5586 spec->adc_nids += i;
5587 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005588 }
5589}
5590
Takashi Iwai840b64c2010-07-13 22:49:01 +02005591/* initialize dual adcs */
5592static void fixup_dual_adc_switch(struct hda_codec *codec)
5593{
5594 struct alc_spec *spec = codec->spec;
5595 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5596 init_capsrc_for_pin(codec, spec->int_mic.pin);
5597}
5598
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005599static void set_capture_mixer(struct hda_codec *codec)
5600{
5601 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005602 static struct snd_kcontrol_new *caps[2][3] = {
5603 { alc_capture_mixer_nosrc1,
5604 alc_capture_mixer_nosrc2,
5605 alc_capture_mixer_nosrc3 },
5606 { alc_capture_mixer1,
5607 alc_capture_mixer2,
5608 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005609 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005610 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005611 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005612 int num_adcs = spec->num_adc_nids;
5613 if (spec->dual_adc_switch)
5614 fixup_dual_adc_switch(codec);
5615 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005616 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005617 else if (spec->input_mux) {
5618 if (spec->input_mux->num_items > 1)
5619 mux = 1;
5620 else if (spec->input_mux->num_items == 1)
5621 fixup_single_adc(codec);
5622 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005623 if (spec->dual_adc_switch)
5624 num_adcs = 1;
5625 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005626 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005627}
5628
Takashi Iwai66946352010-03-29 17:21:45 +02005629/* fill adc_nids (and capsrc_nids) containing all active input pins */
5630static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5631 int num_nids)
5632{
5633 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005634 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005635 int n;
5636 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5637
5638 for (n = 0; n < num_nids; n++) {
5639 hda_nid_t adc, cap;
5640 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5641 int nconns, i, j;
5642
5643 adc = nids[n];
5644 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5645 continue;
5646 cap = adc;
5647 nconns = snd_hda_get_connections(codec, cap, conn,
5648 ARRAY_SIZE(conn));
5649 if (nconns == 1) {
5650 cap = conn[0];
5651 nconns = snd_hda_get_connections(codec, cap, conn,
5652 ARRAY_SIZE(conn));
5653 }
5654 if (nconns <= 0)
5655 continue;
5656 if (!fallback_adc) {
5657 fallback_adc = adc;
5658 fallback_cap = cap;
5659 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005660 for (i = 0; i < cfg->num_inputs; i++) {
5661 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005662 for (j = 0; j < nconns; j++) {
5663 if (conn[j] == nid)
5664 break;
5665 }
5666 if (j >= nconns)
5667 break;
5668 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005669 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005670 int num_adcs = spec->num_adc_nids;
5671 spec->private_adc_nids[num_adcs] = adc;
5672 spec->private_capsrc_nids[num_adcs] = cap;
5673 spec->num_adc_nids++;
5674 spec->adc_nids = spec->private_adc_nids;
5675 if (adc != cap)
5676 spec->capsrc_nids = spec->private_capsrc_nids;
5677 }
5678 }
5679 if (!spec->num_adc_nids) {
5680 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005681 " using fallback 0x%x\n",
5682 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005683 spec->private_adc_nids[0] = fallback_adc;
5684 spec->adc_nids = spec->private_adc_nids;
5685 if (fallback_adc != fallback_cap) {
5686 spec->private_capsrc_nids[0] = fallback_cap;
5687 spec->capsrc_nids = spec->private_adc_nids;
5688 }
5689 }
5690}
5691
Takashi Iwai67d634c2009-11-16 15:35:59 +01005692#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005693#define set_beep_amp(spec, nid, idx, dir) \
5694 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005695
5696static struct snd_pci_quirk beep_white_list[] = {
5697 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005698 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005699 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005700 {}
5701};
5702
5703static inline int has_cdefine_beep(struct hda_codec *codec)
5704{
5705 struct alc_spec *spec = codec->spec;
5706 const struct snd_pci_quirk *q;
5707 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5708 if (q)
5709 return q->value;
5710 return spec->cdefine.enable_pcbeep;
5711}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005712#else
5713#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005714#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005715#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005716
5717/*
5718 * OK, here we have finally the patch for ALC880
5719 */
5720
Linus Torvalds1da177e2005-04-16 15:20:36 -07005721static int patch_alc880(struct hda_codec *codec)
5722{
5723 struct alc_spec *spec;
5724 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005725 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005726
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005727 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005728 if (spec == NULL)
5729 return -ENOMEM;
5730
5731 codec->spec = spec;
5732
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005733 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5734 alc880_models,
5735 alc880_cfg_tbl);
5736 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005737 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5738 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005739 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005740 }
5741
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005742 if (board_config == ALC880_AUTO) {
5743 /* automatic parse from the BIOS config */
5744 err = alc880_parse_auto_config(codec);
5745 if (err < 0) {
5746 alc_free(codec);
5747 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005748 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005749 printk(KERN_INFO
5750 "hda_codec: Cannot set up configuration "
5751 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005752 board_config = ALC880_3ST;
5753 }
5754 }
5755
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005756 err = snd_hda_attach_beep_device(codec, 0x1);
5757 if (err < 0) {
5758 alc_free(codec);
5759 return err;
5760 }
5761
Kailang Yangdf694da2005-12-05 19:42:22 +01005762 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005763 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005764
Linus Torvalds1da177e2005-04-16 15:20:36 -07005765 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5766 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005767 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005768
Linus Torvalds1da177e2005-04-16 15:20:36 -07005769 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5770 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5771
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005772 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005773 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005774 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005775 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005776 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005777 if (wcap != AC_WID_AUD_IN) {
5778 spec->adc_nids = alc880_adc_nids_alt;
5779 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005780 } else {
5781 spec->adc_nids = alc880_adc_nids;
5782 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005783 }
5784 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005785 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005786 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005787
Takashi Iwai2134ea42008-01-10 16:53:55 +01005788 spec->vmaster_nid = 0x0c;
5789
Linus Torvalds1da177e2005-04-16 15:20:36 -07005790 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005791 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005792 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005793#ifdef CONFIG_SND_HDA_POWER_SAVE
5794 if (!spec->loopback.amplist)
5795 spec->loopback.amplist = alc880_loopbacks;
5796#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005797
5798 return 0;
5799}
5800
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005801
Linus Torvalds1da177e2005-04-16 15:20:36 -07005802/*
5803 * ALC260 support
5804 */
5805
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005806static hda_nid_t alc260_dac_nids[1] = {
5807 /* front */
5808 0x02,
5809};
5810
5811static hda_nid_t alc260_adc_nids[1] = {
5812 /* ADC0 */
5813 0x04,
5814};
5815
Kailang Yangdf694da2005-12-05 19:42:22 +01005816static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005817 /* ADC1 */
5818 0x05,
5819};
5820
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005821/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5822 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5823 */
5824static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005825 /* ADC0, ADC1 */
5826 0x04, 0x05
5827};
5828
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005829#define ALC260_DIGOUT_NID 0x03
5830#define ALC260_DIGIN_NID 0x06
5831
5832static struct hda_input_mux alc260_capture_source = {
5833 .num_items = 4,
5834 .items = {
5835 { "Mic", 0x0 },
5836 { "Front Mic", 0x1 },
5837 { "Line", 0x2 },
5838 { "CD", 0x4 },
5839 },
5840};
5841
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005842/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005843 * headphone jack and the internal CD lines since these are the only pins at
5844 * which audio can appear. For flexibility, also allow the option of
5845 * recording the mixer output on the second ADC (ADC0 doesn't have a
5846 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005847 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005848static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5849 {
5850 .num_items = 3,
5851 .items = {
5852 { "Mic/Line", 0x0 },
5853 { "CD", 0x4 },
5854 { "Headphone", 0x2 },
5855 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005856 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005857 {
5858 .num_items = 4,
5859 .items = {
5860 { "Mic/Line", 0x0 },
5861 { "CD", 0x4 },
5862 { "Headphone", 0x2 },
5863 { "Mixer", 0x5 },
5864 },
5865 },
5866
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005867};
5868
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005869/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5870 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005871 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005872static struct hda_input_mux alc260_acer_capture_sources[2] = {
5873 {
5874 .num_items = 4,
5875 .items = {
5876 { "Mic", 0x0 },
5877 { "Line", 0x2 },
5878 { "CD", 0x4 },
5879 { "Headphone", 0x5 },
5880 },
5881 },
5882 {
5883 .num_items = 5,
5884 .items = {
5885 { "Mic", 0x0 },
5886 { "Line", 0x2 },
5887 { "CD", 0x4 },
5888 { "Headphone", 0x6 },
5889 { "Mixer", 0x5 },
5890 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005891 },
5892};
Michael Schwingencc959482009-02-22 18:58:45 +01005893
5894/* Maxdata Favorit 100XS */
5895static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5896 {
5897 .num_items = 2,
5898 .items = {
5899 { "Line/Mic", 0x0 },
5900 { "CD", 0x4 },
5901 },
5902 },
5903 {
5904 .num_items = 3,
5905 .items = {
5906 { "Line/Mic", 0x0 },
5907 { "CD", 0x4 },
5908 { "Mixer", 0x5 },
5909 },
5910 },
5911};
5912
Linus Torvalds1da177e2005-04-16 15:20:36 -07005913/*
5914 * This is just place-holder, so there's something for alc_build_pcms to look
5915 * at when it calculates the maximum number of channels. ALC260 has no mixer
5916 * element which allows changing the channel mode, so the verb list is
5917 * never used.
5918 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005919static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005920 { 2, NULL },
5921};
5922
Kailang Yangdf694da2005-12-05 19:42:22 +01005923
5924/* Mixer combinations
5925 *
5926 * basic: base_output + input + pc_beep + capture
5927 * HP: base_output + input + capture_alt
5928 * HP_3013: hp_3013 + input + capture
5929 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005930 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005931 */
5932
5933static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005934 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005935 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005936 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5937 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5938 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5939 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5940 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005941};
Kailang Yangdf694da2005-12-05 19:42:22 +01005942
5943static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005944 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5945 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5946 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5947 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5949 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5950 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5951 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005952 { } /* end */
5953};
5954
Takashi Iwaibec15c32008-01-28 18:16:30 +01005955/* update HP, line and mono out pins according to the master switch */
5956static void alc260_hp_master_update(struct hda_codec *codec,
5957 hda_nid_t hp, hda_nid_t line,
5958 hda_nid_t mono)
5959{
5960 struct alc_spec *spec = codec->spec;
5961 unsigned int val = spec->master_sw ? PIN_HP : 0;
5962 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005963 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005964 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005965 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005966 val);
5967 /* mono (speaker) depending on the HP jack sense */
5968 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005969 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005970 val);
5971}
5972
5973static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5974 struct snd_ctl_elem_value *ucontrol)
5975{
5976 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5977 struct alc_spec *spec = codec->spec;
5978 *ucontrol->value.integer.value = spec->master_sw;
5979 return 0;
5980}
5981
5982static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5983 struct snd_ctl_elem_value *ucontrol)
5984{
5985 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5986 struct alc_spec *spec = codec->spec;
5987 int val = !!*ucontrol->value.integer.value;
5988 hda_nid_t hp, line, mono;
5989
5990 if (val == spec->master_sw)
5991 return 0;
5992 spec->master_sw = val;
5993 hp = (kcontrol->private_value >> 16) & 0xff;
5994 line = (kcontrol->private_value >> 8) & 0xff;
5995 mono = kcontrol->private_value & 0xff;
5996 alc260_hp_master_update(codec, hp, line, mono);
5997 return 1;
5998}
5999
6000static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
6001 {
6002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6003 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006004 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006005 .info = snd_ctl_boolean_mono_info,
6006 .get = alc260_hp_master_sw_get,
6007 .put = alc260_hp_master_sw_put,
6008 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
6009 },
6010 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6011 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
6012 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6013 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
6014 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
6015 HDA_OUTPUT),
6016 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6017 { } /* end */
6018};
6019
6020static struct hda_verb alc260_hp_unsol_verbs[] = {
6021 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6022 {},
6023};
6024
6025static void alc260_hp_automute(struct hda_codec *codec)
6026{
6027 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006028
Wu Fengguang864f92b2009-11-18 12:38:02 +08006029 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006030 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
6031}
6032
6033static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
6034{
6035 if ((res >> 26) == ALC880_HP_EVENT)
6036 alc260_hp_automute(codec);
6037}
6038
Kailang Yangdf694da2005-12-05 19:42:22 +01006039static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006040 {
6041 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6042 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006043 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006044 .info = snd_ctl_boolean_mono_info,
6045 .get = alc260_hp_master_sw_get,
6046 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006047 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01006048 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006049 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6050 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6051 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
6052 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
6053 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6054 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006055 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6056 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02006057 { } /* end */
6058};
6059
Kailang Yang3f878302008-08-26 13:02:23 +02006060static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
6061 .ops = &snd_hda_bind_vol,
6062 .values = {
6063 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6064 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
6065 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6066 0
6067 },
6068};
6069
6070static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6071 .ops = &snd_hda_bind_sw,
6072 .values = {
6073 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6074 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6075 0
6076 },
6077};
6078
6079static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6080 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6081 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6082 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6083 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6084 { } /* end */
6085};
6086
Takashi Iwaibec15c32008-01-28 18:16:30 +01006087static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6088 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6089 {},
6090};
6091
6092static void alc260_hp_3013_automute(struct hda_codec *codec)
6093{
6094 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006095
Wu Fengguang864f92b2009-11-18 12:38:02 +08006096 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006097 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006098}
6099
6100static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6101 unsigned int res)
6102{
6103 if ((res >> 26) == ALC880_HP_EVENT)
6104 alc260_hp_3013_automute(codec);
6105}
6106
Kailang Yang3f878302008-08-26 13:02:23 +02006107static void alc260_hp_3012_automute(struct hda_codec *codec)
6108{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006109 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006110
Kailang Yang3f878302008-08-26 13:02:23 +02006111 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6112 bits);
6113 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6114 bits);
6115 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6116 bits);
6117}
6118
6119static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6120 unsigned int res)
6121{
6122 if ((res >> 26) == ALC880_HP_EVENT)
6123 alc260_hp_3012_automute(codec);
6124}
6125
6126/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006127 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6128 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006129static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006130 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006131 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006132 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006133 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6134 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6135 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6136 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006137 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006138 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6139 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006140 { } /* end */
6141};
6142
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006143/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6144 * versions of the ALC260 don't act on requests to enable mic bias from NID
6145 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6146 * datasheet doesn't mention this restriction. At this stage it's not clear
6147 * whether this behaviour is intentional or is a hardware bug in chip
6148 * revisions available in early 2006. Therefore for now allow the
6149 * "Headphone Jack Mode" control to span all choices, but if it turns out
6150 * that the lack of mic bias for this NID is intentional we could change the
6151 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6152 *
6153 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6154 * don't appear to make the mic bias available from the "line" jack, even
6155 * though the NID used for this jack (0x14) can supply it. The theory is
6156 * that perhaps Acer have included blocking capacitors between the ALC260
6157 * and the output jack. If this turns out to be the case for all such
6158 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6159 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006160 *
6161 * The C20x Tablet series have a mono internal speaker which is controlled
6162 * via the chip's Mono sum widget and pin complex, so include the necessary
6163 * controls for such models. On models without a "mono speaker" the control
6164 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006165 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006166static struct snd_kcontrol_new alc260_acer_mixer[] = {
6167 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6168 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006169 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006170 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006171 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006172 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006173 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006174 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6175 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6177 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6178 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6179 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6180 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6181 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006182 { } /* end */
6183};
6184
Michael Schwingencc959482009-02-22 18:58:45 +01006185/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6186 */
6187static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6188 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6189 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6190 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6191 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6192 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6193 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6194 { } /* end */
6195};
6196
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006197/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6198 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6199 */
6200static struct snd_kcontrol_new alc260_will_mixer[] = {
6201 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6202 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6204 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6205 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6206 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6207 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6208 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6209 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6210 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006211 { } /* end */
6212};
6213
6214/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6215 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6216 */
6217static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6218 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6219 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6221 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6222 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6223 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6224 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6225 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6226 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6227 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6228 { } /* end */
6229};
6230
Kailang Yangdf694da2005-12-05 19:42:22 +01006231/*
6232 * initialization verbs
6233 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006234static struct hda_verb alc260_init_verbs[] = {
6235 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006236 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006237 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006238 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006239 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006240 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006241 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006242 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006243 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006245 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006246 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006247 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006248 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006249 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006250 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006251 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006252 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6253 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006254 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006255 /* set connection select to line in (default select for this ADC) */
6256 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006257 /* mute capture amp left and right */
6258 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6259 /* set connection select to line in (default select for this ADC) */
6260 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006261 /* set vol=0 Line-Out mixer amp left and right */
6262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6263 /* unmute pin widget amp left and right (no gain on this amp) */
6264 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6265 /* set vol=0 HP mixer amp left and right */
6266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6267 /* unmute pin widget amp left and right (no gain on this amp) */
6268 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6269 /* set vol=0 Mono mixer amp left and right */
6270 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6271 /* unmute pin widget amp left and right (no gain on this amp) */
6272 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6273 /* unmute LINE-2 out pin */
6274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006275 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6276 * Line In 2 = 0x03
6277 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006278 /* mute analog inputs */
6279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6282 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6283 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006284 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006285 /* mute Front out path */
6286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6287 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6288 /* mute Headphone out path */
6289 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6291 /* mute Mono out path */
6292 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6293 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006294 { }
6295};
6296
Takashi Iwai474167d2006-05-17 17:17:43 +02006297#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006298static struct hda_verb alc260_hp_init_verbs[] = {
6299 /* Headphone and output */
6300 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6301 /* mono output */
6302 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6303 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6304 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6305 /* Mic2 (front panel) pin widget for input and vref at 80% */
6306 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6307 /* Line In pin widget for input */
6308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6309 /* Line-2 pin widget for output */
6310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6311 /* CD pin widget for input */
6312 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6313 /* unmute amp left and right */
6314 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6315 /* set connection select to line in (default select for this ADC) */
6316 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6317 /* unmute Line-Out mixer amp left and right (volume = 0) */
6318 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6319 /* mute pin widget amp left and right (no gain on this amp) */
6320 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6321 /* unmute HP mixer amp left and right (volume = 0) */
6322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6323 /* mute pin widget amp left and right (no gain on this amp) */
6324 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006325 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6326 * Line In 2 = 0x03
6327 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006328 /* mute analog inputs */
6329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006334 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6335 /* Unmute Front out path */
6336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6337 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6338 /* Unmute Headphone out path */
6339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6340 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6341 /* Unmute Mono out path */
6342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6343 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6344 { }
6345};
Takashi Iwai474167d2006-05-17 17:17:43 +02006346#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006347
6348static struct hda_verb alc260_hp_3013_init_verbs[] = {
6349 /* Line out and output */
6350 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6351 /* mono output */
6352 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6353 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6354 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6355 /* Mic2 (front panel) pin widget for input and vref at 80% */
6356 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6357 /* Line In pin widget for input */
6358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6359 /* Headphone pin widget for output */
6360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6361 /* CD pin widget for input */
6362 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6363 /* unmute amp left and right */
6364 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6365 /* set connection select to line in (default select for this ADC) */
6366 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6367 /* unmute Line-Out mixer amp left and right (volume = 0) */
6368 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6369 /* mute pin widget amp left and right (no gain on this amp) */
6370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6371 /* unmute HP mixer amp left and right (volume = 0) */
6372 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6373 /* mute pin widget amp left and right (no gain on this amp) */
6374 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006375 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6376 * Line In 2 = 0x03
6377 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006378 /* mute analog inputs */
6379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006384 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6385 /* Unmute Front out path */
6386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6388 /* Unmute Headphone out path */
6389 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6391 /* Unmute Mono out path */
6392 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6393 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6394 { }
6395};
6396
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006397/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006398 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6399 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006400 */
6401static struct hda_verb alc260_fujitsu_init_verbs[] = {
6402 /* Disable all GPIOs */
6403 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6404 /* Internal speaker is connected to headphone pin */
6405 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6406 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006408 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6409 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6410 /* Ensure all other unused pins are disabled and muted. */
6411 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6412 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006413 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006414 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006415 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006416 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006419
Jonathan Woithef7ace402006-02-28 11:46:14 +01006420 /* Disable digital (SPDIF) pins */
6421 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6422 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006423
Kailang Yangea1fb292008-08-26 12:58:38 +02006424 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006425 * when acting as an output.
6426 */
6427 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6428
6429 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006430 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6435 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6436 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6437 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6438 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006439
Jonathan Woithef7ace402006-02-28 11:46:14 +01006440 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6441 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6442 /* Unmute Line1 pin widget output buffer since it starts as an output.
6443 * If the pin mode is changed by the user the pin mode control will
6444 * take care of enabling the pin's input/output buffers as needed.
6445 * Therefore there's no need to enable the input buffer at this
6446 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006447 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006449 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006450 * mixer ctrl)
6451 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006452 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006453
Jonathan Woithef7ace402006-02-28 11:46:14 +01006454 /* Mute capture amp left and right */
6455 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006456 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006457 * in (on mic1 pin)
6458 */
6459 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006460
Jonathan Woithef7ace402006-02-28 11:46:14 +01006461 /* Do the same for the second ADC: mute capture input amp and
6462 * set ADC connection to line in (on mic1 pin)
6463 */
6464 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6465 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006466
Jonathan Woithef7ace402006-02-28 11:46:14 +01006467 /* Mute all inputs to mixer widget (even unconnected ones) */
6468 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6469 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6470 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6471 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6472 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006476
6477 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006478};
6479
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006480/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6481 * similar laptops (adapted from Fujitsu init verbs).
6482 */
6483static struct hda_verb alc260_acer_init_verbs[] = {
6484 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6485 * the headphone jack. Turn this on and rely on the standard mute
6486 * methods whenever the user wants to turn these outputs off.
6487 */
6488 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6489 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6490 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6491 /* Internal speaker/Headphone jack is connected to Line-out pin */
6492 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6493 /* Internal microphone/Mic jack is connected to Mic1 pin */
6494 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6495 /* Line In jack is connected to Line1 pin */
6496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006497 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6498 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006499 /* Ensure all other unused pins are disabled and muted. */
6500 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6501 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006502 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6503 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6506 /* Disable digital (SPDIF) pins */
6507 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6508 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6509
Kailang Yangea1fb292008-08-26 12:58:38 +02006510 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006511 * bus when acting as outputs.
6512 */
6513 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6514 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6515
6516 /* Start with output sum widgets muted and their output gains at min */
6517 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6518 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6519 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6520 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6521 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6522 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6523 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6524 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6525 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6526
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006527 /* Unmute Line-out pin widget amp left and right
6528 * (no equiv mixer ctrl)
6529 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006530 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006531 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6532 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006533 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6534 * inputs. If the pin mode is changed by the user the pin mode control
6535 * will take care of enabling the pin's input/output buffers as needed.
6536 * Therefore there's no need to enable the input buffer at this
6537 * stage.
6538 */
6539 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6541
6542 /* Mute capture amp left and right */
6543 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6544 /* Set ADC connection select to match default mixer setting - mic
6545 * (on mic1 pin)
6546 */
6547 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6548
6549 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006550 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006551 */
6552 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006553 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006554
6555 /* Mute all inputs to mixer widget (even unconnected ones) */
6556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6560 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6561 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6562 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6564
6565 { }
6566};
6567
Michael Schwingencc959482009-02-22 18:58:45 +01006568/* Initialisation sequence for Maxdata Favorit 100XS
6569 * (adapted from Acer init verbs).
6570 */
6571static struct hda_verb alc260_favorit100_init_verbs[] = {
6572 /* GPIO 0 enables the output jack.
6573 * Turn this on and rely on the standard mute
6574 * methods whenever the user wants to turn these outputs off.
6575 */
6576 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6577 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6578 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6579 /* Line/Mic input jack is connected to Mic1 pin */
6580 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6581 /* Ensure all other unused pins are disabled and muted. */
6582 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6583 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6584 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6585 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6586 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6587 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6590 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6592 /* Disable digital (SPDIF) pins */
6593 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6594 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6595
6596 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6597 * bus when acting as outputs.
6598 */
6599 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6600 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6601
6602 /* Start with output sum widgets muted and their output gains at min */
6603 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6606 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6609 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6610 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6612
6613 /* Unmute Line-out pin widget amp left and right
6614 * (no equiv mixer ctrl)
6615 */
6616 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6617 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6618 * inputs. If the pin mode is changed by the user the pin mode control
6619 * will take care of enabling the pin's input/output buffers as needed.
6620 * Therefore there's no need to enable the input buffer at this
6621 * stage.
6622 */
6623 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6624
6625 /* Mute capture amp left and right */
6626 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6627 /* Set ADC connection select to match default mixer setting - mic
6628 * (on mic1 pin)
6629 */
6630 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6631
6632 /* Do similar with the second ADC: mute capture input amp and
6633 * set ADC connection to mic to match ALSA's default state.
6634 */
6635 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6636 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6637
6638 /* Mute all inputs to mixer widget (even unconnected ones) */
6639 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6640 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6647
6648 { }
6649};
6650
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006651static struct hda_verb alc260_will_verbs[] = {
6652 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6653 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6654 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6655 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6656 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6657 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6658 {}
6659};
6660
6661static struct hda_verb alc260_replacer_672v_verbs[] = {
6662 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6663 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6664 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6665
6666 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6667 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6668 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6669
6670 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6671 {}
6672};
6673
6674/* toggle speaker-output according to the hp-jack state */
6675static void alc260_replacer_672v_automute(struct hda_codec *codec)
6676{
6677 unsigned int present;
6678
6679 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006680 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006681 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006682 snd_hda_codec_write_cache(codec, 0x01, 0,
6683 AC_VERB_SET_GPIO_DATA, 1);
6684 snd_hda_codec_write_cache(codec, 0x0f, 0,
6685 AC_VERB_SET_PIN_WIDGET_CONTROL,
6686 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006687 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006688 snd_hda_codec_write_cache(codec, 0x01, 0,
6689 AC_VERB_SET_GPIO_DATA, 0);
6690 snd_hda_codec_write_cache(codec, 0x0f, 0,
6691 AC_VERB_SET_PIN_WIDGET_CONTROL,
6692 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006693 }
6694}
6695
6696static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6697 unsigned int res)
6698{
6699 if ((res >> 26) == ALC880_HP_EVENT)
6700 alc260_replacer_672v_automute(codec);
6701}
6702
Kailang Yang3f878302008-08-26 13:02:23 +02006703static struct hda_verb alc260_hp_dc7600_verbs[] = {
6704 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6705 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6706 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6707 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6708 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6709 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6710 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6711 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6712 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6713 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6714 {}
6715};
6716
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006717/* Test configuration for debugging, modelled after the ALC880 test
6718 * configuration.
6719 */
6720#ifdef CONFIG_SND_DEBUG
6721static hda_nid_t alc260_test_dac_nids[1] = {
6722 0x02,
6723};
6724static hda_nid_t alc260_test_adc_nids[2] = {
6725 0x04, 0x05,
6726};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006727/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006728 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006729 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006730 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006731static struct hda_input_mux alc260_test_capture_sources[2] = {
6732 {
6733 .num_items = 7,
6734 .items = {
6735 { "MIC1 pin", 0x0 },
6736 { "MIC2 pin", 0x1 },
6737 { "LINE1 pin", 0x2 },
6738 { "LINE2 pin", 0x3 },
6739 { "CD pin", 0x4 },
6740 { "LINE-OUT pin", 0x5 },
6741 { "HP-OUT pin", 0x6 },
6742 },
6743 },
6744 {
6745 .num_items = 8,
6746 .items = {
6747 { "MIC1 pin", 0x0 },
6748 { "MIC2 pin", 0x1 },
6749 { "LINE1 pin", 0x2 },
6750 { "LINE2 pin", 0x3 },
6751 { "CD pin", 0x4 },
6752 { "Mixer", 0x5 },
6753 { "LINE-OUT pin", 0x6 },
6754 { "HP-OUT pin", 0x7 },
6755 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006756 },
6757};
6758static struct snd_kcontrol_new alc260_test_mixer[] = {
6759 /* Output driver widgets */
6760 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6761 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6762 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6763 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6764 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6765 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6766
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006767 /* Modes for retasking pin widgets
6768 * Note: the ALC260 doesn't seem to act on requests to enable mic
6769 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6770 * mention this restriction. At this stage it's not clear whether
6771 * this behaviour is intentional or is a hardware bug in chip
6772 * revisions available at least up until early 2006. Therefore for
6773 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6774 * choices, but if it turns out that the lack of mic bias for these
6775 * NIDs is intentional we could change their modes from
6776 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6777 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006778 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6779 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6780 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6781 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6782 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6783 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6784
6785 /* Loopback mixer controls */
6786 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6787 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6788 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6789 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6790 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6791 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6792 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6793 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6794 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6795 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006796 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6797 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6798 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6799 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006800
6801 /* Controls for GPIO pins, assuming they are configured as outputs */
6802 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6803 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6804 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6805 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6806
Jonathan Woithe92621f12006-02-28 11:47:47 +01006807 /* Switches to allow the digital IO pins to be enabled. The datasheet
6808 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006809 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006810 */
6811 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6812 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6813
Jonathan Woithef8225f62008-01-08 12:16:54 +01006814 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6815 * this output to turn on an external amplifier.
6816 */
6817 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6818 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6819
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006820 { } /* end */
6821};
6822static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006823 /* Enable all GPIOs as outputs with an initial value of 0 */
6824 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6825 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6826 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6827
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006828 /* Enable retasking pins as output, initially without power amp */
6829 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6830 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6832 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6833 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6834 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6835
Jonathan Woithe92621f12006-02-28 11:47:47 +01006836 /* Disable digital (SPDIF) pins initially, but users can enable
6837 * them via a mixer switch. In the case of SPDIF-out, this initverb
6838 * payload also sets the generation to 0, output to be in "consumer"
6839 * PCM format, copyright asserted, no pre-emphasis and no validity
6840 * control.
6841 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006842 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6843 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6844
Kailang Yangea1fb292008-08-26 12:58:38 +02006845 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006846 * OUT1 sum bus when acting as an output.
6847 */
6848 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6849 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6850 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6851 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6852
6853 /* Start with output sum widgets muted and their output gains at min */
6854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6855 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6860 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6861 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6862 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6863
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006864 /* Unmute retasking pin widget output buffers since the default
6865 * state appears to be output. As the pin mode is changed by the
6866 * user the pin mode control will take care of enabling the pin's
6867 * input/output buffers as needed.
6868 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006869 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6870 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6873 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6874 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6875 /* Also unmute the mono-out pin widget */
6876 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6877
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006878 /* Mute capture amp left and right */
6879 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006880 /* Set ADC connection select to match default mixer setting (mic1
6881 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006882 */
6883 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6884
6885 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006886 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006887 */
6888 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6889 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6890
6891 /* Mute all inputs to mixer widget (even unconnected ones) */
6892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6893 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6894 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6895 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6898 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6900
6901 { }
6902};
6903#endif
6904
Takashi Iwai63300792008-01-24 15:31:36 +01006905#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6906#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006907
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006908#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6909#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6910
Kailang Yangdf694da2005-12-05 19:42:22 +01006911/*
6912 * for BIOS auto-configuration
6913 */
6914
6915static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006916 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006917{
6918 hda_nid_t nid_vol;
6919 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006920 int err;
6921
6922 if (nid >= 0x0f && nid < 0x11) {
6923 nid_vol = nid - 0x7;
6924 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6925 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6926 } else if (nid == 0x11) {
6927 nid_vol = nid - 0x7;
6928 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6929 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6930 } else if (nid >= 0x12 && nid <= 0x15) {
6931 nid_vol = 0x08;
6932 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6933 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6934 } else
6935 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006936
Takashi Iwai863b4512008-10-21 17:01:47 +02006937 if (!(*vol_bits & (1 << nid_vol))) {
6938 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006939 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006940 if (err < 0)
6941 return err;
6942 *vol_bits |= (1 << nid_vol);
6943 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006944 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006945 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006946 return err;
6947 return 1;
6948}
6949
6950/* add playback controls from the parsed DAC table */
6951static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6952 const struct auto_pin_cfg *cfg)
6953{
6954 hda_nid_t nid;
6955 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006956 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006957
6958 spec->multiout.num_dacs = 1;
6959 spec->multiout.dac_nids = spec->private_dac_nids;
6960 spec->multiout.dac_nids[0] = 0x02;
6961
6962 nid = cfg->line_out_pins[0];
6963 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006964 const char *pfx;
6965 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6966 pfx = "Master";
6967 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6968 pfx = "Speaker";
6969 else
6970 pfx = "Front";
6971 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006972 if (err < 0)
6973 return err;
6974 }
6975
Takashi Iwai82bc9552006-03-21 11:24:42 +01006976 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006977 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006978 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006979 if (err < 0)
6980 return err;
6981 }
6982
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006983 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006984 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006985 err = alc260_add_playback_controls(spec, nid, "Headphone",
6986 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006987 if (err < 0)
6988 return err;
6989 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006990 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006991}
6992
6993/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006994static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006995 const struct auto_pin_cfg *cfg)
6996{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006997 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006998}
6999
7000static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
7001 hda_nid_t nid, int pin_type,
7002 int sel_idx)
7003{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007004 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007005 /* need the manual connection? */
7006 if (nid >= 0x12) {
7007 int idx = nid - 0x12;
7008 snd_hda_codec_write(codec, idx + 0x0b, 0,
7009 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01007010 }
7011}
7012
7013static void alc260_auto_init_multi_out(struct hda_codec *codec)
7014{
7015 struct alc_spec *spec = codec->spec;
7016 hda_nid_t nid;
7017
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007018 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007019 if (nid) {
7020 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7021 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
7022 }
Kailang Yangea1fb292008-08-26 12:58:38 +02007023
Takashi Iwai82bc9552006-03-21 11:24:42 +01007024 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 if (nid)
7026 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
7027
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007028 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007029 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007030 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007031}
Kailang Yangdf694da2005-12-05 19:42:22 +01007032
7033#define ALC260_PIN_CD_NID 0x16
7034static void alc260_auto_init_analog_input(struct hda_codec *codec)
7035{
7036 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007037 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01007038 int i;
7039
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007040 for (i = 0; i < cfg->num_inputs; i++) {
7041 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02007043 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01007044 if (nid != ALC260_PIN_CD_NID &&
7045 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007046 snd_hda_codec_write(codec, nid, 0,
7047 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01007048 AMP_OUT_MUTE);
7049 }
7050 }
7051}
7052
Takashi Iwai7f311a42010-04-09 17:32:23 +02007053#define alc260_auto_init_input_src alc880_auto_init_input_src
7054
Kailang Yangdf694da2005-12-05 19:42:22 +01007055/*
7056 * generic initialization of ADC, input mixers and output mixers
7057 */
7058static struct hda_verb alc260_volume_init_verbs[] = {
7059 /*
7060 * Unmute ADC0-1 and set the default input to mic-in
7061 */
7062 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7063 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7064 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7065 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007066
Kailang Yangdf694da2005-12-05 19:42:22 +01007067 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7068 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007069 * Note: PASD motherboards uses the Line In 2 as the input for
7070 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007071 */
7072 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007073 /* mute analog inputs */
7074 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7075 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7078 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007079
7080 /*
7081 * Set up output mixers (0x08 - 0x0a)
7082 */
7083 /* set vol=0 to output mixers */
7084 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7085 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7086 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7087 /* set up input amps for analog loopback */
7088 /* Amp Indices: DAC = 0, mixer = 1 */
7089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7090 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7093 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7094 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007095
Kailang Yangdf694da2005-12-05 19:42:22 +01007096 { }
7097};
7098
7099static int alc260_parse_auto_config(struct hda_codec *codec)
7100{
7101 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007102 int err;
7103 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7104
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007105 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7106 alc260_ignore);
7107 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007108 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007109 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7110 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007111 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007112 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007113 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007114 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007115 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007116 return err;
7117
7118 spec->multiout.max_channels = 2;
7119
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007120 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007121 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007122 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007123 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007124
Takashi Iwaid88897e2008-10-31 15:01:37 +01007125 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007126
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007127 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007128 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007129
Kailang Yang6227cdc2010-02-25 08:36:52 +01007130 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007131
Kailang Yangdf694da2005-12-05 19:42:22 +01007132 return 1;
7133}
7134
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007135/* additional initialization for auto-configuration model */
7136static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007137{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007138 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007139 alc260_auto_init_multi_out(codec);
7140 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007141 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007142 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007143 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007144 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007145}
7146
Takashi Iwaicb53c622007-08-10 17:21:45 +02007147#ifdef CONFIG_SND_HDA_POWER_SAVE
7148static struct hda_amp_list alc260_loopbacks[] = {
7149 { 0x07, HDA_INPUT, 0 },
7150 { 0x07, HDA_INPUT, 1 },
7151 { 0x07, HDA_INPUT, 2 },
7152 { 0x07, HDA_INPUT, 3 },
7153 { 0x07, HDA_INPUT, 4 },
7154 { } /* end */
7155};
7156#endif
7157
Kailang Yangdf694da2005-12-05 19:42:22 +01007158/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007159 * Pin config fixes
7160 */
7161enum {
7162 PINFIX_HP_DC5750,
7163};
7164
Takashi Iwaifc091762010-08-04 23:53:36 +02007165static const struct alc_fixup alc260_fixups[] = {
7166 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007167 .type = ALC_FIXUP_PINS,
7168 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007169 { 0x11, 0x90130110 }, /* speaker */
7170 { }
7171 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007172 },
7173};
7174
7175static struct snd_pci_quirk alc260_fixup_tbl[] = {
7176 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7177 {}
7178};
7179
7180/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007181 * ALC260 configurations
7182 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007183static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007184 [ALC260_BASIC] = "basic",
7185 [ALC260_HP] = "hp",
7186 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007187 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007188 [ALC260_FUJITSU_S702X] = "fujitsu",
7189 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007190 [ALC260_WILL] = "will",
7191 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007192 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007193#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007194 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007195#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007196 [ALC260_AUTO] = "auto",
7197};
7198
7199static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007200 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007201 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007202 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007203 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007204 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007205 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007206 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007207 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007208 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007209 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7210 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7211 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7212 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7213 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7214 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7215 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7216 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7217 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007218 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007219 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007220 {}
7221};
7222
Kailang Yangdf694da2005-12-05 19:42:22 +01007223static struct alc_config_preset alc260_presets[] = {
7224 [ALC260_BASIC] = {
7225 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007226 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007227 .init_verbs = { alc260_init_verbs },
7228 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7229 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007230 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007231 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007232 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7233 .channel_mode = alc260_modes,
7234 .input_mux = &alc260_capture_source,
7235 },
7236 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007237 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007238 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007239 .init_verbs = { alc260_init_verbs,
7240 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007241 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7242 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007243 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7244 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007245 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7246 .channel_mode = alc260_modes,
7247 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007248 .unsol_event = alc260_hp_unsol_event,
7249 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007250 },
Kailang Yang3f878302008-08-26 13:02:23 +02007251 [ALC260_HP_DC7600] = {
7252 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007253 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007254 .init_verbs = { alc260_init_verbs,
7255 alc260_hp_dc7600_verbs },
7256 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7257 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007258 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7259 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007260 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7261 .channel_mode = alc260_modes,
7262 .input_mux = &alc260_capture_source,
7263 .unsol_event = alc260_hp_3012_unsol_event,
7264 .init_hook = alc260_hp_3012_automute,
7265 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007266 [ALC260_HP_3013] = {
7267 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007268 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007269 .init_verbs = { alc260_hp_3013_init_verbs,
7270 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007271 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7272 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007273 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7274 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007275 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7276 .channel_mode = alc260_modes,
7277 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007278 .unsol_event = alc260_hp_3013_unsol_event,
7279 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007280 },
7281 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007282 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007283 .init_verbs = { alc260_fujitsu_init_verbs },
7284 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7285 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007286 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7287 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007288 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7289 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007290 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7291 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007292 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007293 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007294 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007295 .init_verbs = { alc260_acer_init_verbs },
7296 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7297 .dac_nids = alc260_dac_nids,
7298 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7299 .adc_nids = alc260_dual_adc_nids,
7300 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7301 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007302 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7303 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007304 },
Michael Schwingencc959482009-02-22 18:58:45 +01007305 [ALC260_FAVORIT100] = {
7306 .mixers = { alc260_favorit100_mixer },
7307 .init_verbs = { alc260_favorit100_init_verbs },
7308 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7309 .dac_nids = alc260_dac_nids,
7310 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7311 .adc_nids = alc260_dual_adc_nids,
7312 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7313 .channel_mode = alc260_modes,
7314 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7315 .input_mux = alc260_favorit100_capture_sources,
7316 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007317 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007318 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007319 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7320 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7321 .dac_nids = alc260_dac_nids,
7322 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7323 .adc_nids = alc260_adc_nids,
7324 .dig_out_nid = ALC260_DIGOUT_NID,
7325 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7326 .channel_mode = alc260_modes,
7327 .input_mux = &alc260_capture_source,
7328 },
7329 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007330 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007331 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7332 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7333 .dac_nids = alc260_dac_nids,
7334 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7335 .adc_nids = alc260_adc_nids,
7336 .dig_out_nid = ALC260_DIGOUT_NID,
7337 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7338 .channel_mode = alc260_modes,
7339 .input_mux = &alc260_capture_source,
7340 .unsol_event = alc260_replacer_672v_unsol_event,
7341 .init_hook = alc260_replacer_672v_automute,
7342 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007343#ifdef CONFIG_SND_DEBUG
7344 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007345 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007346 .init_verbs = { alc260_test_init_verbs },
7347 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7348 .dac_nids = alc260_test_dac_nids,
7349 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7350 .adc_nids = alc260_test_adc_nids,
7351 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7352 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007353 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7354 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007355 },
7356#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007357};
7358
Linus Torvalds1da177e2005-04-16 15:20:36 -07007359static int patch_alc260(struct hda_codec *codec)
7360{
7361 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007362 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007363
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007364 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007365 if (spec == NULL)
7366 return -ENOMEM;
7367
7368 codec->spec = spec;
7369
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007370 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7371 alc260_models,
7372 alc260_cfg_tbl);
7373 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007374 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007375 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007376 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007377 }
7378
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007379 if (board_config == ALC260_AUTO) {
7380 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7381 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7382 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007383
Kailang Yangdf694da2005-12-05 19:42:22 +01007384 if (board_config == ALC260_AUTO) {
7385 /* automatic parse from the BIOS config */
7386 err = alc260_parse_auto_config(codec);
7387 if (err < 0) {
7388 alc_free(codec);
7389 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007390 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007391 printk(KERN_INFO
7392 "hda_codec: Cannot set up configuration "
7393 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007394 board_config = ALC260_BASIC;
7395 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007396 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007397
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007398 err = snd_hda_attach_beep_device(codec, 0x1);
7399 if (err < 0) {
7400 alc_free(codec);
7401 return err;
7402 }
7403
Kailang Yangdf694da2005-12-05 19:42:22 +01007404 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007405 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007406
Linus Torvalds1da177e2005-04-16 15:20:36 -07007407 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7408 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307409 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007410
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007411 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7412 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7413
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007414 if (!spec->adc_nids && spec->input_mux) {
7415 /* check whether NID 0x04 is valid */
7416 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007417 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007418 /* get type */
7419 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7420 spec->adc_nids = alc260_adc_nids_alt;
7421 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7422 } else {
7423 spec->adc_nids = alc260_adc_nids;
7424 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7425 }
7426 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007427 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007428 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007429
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007430 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007431
Takashi Iwai2134ea42008-01-10 16:53:55 +01007432 spec->vmaster_nid = 0x08;
7433
Linus Torvalds1da177e2005-04-16 15:20:36 -07007434 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007435 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007436 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007437#ifdef CONFIG_SND_HDA_POWER_SAVE
7438 if (!spec->loopback.amplist)
7439 spec->loopback.amplist = alc260_loopbacks;
7440#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007441
7442 return 0;
7443}
7444
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007445
Linus Torvalds1da177e2005-04-16 15:20:36 -07007446/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007447 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007448 *
7449 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7450 * configuration. Each pin widget can choose any input DACs and a mixer.
7451 * Each ADC is connected from a mixer of all inputs. This makes possible
7452 * 6-channel independent captures.
7453 *
7454 * In addition, an independent DAC for the multi-playback (not used in this
7455 * driver yet).
7456 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007457#define ALC882_DIGOUT_NID 0x06
7458#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007459#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7460#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7461#define ALC1200_DIGOUT_NID 0x10
7462
Linus Torvalds1da177e2005-04-16 15:20:36 -07007463
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007464static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007465 { 8, NULL }
7466};
7467
Takashi Iwai4953550a2009-06-30 15:28:30 +02007468/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007469static hda_nid_t alc882_dac_nids[4] = {
7470 /* front, rear, clfe, rear_surr */
7471 0x02, 0x03, 0x04, 0x05
7472};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007473#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007474
Takashi Iwai4953550a2009-06-30 15:28:30 +02007475/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007476#define alc882_adc_nids alc880_adc_nids
7477#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007478#define alc883_adc_nids alc882_adc_nids_alt
7479static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7480static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7481#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007482
Takashi Iwaie1406342008-02-11 18:32:32 +01007483static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7484static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007485#define alc883_capsrc_nids alc882_capsrc_nids_alt
7486static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7487#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007488
Linus Torvalds1da177e2005-04-16 15:20:36 -07007489/* input MUX */
7490/* FIXME: should be a matrix-type input source selection */
7491
7492static struct hda_input_mux alc882_capture_source = {
7493 .num_items = 4,
7494 .items = {
7495 { "Mic", 0x0 },
7496 { "Front Mic", 0x1 },
7497 { "Line", 0x2 },
7498 { "CD", 0x4 },
7499 },
7500};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007501
Takashi Iwai4953550a2009-06-30 15:28:30 +02007502#define alc883_capture_source alc882_capture_source
7503
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007504static struct hda_input_mux alc889_capture_source = {
7505 .num_items = 3,
7506 .items = {
7507 { "Front Mic", 0x0 },
7508 { "Mic", 0x3 },
7509 { "Line", 0x2 },
7510 },
7511};
7512
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007513static struct hda_input_mux mb5_capture_source = {
7514 .num_items = 3,
7515 .items = {
7516 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307517 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007518 { "CD", 0x4 },
7519 },
7520};
7521
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007522static struct hda_input_mux macmini3_capture_source = {
7523 .num_items = 2,
7524 .items = {
7525 { "Line", 0x2 },
7526 { "CD", 0x4 },
7527 },
7528};
7529
Takashi Iwai4953550a2009-06-30 15:28:30 +02007530static struct hda_input_mux alc883_3stack_6ch_intel = {
7531 .num_items = 4,
7532 .items = {
7533 { "Mic", 0x1 },
7534 { "Front Mic", 0x0 },
7535 { "Line", 0x2 },
7536 { "CD", 0x4 },
7537 },
7538};
7539
7540static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7541 .num_items = 2,
7542 .items = {
7543 { "Mic", 0x1 },
7544 { "Line", 0x2 },
7545 },
7546};
7547
7548static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7549 .num_items = 4,
7550 .items = {
7551 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007552 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007553 { "Line", 0x2 },
7554 { "CD", 0x4 },
7555 },
7556};
7557
7558static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7559 .num_items = 2,
7560 .items = {
7561 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007562 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007563 },
7564};
7565
7566static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7567 .num_items = 3,
7568 .items = {
7569 { "Mic", 0x0 },
7570 { "Front Mic", 0x1 },
7571 { "Line", 0x4 },
7572 },
7573};
7574
7575static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7576 .num_items = 2,
7577 .items = {
7578 { "Mic", 0x0 },
7579 { "Line", 0x2 },
7580 },
7581};
7582
7583static struct hda_input_mux alc889A_mb31_capture_source = {
7584 .num_items = 2,
7585 .items = {
7586 { "Mic", 0x0 },
7587 /* Front Mic (0x01) unused */
7588 { "Line", 0x2 },
7589 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007590 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007591 },
7592};
7593
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007594static struct hda_input_mux alc889A_imac91_capture_source = {
7595 .num_items = 2,
7596 .items = {
7597 { "Mic", 0x01 },
7598 { "Line", 0x2 }, /* Not sure! */
7599 },
7600};
7601
Takashi Iwai4953550a2009-06-30 15:28:30 +02007602/*
7603 * 2ch mode
7604 */
7605static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7606 { 2, NULL }
7607};
7608
Kailang Yangdf694da2005-12-05 19:42:22 +01007609/*
Kailang Yang272a5272007-05-14 11:00:38 +02007610 * 2ch mode
7611 */
7612static struct hda_verb alc882_3ST_ch2_init[] = {
7613 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7614 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7615 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7616 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7617 { } /* end */
7618};
7619
7620/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007621 * 4ch mode
7622 */
7623static struct hda_verb alc882_3ST_ch4_init[] = {
7624 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7625 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7626 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7627 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7628 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7629 { } /* end */
7630};
7631
7632/*
Kailang Yang272a5272007-05-14 11:00:38 +02007633 * 6ch mode
7634 */
7635static struct hda_verb alc882_3ST_ch6_init[] = {
7636 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7637 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7638 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7639 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7640 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7641 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7642 { } /* end */
7643};
7644
Takashi Iwai4953550a2009-06-30 15:28:30 +02007645static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007646 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007647 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007648 { 6, alc882_3ST_ch6_init },
7649};
7650
Takashi Iwai4953550a2009-06-30 15:28:30 +02007651#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7652
Kailang Yang272a5272007-05-14 11:00:38 +02007653/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307654 * 2ch mode
7655 */
7656static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7657 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7658 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7659 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7660 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7661 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7662 { } /* end */
7663};
7664
7665/*
7666 * 4ch mode
7667 */
7668static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7669 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7670 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7671 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7672 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7673 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7674 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7675 { } /* end */
7676};
7677
7678/*
7679 * 6ch mode
7680 */
7681static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7682 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7683 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7684 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7685 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7686 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7687 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7688 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7689 { } /* end */
7690};
7691
7692static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7693 { 2, alc883_3ST_ch2_clevo_init },
7694 { 4, alc883_3ST_ch4_clevo_init },
7695 { 6, alc883_3ST_ch6_clevo_init },
7696};
7697
7698
7699/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007700 * 6ch mode
7701 */
7702static struct hda_verb alc882_sixstack_ch6_init[] = {
7703 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7704 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7705 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7706 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7707 { } /* end */
7708};
7709
7710/*
7711 * 8ch mode
7712 */
7713static struct hda_verb alc882_sixstack_ch8_init[] = {
7714 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7715 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7716 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7717 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7718 { } /* end */
7719};
7720
7721static struct hda_channel_mode alc882_sixstack_modes[2] = {
7722 { 6, alc882_sixstack_ch6_init },
7723 { 8, alc882_sixstack_ch8_init },
7724};
7725
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007726
7727/* Macbook Air 2,1 */
7728
7729static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7730 { 2, NULL },
7731};
7732
Takashi Iwai87350ad2007-08-16 18:19:38 +02007733/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007734 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007735 */
7736
7737/*
7738 * 2ch mode
7739 */
7740static struct hda_verb alc885_mbp_ch2_init[] = {
7741 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7742 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7743 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7744 { } /* end */
7745};
7746
7747/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007748 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007749 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007750static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7753 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7754 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7755 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7756 { } /* end */
7757};
7758
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007759static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007760 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007761 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007762};
7763
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007764/*
7765 * 2ch
7766 * Speakers/Woofer/HP = Front
7767 * LineIn = Input
7768 */
7769static struct hda_verb alc885_mb5_ch2_init[] = {
7770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7772 { } /* end */
7773};
7774
7775/*
7776 * 6ch mode
7777 * Speakers/HP = Front
7778 * Woofer = LFE
7779 * LineIn = Surround
7780 */
7781static struct hda_verb alc885_mb5_ch6_init[] = {
7782 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7785 { } /* end */
7786};
7787
7788static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7789 { 2, alc885_mb5_ch2_init },
7790 { 6, alc885_mb5_ch6_init },
7791};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007792
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007793#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007794
7795/*
7796 * 2ch mode
7797 */
7798static struct hda_verb alc883_4ST_ch2_init[] = {
7799 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7800 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7801 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7802 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7803 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7804 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7805 { } /* end */
7806};
7807
7808/*
7809 * 4ch mode
7810 */
7811static struct hda_verb alc883_4ST_ch4_init[] = {
7812 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7813 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7814 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7815 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7816 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7817 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7818 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7819 { } /* end */
7820};
7821
7822/*
7823 * 6ch mode
7824 */
7825static struct hda_verb alc883_4ST_ch6_init[] = {
7826 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7827 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7828 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7829 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7830 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7831 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7832 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7833 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7834 { } /* end */
7835};
7836
7837/*
7838 * 8ch mode
7839 */
7840static struct hda_verb alc883_4ST_ch8_init[] = {
7841 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7842 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7843 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7844 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7845 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7846 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7847 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7848 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7849 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7850 { } /* end */
7851};
7852
7853static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7854 { 2, alc883_4ST_ch2_init },
7855 { 4, alc883_4ST_ch4_init },
7856 { 6, alc883_4ST_ch6_init },
7857 { 8, alc883_4ST_ch8_init },
7858};
7859
7860
7861/*
7862 * 2ch mode
7863 */
7864static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7865 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7866 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7867 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7868 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7869 { } /* end */
7870};
7871
7872/*
7873 * 4ch mode
7874 */
7875static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7876 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7877 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7878 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7879 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7880 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7881 { } /* end */
7882};
7883
7884/*
7885 * 6ch mode
7886 */
7887static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7888 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7889 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7890 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7891 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7892 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7893 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7894 { } /* end */
7895};
7896
7897static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7898 { 2, alc883_3ST_ch2_intel_init },
7899 { 4, alc883_3ST_ch4_intel_init },
7900 { 6, alc883_3ST_ch6_intel_init },
7901};
7902
7903/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007904 * 2ch mode
7905 */
7906static struct hda_verb alc889_ch2_intel_init[] = {
7907 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7908 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7909 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7910 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7911 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7912 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7913 { } /* end */
7914};
7915
7916/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007917 * 6ch mode
7918 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007919static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007920 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7921 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7922 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7923 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7924 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007925 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7926 { } /* end */
7927};
7928
7929/*
7930 * 8ch mode
7931 */
7932static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007933 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7934 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7935 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7936 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7937 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007938 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7939 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007940 { } /* end */
7941};
7942
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007943static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7944 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007945 { 6, alc889_ch6_intel_init },
7946 { 8, alc889_ch8_intel_init },
7947};
7948
7949/*
7950 * 6ch mode
7951 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007952static struct hda_verb alc883_sixstack_ch6_init[] = {
7953 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7954 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7955 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7956 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7957 { } /* end */
7958};
7959
7960/*
7961 * 8ch mode
7962 */
7963static struct hda_verb alc883_sixstack_ch8_init[] = {
7964 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7965 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7966 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7967 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7968 { } /* end */
7969};
7970
7971static struct hda_channel_mode alc883_sixstack_modes[2] = {
7972 { 6, alc883_sixstack_ch6_init },
7973 { 8, alc883_sixstack_ch8_init },
7974};
7975
7976
Linus Torvalds1da177e2005-04-16 15:20:36 -07007977/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7978 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7979 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007980static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007981 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007982 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007983 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007984 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007985 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7986 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007987 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7988 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007989 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007990 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7992 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7994 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7995 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007997 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7999 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008000 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008001 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008002 { } /* end */
8003};
8004
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008005/* Macbook Air 2,1 same control for HP and internal Speaker */
8006
8007static struct snd_kcontrol_new alc885_mba21_mixer[] = {
8008 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8009 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
8010 { }
8011};
8012
8013
Takashi Iwai87350ad2007-08-16 18:19:38 +02008014static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008015 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8016 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
8017 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8018 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
8019 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01008020 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8021 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8023 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008024 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
8025 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008026 { } /* end */
8027};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008028
8029static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8031 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8032 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8033 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8034 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8035 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10308036 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8037 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09308038 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8039 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008040 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8041 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008042 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
8043 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008044 { } /* end */
8045};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008046
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008047static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
8048 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8049 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8050 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8051 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8052 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8053 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8055 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
8056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8057 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008058 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008059 { } /* end */
8060};
8061
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008062static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008063 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8064 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008065 { } /* end */
8066};
8067
8068
Kailang Yangbdd148a2007-05-08 15:19:08 +02008069static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8070 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8071 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8072 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8073 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8075 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008077 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008078 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008079 { } /* end */
8080};
8081
Kailang Yang272a5272007-05-14 11:00:38 +02008082static struct snd_kcontrol_new alc882_targa_mixer[] = {
8083 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8084 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8085 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8086 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8087 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8088 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8089 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8090 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008092 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008093 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8094 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008095 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008096 { } /* end */
8097};
8098
8099/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8100 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8101 */
8102static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8104 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8106 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8107 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8108 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8111 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8112 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008115 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008116 { } /* end */
8117};
8118
Takashi Iwai914759b2007-09-06 14:52:04 +02008119static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8120 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8121 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008128 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008130 { } /* end */
8131};
8132
Kailang Yangdf694da2005-12-05 19:42:22 +01008133static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8134 {
8135 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8136 .name = "Channel Mode",
8137 .info = alc_ch_mode_info,
8138 .get = alc_ch_mode_get,
8139 .put = alc_ch_mode_put,
8140 },
8141 { } /* end */
8142};
8143
Takashi Iwai4953550a2009-06-30 15:28:30 +02008144static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008145 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008148 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008149 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8150 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008151 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008152 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8153 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008154 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008155 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8156 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008157
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008158 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008159 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008160 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008161 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008162 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008164 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008165 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008166 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008168 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008169 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008170 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008171 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008172 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008173 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008174 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008175 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008176 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8177 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008178 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008179 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8180 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008181 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8183 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8185 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8186 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008187 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008188 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008189
8190 /* FIXME: use matrix-type input source selection */
8191 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008192 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008194 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008196 /* ADC2: mute amp left and right */
8197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008198 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008199 /* ADC3: mute amp left and right */
8200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008201 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008202
8203 { }
8204};
8205
Takashi Iwai4953550a2009-06-30 15:28:30 +02008206static struct hda_verb alc882_adc1_init_verbs[] = {
8207 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8212 /* ADC1: mute amp left and right */
8213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8214 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8215 { }
8216};
8217
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008218static struct hda_verb alc882_eapd_verbs[] = {
8219 /* change to EAPD mode */
8220 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008221 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008222 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008223};
8224
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008225static struct hda_verb alc889_eapd_verbs[] = {
8226 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8227 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8228 { }
8229};
8230
Wu Fengguang6732bd02009-07-30 09:19:14 +02008231static struct hda_verb alc_hp15_unsol_verbs[] = {
8232 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8233 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8234 {}
8235};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008236
8237static struct hda_verb alc885_init_verbs[] = {
8238 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008239 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008241 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008242 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8243 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008244 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008245 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8246 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008247 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008248 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8249 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008250
8251 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8254 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8255 /* Front Pin: output 0 (0x0c) */
8256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8257 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8258 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8259 /* Rear Pin: output 1 (0x0d) */
8260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8262 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8263 /* CLFE Pin: output 2 (0x0e) */
8264 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8265 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8266 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8267 /* Side Pin: output 3 (0x0f) */
8268 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8269 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8270 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8271 /* Mic (rear) pin: input vref at 80% */
8272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8274 /* Front Mic pin: input vref at 80% */
8275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8277 /* Line In pin: input */
8278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8279 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8280
8281 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8282 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008284 /* Input mixer2 */
8285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008286 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008288 /* ADC2: mute amp left and right */
8289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8290 /* ADC3: mute amp left and right */
8291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8292
8293 { }
8294};
8295
8296static struct hda_verb alc885_init_input_verbs[] = {
8297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8300 { }
8301};
8302
8303
8304/* Unmute Selector 24h and set the default input to front mic */
8305static struct hda_verb alc889_init_input_verbs[] = {
8306 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8308 { }
8309};
8310
8311
Takashi Iwai4953550a2009-06-30 15:28:30 +02008312#define alc883_init_verbs alc882_base_init_verbs
8313
Tobin Davis9102cd12006-12-15 10:02:12 +01008314/* Mac Pro test */
8315static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8316 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8317 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8318 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8319 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8320 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008321 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008322 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8323 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008324 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008325 { } /* end */
8326};
8327
8328static struct hda_verb alc882_macpro_init_verbs[] = {
8329 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8333 /* Front Pin: output 0 (0x0c) */
8334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8337 /* Front Mic pin: input vref at 80% */
8338 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8340 /* Speaker: output */
8341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8343 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8344 /* Headphone output (output 0 - 0x0c) */
8345 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8346 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8347 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8348
8349 /* FIXME: use matrix-type input source selection */
8350 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8351 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8356 /* Input mixer2 */
8357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8359 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8360 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8361 /* Input mixer3 */
8362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8366 /* ADC1: mute amp left and right */
8367 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8368 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8369 /* ADC2: mute amp left and right */
8370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8371 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8372 /* ADC3: mute amp left and right */
8373 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8374 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8375
8376 { }
8377};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008378
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008379/* Macbook 5,1 */
8380static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008381 /* DACs */
8382 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8383 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8384 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8385 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008386 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8388 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8389 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008390 /* Surround mixer */
8391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8392 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8394 /* LFE mixer */
8395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8398 /* HP mixer */
8399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8400 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8401 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8402 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008403 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8404 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008405 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8406 /* LFE Pin (0x0e) */
8407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8409 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8410 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008413 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308414 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008415 /* Front Mic pin: input vref at 80% */
8416 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8417 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8418 /* Line In pin */
8419 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8420 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8421
Alex Murrayb8f171e2010-06-14 12:08:43 +09308422 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8423 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008425 { }
8426};
8427
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008428/* Macmini 3,1 */
8429static struct hda_verb alc885_macmini3_init_verbs[] = {
8430 /* DACs */
8431 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8432 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8433 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8434 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8435 /* Front mixer */
8436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8439 /* Surround mixer */
8440 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8441 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8442 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8443 /* LFE mixer */
8444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8446 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8447 /* HP mixer */
8448 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8449 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8450 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8451 /* Front Pin (0x0c) */
8452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8453 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8454 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8455 /* LFE Pin (0x0e) */
8456 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8457 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8458 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8459 /* HP Pin (0x0f) */
8460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8461 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8462 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8463 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8464 /* Line In pin */
8465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8467
8468 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8469 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8470 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8471 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8472 { }
8473};
8474
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008475
8476static struct hda_verb alc885_mba21_init_verbs[] = {
8477 /*Internal and HP Speaker Mixer*/
8478 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8480 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8481 /*Internal Speaker Pin (0x0c)*/
8482 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8483 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8484 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8485 /* HP Pin: output 0 (0x0e) */
8486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8488 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8489 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8490 /* Line in (is hp when jack connected)*/
8491 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8492 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8493
8494 { }
8495 };
8496
8497
Takashi Iwai87350ad2007-08-16 18:19:38 +02008498/* Macbook Pro rev3 */
8499static struct hda_verb alc885_mbp3_init_verbs[] = {
8500 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8504 /* Rear mixer */
8505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008508 /* HP mixer */
8509 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8510 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8511 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008512 /* Front Pin: output 0 (0x0c) */
8513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8514 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8515 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008516 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008517 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8519 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008520 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8521 /* Mic (rear) pin: input vref at 80% */
8522 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8523 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8524 /* Front Mic pin: input vref at 80% */
8525 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8526 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8527 /* Line In pin: use output 1 when in LineOut mode */
8528 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8530 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8531
8532 /* FIXME: use matrix-type input source selection */
8533 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8534 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8535 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8536 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8537 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8539 /* Input mixer2 */
8540 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8541 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8542 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8543 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8544 /* Input mixer3 */
8545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8548 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8549 /* ADC1: mute amp left and right */
8550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8551 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8552 /* ADC2: mute amp left and right */
8553 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8554 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8555 /* ADC3: mute amp left and right */
8556 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8557 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8558
8559 { }
8560};
8561
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008562/* iMac 9,1 */
8563static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008564 /* Internal Speaker Pin (0x0c) */
8565 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8566 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8567 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8568 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8569 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8570 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8571 /* HP Pin: Rear */
8572 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8573 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8574 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8575 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8576 /* Line in Rear */
8577 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8579 /* Front Mic pin: input vref at 80% */
8580 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8581 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008582 /* Rear mixer */
8583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008586 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8590 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008595 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008600 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8603 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8604 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008605 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008606 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8607 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008608 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008609 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8610 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008611 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008612 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8613 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008614 { }
8615};
8616
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008617/* iMac 24 mixer. */
8618static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8619 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8620 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8621 { } /* end */
8622};
8623
8624/* iMac 24 init verbs. */
8625static struct hda_verb alc885_imac24_init_verbs[] = {
8626 /* Internal speakers: output 0 (0x0c) */
8627 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8628 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8629 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8630 /* Internal speakers: output 0 (0x0c) */
8631 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8632 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8633 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8634 /* Headphone: output 0 (0x0c) */
8635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8636 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8637 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8638 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8639 /* Front Mic: input vref at 80% */
8640 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8641 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8642 { }
8643};
8644
8645/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008646static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008647{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008648 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008649
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008650 spec->autocfg.hp_pins[0] = 0x14;
8651 spec->autocfg.speaker_pins[0] = 0x18;
8652 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008653}
8654
Takashi Iwai9d54f082010-02-22 08:34:40 +01008655#define alc885_mb5_setup alc885_imac24_setup
8656#define alc885_macmini3_setup alc885_imac24_setup
8657
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008658/* Macbook Air 2,1 */
8659static void alc885_mba21_setup(struct hda_codec *codec)
8660{
8661 struct alc_spec *spec = codec->spec;
8662
8663 spec->autocfg.hp_pins[0] = 0x14;
8664 spec->autocfg.speaker_pins[0] = 0x18;
8665}
8666
8667
8668
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008669static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008670{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008671 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008672
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008673 spec->autocfg.hp_pins[0] = 0x15;
8674 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008675}
8676
Takashi Iwai9d54f082010-02-22 08:34:40 +01008677static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308678{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008679 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308680
Takashi Iwai9d54f082010-02-22 08:34:40 +01008681 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008682 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008683 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008684}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008685
Kailang Yang272a5272007-05-14 11:00:38 +02008686static struct hda_verb alc882_targa_verbs[] = {
8687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8689
8690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8691 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008692
Kailang Yang272a5272007-05-14 11:00:38 +02008693 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8694 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8695 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8696
8697 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008698 { } /* end */
8699};
8700
8701/* toggle speaker-output according to the hp-jack state */
8702static void alc882_targa_automute(struct hda_codec *codec)
8703{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008704 struct alc_spec *spec = codec->spec;
8705 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008706 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008707 spec->jack_present ? 1 : 3);
8708}
8709
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008710static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008711{
8712 struct alc_spec *spec = codec->spec;
8713
8714 spec->autocfg.hp_pins[0] = 0x14;
8715 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008716}
8717
8718static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8719{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008720 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008721 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008722}
8723
8724static struct hda_verb alc882_asus_a7j_verbs[] = {
8725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8727
8728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8730 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008731
Kailang Yang272a5272007-05-14 11:00:38 +02008732 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8733 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8734 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8735
8736 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8737 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8738 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8739 { } /* end */
8740};
8741
Takashi Iwai914759b2007-09-06 14:52:04 +02008742static struct hda_verb alc882_asus_a7m_verbs[] = {
8743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8745
8746 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8748 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008749
Takashi Iwai914759b2007-09-06 14:52:04 +02008750 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8751 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8752 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8753
8754 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8755 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8756 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8757 { } /* end */
8758};
8759
Tobin Davis9102cd12006-12-15 10:02:12 +01008760static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8761{
8762 unsigned int gpiostate, gpiomask, gpiodir;
8763
8764 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8765 AC_VERB_GET_GPIO_DATA, 0);
8766
8767 if (!muted)
8768 gpiostate |= (1 << pin);
8769 else
8770 gpiostate &= ~(1 << pin);
8771
8772 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8773 AC_VERB_GET_GPIO_MASK, 0);
8774 gpiomask |= (1 << pin);
8775
8776 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8777 AC_VERB_GET_GPIO_DIRECTION, 0);
8778 gpiodir |= (1 << pin);
8779
8780
8781 snd_hda_codec_write(codec, codec->afg, 0,
8782 AC_VERB_SET_GPIO_MASK, gpiomask);
8783 snd_hda_codec_write(codec, codec->afg, 0,
8784 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8785
8786 msleep(1);
8787
8788 snd_hda_codec_write(codec, codec->afg, 0,
8789 AC_VERB_SET_GPIO_DATA, gpiostate);
8790}
8791
Takashi Iwai7debbe52007-08-16 15:01:03 +02008792/* set up GPIO at initialization */
8793static void alc885_macpro_init_hook(struct hda_codec *codec)
8794{
8795 alc882_gpio_mute(codec, 0, 0);
8796 alc882_gpio_mute(codec, 1, 0);
8797}
8798
8799/* set up GPIO and update auto-muting at initialization */
8800static void alc885_imac24_init_hook(struct hda_codec *codec)
8801{
8802 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008803 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008804}
8805
Kailang Yangdf694da2005-12-05 19:42:22 +01008806/*
8807 * generic initialization of ADC, input mixers and output mixers
8808 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008809static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008810 /*
8811 * Unmute ADC0-2 and set the default input to mic-in
8812 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008813 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8814 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8815 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8816 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8817
Kailang Yangdf694da2005-12-05 19:42:22 +01008818 /*
8819 * Set up output mixers (0x0c - 0x0f)
8820 */
8821 /* set vol=0 to output mixers */
8822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8825 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8826 /* set up input amps for analog loopback */
8827 /* Amp Indices: DAC = 0, mixer = 1 */
8828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8829 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8830 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8831 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8832 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8834 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8835 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8836 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8837 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8838
8839 /* FIXME: use matrix-type input source selection */
8840 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008841 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008843 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008845 { }
8846};
8847
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008848/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8849static struct hda_verb alc889A_mb31_ch2_init[] = {
8850 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8851 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8852 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8853 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8854 { } /* end */
8855};
8856
8857/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8858static struct hda_verb alc889A_mb31_ch4_init[] = {
8859 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8860 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8861 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8862 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8863 { } /* end */
8864};
8865
8866/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8867static struct hda_verb alc889A_mb31_ch5_init[] = {
8868 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8871 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8872 { } /* end */
8873};
8874
8875/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8876static struct hda_verb alc889A_mb31_ch6_init[] = {
8877 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8878 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8879 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8880 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8881 { } /* end */
8882};
8883
8884static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8885 { 2, alc889A_mb31_ch2_init },
8886 { 4, alc889A_mb31_ch4_init },
8887 { 5, alc889A_mb31_ch5_init },
8888 { 6, alc889A_mb31_ch6_init },
8889};
8890
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008891static struct hda_verb alc883_medion_eapd_verbs[] = {
8892 /* eanable EAPD on medion laptop */
8893 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8894 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8895 { }
8896};
8897
Takashi Iwai4953550a2009-06-30 15:28:30 +02008898#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008899
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008900static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8901 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8902 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8903 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8904 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8905 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8906 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8907 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8908 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008909 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008910 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8911 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008912 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008913 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008914 { } /* end */
8915};
8916
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008917static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8919 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8920 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8921 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008923 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008924 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008925 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008926 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008927 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008928 { } /* end */
8929};
8930
Jiang zhefb97dc62008-03-06 11:07:11 +01008931static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8932 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8933 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8934 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8935 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008937 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008939 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008940 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008941 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008942 { } /* end */
8943};
8944
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008945static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8949 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8950 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008954 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8956 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008957 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008959 { } /* end */
8960};
8961
8962static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8963 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8964 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8965 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8966 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8967 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8968 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8969 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8970 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008977 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8979 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008980 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008981 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008982 { } /* end */
8983};
8984
Jiang zhe17bba1b2008-06-04 12:11:07 +02008985static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8986 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8987 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8988 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8989 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8990 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8991 HDA_OUTPUT),
8992 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8993 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8994 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8996 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8997 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009001 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9003 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009004 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009005 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009006 { } /* end */
9007};
9008
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009009static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
9010 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9011 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9012 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9013 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9014 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9015 HDA_OUTPUT),
9016 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9017 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9018 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9019 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9020 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
9021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009025 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
9027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009028 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9030 { } /* end */
9031};
9032
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009033static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02009034 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009035 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009036 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009037 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009038 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9039 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009040 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9041 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9043 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9044 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9046 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009048 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9050 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009051 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009052 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009053 { } /* end */
9054};
9055
Sasha Alexandrc2592492009-06-16 14:52:54 -04009056static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009059 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009060 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009061 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9062 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9063 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9064 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9065 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9066 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9067 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9068 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9069 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9070 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009072 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009074 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009075};
Kailang Yangccc656c2006-10-17 12:32:26 +02009076
Sasha Alexandrc2592492009-06-16 14:52:54 -04009077static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009078 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009079 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009080 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009081 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009085 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009086 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009087 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009088 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009089 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009090 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009091};
Kailang Yangccc656c2006-10-17 12:32:26 +02009092
Takashi Iwaib99dba32009-09-17 18:23:00 +02009093static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9094 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9095 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009096 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009097 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009098 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009099 { } /* end */
9100};
9101
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009102static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9104 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009105 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9106 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009109 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009110 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009111 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009112};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009113
Kailang Yang272a5272007-05-14 11:00:38 +02009114static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9115 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9116 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9121 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009122 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9123 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009124 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009125};
Kailang Yang272a5272007-05-14 11:00:38 +02009126
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009127static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9128 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9129 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9130 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9132 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9133 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9134 { } /* end */
9135};
9136
9137static struct hda_verb alc883_medion_wim2160_verbs[] = {
9138 /* Unmute front mixer */
9139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9141
9142 /* Set speaker pin to front mixer */
9143 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9144
9145 /* Init headphone pin */
9146 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9147 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9148 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9149 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9150
9151 { } /* end */
9152};
9153
9154/* toggle speaker-output according to the hp-jack state */
9155static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9156{
9157 struct alc_spec *spec = codec->spec;
9158
9159 spec->autocfg.hp_pins[0] = 0x1a;
9160 spec->autocfg.speaker_pins[0] = 0x15;
9161}
9162
Tobin Davis2880a862007-08-07 11:50:26 +02009163static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009164 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9165 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009167 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9168 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009170 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009172 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009173};
Tobin Davis2880a862007-08-07 11:50:26 +02009174
Tony Vroond2fd4b02009-06-21 00:40:10 +01009175static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9176 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009177 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009180 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9181 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, 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),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9185 { } /* end */
9186};
9187
Kailang Yange2757d52008-08-26 13:17:46 +02009188static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9189 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9190 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9191 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9192 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9193 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9194 0x0d, 1, 0x0, HDA_OUTPUT),
9195 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9196 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9197 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9198 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9199 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009200 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9201 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9202 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9203 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009205 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9207 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009208 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009209 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009210 { } /* end */
9211};
9212
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009213static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9214 /* Output mixers */
9215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9216 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9217 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9218 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9219 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9220 HDA_OUTPUT),
9221 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9222 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9223 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9224 /* Output switches */
9225 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9226 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9227 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9228 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009229 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9230 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009231 /* Input mixers */
9232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9235 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9236 { } /* end */
9237};
9238
Guido Günther3e1647c2009-06-05 00:47:26 +02009239static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9240 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9241 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9242 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009244 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9246 { } /* end */
9247};
9248
Kailang Yange2757d52008-08-26 13:17:46 +02009249static struct hda_bind_ctls alc883_bind_cap_vol = {
9250 .ops = &snd_hda_bind_vol,
9251 .values = {
9252 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9253 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9254 0
9255 },
9256};
9257
9258static struct hda_bind_ctls alc883_bind_cap_switch = {
9259 .ops = &snd_hda_bind_sw,
9260 .values = {
9261 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9262 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9263 0
9264 },
9265};
9266
9267static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9268 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9269 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9270 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9271 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9272 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9273 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009274 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009275 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009276 { } /* end */
9277};
9278
9279static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009280 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9281 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9282 {
9283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9284 /* .name = "Capture Source", */
9285 .name = "Input Source",
9286 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009287 .info = alc_mux_enum_info,
9288 .get = alc_mux_enum_get,
9289 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009290 },
9291 { } /* end */
9292};
9293
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009294static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9295 {
9296 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9297 .name = "Channel Mode",
9298 .info = alc_ch_mode_info,
9299 .get = alc_ch_mode_get,
9300 .put = alc_ch_mode_put,
9301 },
9302 { } /* end */
9303};
9304
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009305/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009306static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009307{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009308 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009309
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009310 spec->autocfg.hp_pins[0] = 0x15;
9311 spec->autocfg.speaker_pins[0] = 0x14;
9312 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009313}
9314
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009315static struct hda_verb alc883_mitac_verbs[] = {
9316 /* HP */
9317 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9319 /* Subwoofer */
9320 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9321 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9322
9323 /* enable unsolicited event */
9324 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9325 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9326
9327 { } /* end */
9328};
9329
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309330static struct hda_verb alc883_clevo_m540r_verbs[] = {
9331 /* HP */
9332 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9333 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9334 /* Int speaker */
9335 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9336
9337 /* enable unsolicited event */
9338 /*
9339 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9340 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9341 */
9342
9343 { } /* end */
9344};
9345
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009346static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009347 /* HP */
9348 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9349 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9350 /* Int speaker */
9351 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9353
9354 /* enable unsolicited event */
9355 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009356 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009357
9358 { } /* end */
9359};
9360
Jiang zhefb97dc62008-03-06 11:07:11 +01009361static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9362 /* HP */
9363 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9365 /* Subwoofer */
9366 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9368
9369 /* enable unsolicited event */
9370 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9371
9372 { } /* end */
9373};
9374
Sasha Alexandrc2592492009-06-16 14:52:54 -04009375static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9378
9379 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009381
David Heidelberger64a8be72009-06-08 16:15:18 +02009382/* Connect Line-Out side jack (SPDIF) to Side */
9383 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9384 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9385 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9386/* Connect Mic jack to CLFE */
9387 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9388 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9389 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9390/* Connect Line-in jack to Surround */
9391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9393 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9394/* Connect HP out jack to Front */
9395 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9396 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9397 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009398
9399 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009400
9401 { } /* end */
9402};
9403
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009404static struct hda_verb alc883_lenovo_101e_verbs[] = {
9405 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9406 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9407 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9408 { } /* end */
9409};
9410
Kailang Yang272a5272007-05-14 11:00:38 +02009411static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9412 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9414 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9416 { } /* end */
9417};
9418
9419static struct hda_verb alc888_lenovo_ms7195_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 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9423 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9424 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9425 { } /* end */
9426};
9427
Kailang Yang189609a2007-08-20 11:31:23 +02009428static struct hda_verb alc883_haier_w66_verbs[] = {
9429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9431
9432 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9433
9434 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9435 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9436 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9437 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9438 { } /* end */
9439};
9440
Kailang Yange2757d52008-08-26 13:17:46 +02009441static struct hda_verb alc888_lenovo_sky_verbs[] = {
9442 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9443 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9444 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9446 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9447 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9448 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9449 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9450 { } /* end */
9451};
9452
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009453static struct hda_verb alc888_6st_dell_verbs[] = {
9454 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9455 { }
9456};
9457
Guido Günther3e1647c2009-06-05 00:47:26 +02009458static struct hda_verb alc883_vaiott_verbs[] = {
9459 /* HP */
9460 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9462
9463 /* enable unsolicited event */
9464 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9465
9466 { } /* end */
9467};
9468
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009469static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009470{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009471 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009472
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009473 spec->autocfg.hp_pins[0] = 0x1b;
9474 spec->autocfg.speaker_pins[0] = 0x14;
9475 spec->autocfg.speaker_pins[1] = 0x16;
9476 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009477}
9478
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009479static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009480 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009481 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9482 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009483 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009484 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009485};
9486
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009487/*
9488 * 2ch mode
9489 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009490static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009491 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9492 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9493 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9494 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009495 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009496};
9497
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009498/*
9499 * 4ch mode
9500 */
9501static struct hda_verb alc888_3st_hp_4ch_init[] = {
9502 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9503 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9504 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9505 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9506 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9507 { } /* end */
9508};
9509
9510/*
9511 * 6ch mode
9512 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009513static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009514 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9515 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009516 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009517 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9518 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009519 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9520 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009521};
9522
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009523static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009524 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009525 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009526 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009527};
9528
Kailang Yang272a5272007-05-14 11:00:38 +02009529/* toggle front-jack and RCA according to the hp-jack state */
9530static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9531{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009532 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009533
Takashi Iwai47fd8302007-08-10 17:11:07 +02009534 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9535 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9536 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9537 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009538}
9539
9540/* toggle RCA according to the front-jack state */
9541static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9542{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009543 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009544
Takashi Iwai47fd8302007-08-10 17:11:07 +02009545 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9546 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009547}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009548
Kailang Yang272a5272007-05-14 11:00:38 +02009549static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9550 unsigned int res)
9551{
9552 if ((res >> 26) == ALC880_HP_EVENT)
9553 alc888_lenovo_ms7195_front_automute(codec);
9554 if ((res >> 26) == ALC880_FRONT_EVENT)
9555 alc888_lenovo_ms7195_rca_automute(codec);
9556}
9557
Kailang Yang272a5272007-05-14 11:00:38 +02009558/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009559static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009560{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009561 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009562
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009563 spec->autocfg.hp_pins[0] = 0x14;
9564 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009565}
9566
Kailang Yangccc656c2006-10-17 12:32:26 +02009567/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009568#define alc883_targa_init_hook alc882_targa_init_hook
9569#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009570
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009571static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009572{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009573 struct alc_spec *spec = codec->spec;
9574
9575 spec->autocfg.hp_pins[0] = 0x15;
9576 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009577}
9578
9579static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9580{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009581 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009582 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009583}
9584
9585static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009586 unsigned int res)
9587{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009588 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009589 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009590 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009591 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009592 default:
9593 alc_automute_amp_unsol_event(codec, res);
9594 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009595 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009596}
9597
Jiang zhefb97dc62008-03-06 11:07:11 +01009598/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009599static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009600{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009601 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009602
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009603 spec->autocfg.hp_pins[0] = 0x14;
9604 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009605}
9606
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009607static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009608{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009609 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009610
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009611 spec->autocfg.hp_pins[0] = 0x1b;
9612 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009613}
9614
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009615static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9616{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009617 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009618
Takashi Iwai47fd8302007-08-10 17:11:07 +02009619 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9620 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009621}
9622
9623static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9624{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009625 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009626
Takashi Iwai47fd8302007-08-10 17:11:07 +02009627 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9628 HDA_AMP_MUTE, bits);
9629 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9630 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009631}
9632
9633static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9634 unsigned int res)
9635{
9636 if ((res >> 26) == ALC880_HP_EVENT)
9637 alc883_lenovo_101e_all_automute(codec);
9638 if ((res >> 26) == ALC880_FRONT_EVENT)
9639 alc883_lenovo_101e_ispeaker_automute(codec);
9640}
9641
Takashi Iwai676a9b52007-08-16 15:23:35 +02009642/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009643static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009644{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009645 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009646
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009647 spec->autocfg.hp_pins[0] = 0x14;
9648 spec->autocfg.speaker_pins[0] = 0x15;
9649 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009650}
9651
Kailang Yangd1a991a2007-08-15 16:21:59 +02009652static struct hda_verb alc883_acer_eapd_verbs[] = {
9653 /* HP Pin: output 0 (0x0c) */
9654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9656 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9657 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9659 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009660 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009661 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9662 /* eanable EAPD on medion laptop */
9663 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9664 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009665 /* enable unsolicited event */
9666 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009667 { }
9668};
9669
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009670static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009671{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009672 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009673
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009674 spec->autocfg.hp_pins[0] = 0x1b;
9675 spec->autocfg.speaker_pins[0] = 0x14;
9676 spec->autocfg.speaker_pins[1] = 0x15;
9677 spec->autocfg.speaker_pins[2] = 0x16;
9678 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009679}
9680
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009681static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009682{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009683 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009684
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009685 spec->autocfg.hp_pins[0] = 0x1b;
9686 spec->autocfg.speaker_pins[0] = 0x14;
9687 spec->autocfg.speaker_pins[1] = 0x15;
9688 spec->autocfg.speaker_pins[2] = 0x16;
9689 spec->autocfg.speaker_pins[3] = 0x17;
9690 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009691}
9692
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009693static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009694{
9695 struct alc_spec *spec = codec->spec;
9696
9697 spec->autocfg.hp_pins[0] = 0x15;
9698 spec->autocfg.speaker_pins[0] = 0x14;
9699 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009700}
9701
Kailang Yange2757d52008-08-26 13:17:46 +02009702static struct hda_verb alc888_asus_m90v_verbs[] = {
9703 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9706 /* enable unsolicited event */
9707 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9708 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9709 { } /* end */
9710};
9711
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009712static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009713{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009714 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009715
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009716 spec->autocfg.hp_pins[0] = 0x1b;
9717 spec->autocfg.speaker_pins[0] = 0x14;
9718 spec->autocfg.speaker_pins[1] = 0x15;
9719 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009720 spec->ext_mic.pin = 0x18;
9721 spec->int_mic.pin = 0x19;
9722 spec->ext_mic.mux_idx = 0;
9723 spec->int_mic.mux_idx = 1;
9724 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009725}
9726
9727static struct hda_verb alc888_asus_eee1601_verbs[] = {
9728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9732 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9733 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9734 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9735 /* enable unsolicited event */
9736 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9737 { } /* end */
9738};
9739
Kailang Yange2757d52008-08-26 13:17:46 +02009740static void alc883_eee1601_inithook(struct hda_codec *codec)
9741{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009742 struct alc_spec *spec = codec->spec;
9743
9744 spec->autocfg.hp_pins[0] = 0x14;
9745 spec->autocfg.speaker_pins[0] = 0x1b;
9746 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009747}
9748
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009749static struct hda_verb alc889A_mb31_verbs[] = {
9750 /* Init rear pin (used as headphone output) */
9751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9753 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9754 /* Init line pin (used as output in 4ch and 6ch mode) */
9755 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9756 /* Init line 2 pin (used as headphone out by default) */
9757 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9758 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9759 { } /* end */
9760};
9761
9762/* Mute speakers according to the headphone jack state */
9763static void alc889A_mb31_automute(struct hda_codec *codec)
9764{
9765 unsigned int present;
9766
9767 /* Mute only in 2ch or 4ch mode */
9768 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9769 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009770 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009771 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9772 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9773 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9774 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9775 }
9776}
9777
9778static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9779{
9780 if ((res >> 26) == ALC880_HP_EVENT)
9781 alc889A_mb31_automute(codec);
9782}
9783
Takashi Iwai4953550a2009-06-30 15:28:30 +02009784
Takashi Iwaicb53c622007-08-10 17:21:45 +02009785#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009786#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009787#endif
9788
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009789/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009790#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9791#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9792#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9793#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9794
9795static hda_nid_t alc883_slave_dig_outs[] = {
9796 ALC1200_DIGOUT_NID, 0,
9797};
9798
9799static hda_nid_t alc1200_slave_dig_outs[] = {
9800 ALC883_DIGOUT_NID, 0,
9801};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009802
9803/*
9804 * configuration and preset
9805 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009806static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009807 [ALC882_3ST_DIG] = "3stack-dig",
9808 [ALC882_6ST_DIG] = "6stack-dig",
9809 [ALC882_ARIMA] = "arima",
9810 [ALC882_W2JC] = "w2jc",
9811 [ALC882_TARGA] = "targa",
9812 [ALC882_ASUS_A7J] = "asus-a7j",
9813 [ALC882_ASUS_A7M] = "asus-a7m",
9814 [ALC885_MACPRO] = "macpro",
9815 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009816 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009817 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009818 [ALC885_MBP3] = "mbp3",
9819 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009820 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009821 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009822 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9823 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009824 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009825 [ALC883_TARGA_DIG] = "targa-dig",
9826 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009827 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009828 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009829 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009830 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009831 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009832 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009833 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009834 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009835 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009836 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009837 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009838 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9839 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009840 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009841 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009842 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009843 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009844 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309845 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009846 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009847 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009848 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009849 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009850 [ALC889A_INTEL] = "intel-alc889a",
9851 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009852 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009853 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009854 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009855 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009856};
9857
Takashi Iwai4953550a2009-06-30 15:28:30 +02009858static struct snd_pci_quirk alc882_cfg_tbl[] = {
9859 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9860
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009861 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009862 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009863 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009864 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9865 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009866 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009867 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9868 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009869 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009870 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009871 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9872 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009873 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9874 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009875 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9876 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009877 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009878 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009879 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009880 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009881 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9882 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009883 /* default Acer -- disabled as it causes more problems.
9884 * model=auto should work fine now
9885 */
9886 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009887
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009888 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009889
Tobin Davisfebe3372007-06-12 11:27:46 +02009890 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009891 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9892 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009893 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009894 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009895 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009896
9897 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9898 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9899 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009900 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009901 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9902 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9903 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009904 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009905 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009906 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009907 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009908
9909 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009910 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009911 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009912 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009913 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9914 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009915 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009916 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009917 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9918
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009919 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9920 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9921 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009922 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009923 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009924 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009925 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009926 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009927 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9928 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9929 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9930 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9931 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9932 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009933 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009934 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9935 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9936 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009937 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009938 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009939 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9940 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009941 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009942 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009943 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009944 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009945 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009946 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009947 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009948 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009949 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009950
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009951 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009952 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009953 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9954 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309955 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009956 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009957 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009958 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009959 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009960 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009961 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009962 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009963 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009964 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009965 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009966 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9967 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009968 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009969 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009970 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009971 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009972
Jiang zhe17bba1b2008-06-04 12:11:07 +02009973 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9974 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009975 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009976 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9977 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9978 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009979 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009980
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009981 {}
9982};
9983
Takashi Iwai4953550a2009-06-30 15:28:30 +02009984/* codec SSID table for Intel Mac */
9985static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9986 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9987 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9988 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9989 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9990 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9991 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9992 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009993 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009994 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009995 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009996 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009997 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9998 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9999 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010000 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010001 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +100010002 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010003 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
10004 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +020010005 */
10006 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010007 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010008 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010009 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010010};
10011
Takashi Iwai4953550a2009-06-30 15:28:30 +020010012static struct alc_config_preset alc882_presets[] = {
10013 [ALC882_3ST_DIG] = {
10014 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010015 .init_verbs = { alc882_base_init_verbs,
10016 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010017 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10018 .dac_nids = alc882_dac_nids,
10019 .dig_out_nid = ALC882_DIGOUT_NID,
10020 .dig_in_nid = ALC882_DIGIN_NID,
10021 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10022 .channel_mode = alc882_ch_modes,
10023 .need_dac_fix = 1,
10024 .input_mux = &alc882_capture_source,
10025 },
10026 [ALC882_6ST_DIG] = {
10027 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010028 .init_verbs = { alc882_base_init_verbs,
10029 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010030 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10031 .dac_nids = alc882_dac_nids,
10032 .dig_out_nid = ALC882_DIGOUT_NID,
10033 .dig_in_nid = ALC882_DIGIN_NID,
10034 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10035 .channel_mode = alc882_sixstack_modes,
10036 .input_mux = &alc882_capture_source,
10037 },
10038 [ALC882_ARIMA] = {
10039 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010040 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10041 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010042 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10043 .dac_nids = alc882_dac_nids,
10044 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10045 .channel_mode = alc882_sixstack_modes,
10046 .input_mux = &alc882_capture_source,
10047 },
10048 [ALC882_W2JC] = {
10049 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010050 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10051 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010052 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10053 .dac_nids = alc882_dac_nids,
10054 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10055 .channel_mode = alc880_threestack_modes,
10056 .need_dac_fix = 1,
10057 .input_mux = &alc882_capture_source,
10058 .dig_out_nid = ALC882_DIGOUT_NID,
10059 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010060 [ALC885_MBA21] = {
10061 .mixers = { alc885_mba21_mixer },
10062 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
10063 .num_dacs = 2,
10064 .dac_nids = alc882_dac_nids,
10065 .channel_mode = alc885_mba21_ch_modes,
10066 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10067 .input_mux = &alc882_capture_source,
10068 .unsol_event = alc_automute_amp_unsol_event,
10069 .setup = alc885_mba21_setup,
10070 .init_hook = alc_automute_amp,
10071 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010072 [ALC885_MBP3] = {
10073 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10074 .init_verbs = { alc885_mbp3_init_verbs,
10075 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010076 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010077 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010078 .hp_nid = 0x04,
10079 .channel_mode = alc885_mbp_4ch_modes,
10080 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010081 .input_mux = &alc882_capture_source,
10082 .dig_out_nid = ALC882_DIGOUT_NID,
10083 .dig_in_nid = ALC882_DIGIN_NID,
10084 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010085 .setup = alc885_mbp3_setup,
10086 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010087 },
10088 [ALC885_MB5] = {
10089 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10090 .init_verbs = { alc885_mb5_init_verbs,
10091 alc880_gpio1_init_verbs },
10092 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10093 .dac_nids = alc882_dac_nids,
10094 .channel_mode = alc885_mb5_6ch_modes,
10095 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10096 .input_mux = &mb5_capture_source,
10097 .dig_out_nid = ALC882_DIGOUT_NID,
10098 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010099 .unsol_event = alc_automute_amp_unsol_event,
10100 .setup = alc885_mb5_setup,
10101 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010102 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010103 [ALC885_MACMINI3] = {
10104 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10105 .init_verbs = { alc885_macmini3_init_verbs,
10106 alc880_gpio1_init_verbs },
10107 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10108 .dac_nids = alc882_dac_nids,
10109 .channel_mode = alc885_macmini3_6ch_modes,
10110 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10111 .input_mux = &macmini3_capture_source,
10112 .dig_out_nid = ALC882_DIGOUT_NID,
10113 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010114 .unsol_event = alc_automute_amp_unsol_event,
10115 .setup = alc885_macmini3_setup,
10116 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010117 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010118 [ALC885_MACPRO] = {
10119 .mixers = { alc882_macpro_mixer },
10120 .init_verbs = { alc882_macpro_init_verbs },
10121 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10122 .dac_nids = alc882_dac_nids,
10123 .dig_out_nid = ALC882_DIGOUT_NID,
10124 .dig_in_nid = ALC882_DIGIN_NID,
10125 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10126 .channel_mode = alc882_ch_modes,
10127 .input_mux = &alc882_capture_source,
10128 .init_hook = alc885_macpro_init_hook,
10129 },
10130 [ALC885_IMAC24] = {
10131 .mixers = { alc885_imac24_mixer },
10132 .init_verbs = { alc885_imac24_init_verbs },
10133 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10134 .dac_nids = alc882_dac_nids,
10135 .dig_out_nid = ALC882_DIGOUT_NID,
10136 .dig_in_nid = ALC882_DIGIN_NID,
10137 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10138 .channel_mode = alc882_ch_modes,
10139 .input_mux = &alc882_capture_source,
10140 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010141 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010142 .init_hook = alc885_imac24_init_hook,
10143 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010144 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010145 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010146 .init_verbs = { alc885_imac91_init_verbs,
10147 alc880_gpio1_init_verbs },
10148 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10149 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010150 .channel_mode = alc885_mba21_ch_modes,
10151 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10152 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010153 .dig_out_nid = ALC882_DIGOUT_NID,
10154 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010155 .unsol_event = alc_automute_amp_unsol_event,
10156 .setup = alc885_imac91_setup,
10157 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010158 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010159 [ALC882_TARGA] = {
10160 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010161 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010162 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010163 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10164 .dac_nids = alc882_dac_nids,
10165 .dig_out_nid = ALC882_DIGOUT_NID,
10166 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10167 .adc_nids = alc882_adc_nids,
10168 .capsrc_nids = alc882_capsrc_nids,
10169 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10170 .channel_mode = alc882_3ST_6ch_modes,
10171 .need_dac_fix = 1,
10172 .input_mux = &alc882_capture_source,
10173 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010174 .setup = alc882_targa_setup,
10175 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010176 },
10177 [ALC882_ASUS_A7J] = {
10178 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010179 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10180 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010181 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10182 .dac_nids = alc882_dac_nids,
10183 .dig_out_nid = ALC882_DIGOUT_NID,
10184 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10185 .adc_nids = alc882_adc_nids,
10186 .capsrc_nids = alc882_capsrc_nids,
10187 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10188 .channel_mode = alc882_3ST_6ch_modes,
10189 .need_dac_fix = 1,
10190 .input_mux = &alc882_capture_source,
10191 },
10192 [ALC882_ASUS_A7M] = {
10193 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010194 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10195 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010196 alc882_asus_a7m_verbs },
10197 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10198 .dac_nids = alc882_dac_nids,
10199 .dig_out_nid = ALC882_DIGOUT_NID,
10200 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10201 .channel_mode = alc880_threestack_modes,
10202 .need_dac_fix = 1,
10203 .input_mux = &alc882_capture_source,
10204 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010205 [ALC883_3ST_2ch_DIG] = {
10206 .mixers = { alc883_3ST_2ch_mixer },
10207 .init_verbs = { alc883_init_verbs },
10208 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10209 .dac_nids = alc883_dac_nids,
10210 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010211 .dig_in_nid = ALC883_DIGIN_NID,
10212 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10213 .channel_mode = alc883_3ST_2ch_modes,
10214 .input_mux = &alc883_capture_source,
10215 },
10216 [ALC883_3ST_6ch_DIG] = {
10217 .mixers = { alc883_3ST_6ch_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,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010222 .dig_in_nid = ALC883_DIGIN_NID,
10223 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10224 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010225 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010226 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010227 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010228 [ALC883_3ST_6ch] = {
10229 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10230 .init_verbs = { alc883_init_verbs },
10231 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10232 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010233 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10234 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010235 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010236 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010237 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010238 [ALC883_3ST_6ch_INTEL] = {
10239 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10240 .init_verbs = { alc883_init_verbs },
10241 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10242 .dac_nids = alc883_dac_nids,
10243 .dig_out_nid = ALC883_DIGOUT_NID,
10244 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010245 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010246 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10247 .channel_mode = alc883_3ST_6ch_intel_modes,
10248 .need_dac_fix = 1,
10249 .input_mux = &alc883_3stack_6ch_intel,
10250 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010251 [ALC889A_INTEL] = {
10252 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010253 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10254 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10256 .dac_nids = alc883_dac_nids,
10257 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10258 .adc_nids = alc889_adc_nids,
10259 .dig_out_nid = ALC883_DIGOUT_NID,
10260 .dig_in_nid = ALC883_DIGIN_NID,
10261 .slave_dig_outs = alc883_slave_dig_outs,
10262 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10263 .channel_mode = alc889_8ch_intel_modes,
10264 .capsrc_nids = alc889_capsrc_nids,
10265 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010266 .setup = alc889_automute_setup,
10267 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010268 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010269 .need_dac_fix = 1,
10270 },
10271 [ALC889_INTEL] = {
10272 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10273 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010274 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010275 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10276 .dac_nids = alc883_dac_nids,
10277 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10278 .adc_nids = alc889_adc_nids,
10279 .dig_out_nid = ALC883_DIGOUT_NID,
10280 .dig_in_nid = ALC883_DIGIN_NID,
10281 .slave_dig_outs = alc883_slave_dig_outs,
10282 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10283 .channel_mode = alc889_8ch_intel_modes,
10284 .capsrc_nids = alc889_capsrc_nids,
10285 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010286 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010287 .init_hook = alc889_intel_init_hook,
10288 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010289 .need_dac_fix = 1,
10290 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010291 [ALC883_6ST_DIG] = {
10292 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10293 .init_verbs = { alc883_init_verbs },
10294 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10295 .dac_nids = alc883_dac_nids,
10296 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010297 .dig_in_nid = ALC883_DIGIN_NID,
10298 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10299 .channel_mode = alc883_sixstack_modes,
10300 .input_mux = &alc883_capture_source,
10301 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010302 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010303 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010304 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10305 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010306 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10307 .dac_nids = alc883_dac_nids,
10308 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010309 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10310 .channel_mode = alc883_3ST_6ch_modes,
10311 .need_dac_fix = 1,
10312 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010313 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010314 .setup = alc882_targa_setup,
10315 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010316 },
10317 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010318 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010319 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10320 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010321 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10322 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010323 .adc_nids = alc883_adc_nids_alt,
10324 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010325 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010326 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010327 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10328 .channel_mode = alc883_3ST_2ch_modes,
10329 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010330 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010331 .setup = alc882_targa_setup,
10332 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010333 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010334 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010335 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10336 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010337 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010338 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010339 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10340 .dac_nids = alc883_dac_nids,
10341 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10342 .adc_nids = alc883_adc_nids_rev,
10343 .capsrc_nids = alc883_capsrc_nids_rev,
10344 .dig_out_nid = ALC883_DIGOUT_NID,
10345 .dig_in_nid = ALC883_DIGIN_NID,
10346 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10347 .channel_mode = alc883_4ST_8ch_modes,
10348 .need_dac_fix = 1,
10349 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010350 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010351 .setup = alc882_targa_setup,
10352 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010353 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010354 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010355 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010356 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10357 * and the headphone jack. Turn this on and rely on the
10358 * standard mute methods whenever the user wants to turn
10359 * these outputs off.
10360 */
10361 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10362 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10363 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010364 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10365 .channel_mode = alc883_3ST_2ch_modes,
10366 .input_mux = &alc883_capture_source,
10367 },
Tobin Davis2880a862007-08-07 11:50:26 +020010368 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010369 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010370 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010371 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10372 .dac_nids = alc883_dac_nids,
10373 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010374 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10375 .channel_mode = alc883_3ST_2ch_modes,
10376 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010377 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010378 .setup = alc883_acer_aspire_setup,
10379 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010380 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010381 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010382 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010383 alc883_chmode_mixer },
10384 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10385 alc888_acer_aspire_4930g_verbs },
10386 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10387 .dac_nids = alc883_dac_nids,
10388 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10389 .adc_nids = alc883_adc_nids_rev,
10390 .capsrc_nids = alc883_capsrc_nids_rev,
10391 .dig_out_nid = ALC883_DIGOUT_NID,
10392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10393 .channel_mode = alc883_3ST_6ch_modes,
10394 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010395 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010396 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010397 ARRAY_SIZE(alc888_2_capture_sources),
10398 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010399 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010400 .setup = alc888_acer_aspire_4930g_setup,
10401 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010402 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010403 [ALC888_ACER_ASPIRE_6530G] = {
10404 .mixers = { alc888_acer_aspire_6530_mixer },
10405 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10406 alc888_acer_aspire_6530g_verbs },
10407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10408 .dac_nids = alc883_dac_nids,
10409 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10410 .adc_nids = alc883_adc_nids_rev,
10411 .capsrc_nids = alc883_capsrc_nids_rev,
10412 .dig_out_nid = ALC883_DIGOUT_NID,
10413 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10414 .channel_mode = alc883_3ST_2ch_modes,
10415 .num_mux_defs =
10416 ARRAY_SIZE(alc888_2_capture_sources),
10417 .input_mux = alc888_acer_aspire_6530_sources,
10418 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010419 .setup = alc888_acer_aspire_6530g_setup,
10420 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010421 },
Hector Martin3b315d72009-06-02 10:54:19 +020010422 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010423 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010424 alc883_chmode_mixer },
10425 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010426 alc889_acer_aspire_8930g_verbs,
10427 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010428 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10429 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010430 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10431 .adc_nids = alc889_adc_nids,
10432 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010433 .dig_out_nid = ALC883_DIGOUT_NID,
10434 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10435 .channel_mode = alc883_3ST_6ch_modes,
10436 .need_dac_fix = 1,
10437 .const_channel_count = 6,
10438 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010439 ARRAY_SIZE(alc889_capture_sources),
10440 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010441 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010442 .setup = alc889_acer_aspire_8930g_setup,
10443 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010444#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010445 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010446#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010447 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010448 [ALC888_ACER_ASPIRE_7730G] = {
10449 .mixers = { alc883_3ST_6ch_mixer,
10450 alc883_chmode_mixer },
10451 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10452 alc888_acer_aspire_7730G_verbs },
10453 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10454 .dac_nids = alc883_dac_nids,
10455 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10456 .adc_nids = alc883_adc_nids_rev,
10457 .capsrc_nids = alc883_capsrc_nids_rev,
10458 .dig_out_nid = ALC883_DIGOUT_NID,
10459 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10460 .channel_mode = alc883_3ST_6ch_modes,
10461 .need_dac_fix = 1,
10462 .const_channel_count = 6,
10463 .input_mux = &alc883_capture_source,
10464 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010465 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010466 .init_hook = alc_automute_amp,
10467 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010468 [ALC883_MEDION] = {
10469 .mixers = { alc883_fivestack_mixer,
10470 alc883_chmode_mixer },
10471 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010472 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010473 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10474 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010475 .adc_nids = alc883_adc_nids_alt,
10476 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010477 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010478 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10479 .channel_mode = alc883_sixstack_modes,
10480 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010481 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010482 [ALC883_MEDION_WIM2160] = {
10483 .mixers = { alc883_medion_wim2160_mixer },
10484 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10485 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10486 .dac_nids = alc883_dac_nids,
10487 .dig_out_nid = ALC883_DIGOUT_NID,
10488 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10489 .adc_nids = alc883_adc_nids,
10490 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10491 .channel_mode = alc883_3ST_2ch_modes,
10492 .input_mux = &alc883_capture_source,
10493 .unsol_event = alc_automute_amp_unsol_event,
10494 .setup = alc883_medion_wim2160_setup,
10495 .init_hook = alc_automute_amp,
10496 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010497 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010498 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010499 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10500 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10501 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010502 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10503 .channel_mode = alc883_3ST_2ch_modes,
10504 .input_mux = &alc883_capture_source,
10505 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010506 [ALC883_CLEVO_M540R] = {
10507 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10508 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10510 .dac_nids = alc883_dac_nids,
10511 .dig_out_nid = ALC883_DIGOUT_NID,
10512 .dig_in_nid = ALC883_DIGIN_NID,
10513 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10514 .channel_mode = alc883_3ST_6ch_clevo_modes,
10515 .need_dac_fix = 1,
10516 .input_mux = &alc883_capture_source,
10517 /* This machine has the hardware HP auto-muting, thus
10518 * we need no software mute via unsol event
10519 */
10520 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010521 [ALC883_CLEVO_M720] = {
10522 .mixers = { alc883_clevo_m720_mixer },
10523 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010524 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10525 .dac_nids = alc883_dac_nids,
10526 .dig_out_nid = ALC883_DIGOUT_NID,
10527 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10528 .channel_mode = alc883_3ST_2ch_modes,
10529 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010530 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010531 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010532 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010533 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010534 [ALC883_LENOVO_101E_2ch] = {
10535 .mixers = { alc883_lenovo_101e_2ch_mixer},
10536 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10538 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010539 .adc_nids = alc883_adc_nids_alt,
10540 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010541 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010542 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10543 .channel_mode = alc883_3ST_2ch_modes,
10544 .input_mux = &alc883_lenovo_101e_capture_source,
10545 .unsol_event = alc883_lenovo_101e_unsol_event,
10546 .init_hook = alc883_lenovo_101e_all_automute,
10547 },
Kailang Yang272a5272007-05-14 11:00:38 +020010548 [ALC883_LENOVO_NB0763] = {
10549 .mixers = { alc883_lenovo_nb0763_mixer },
10550 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10552 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10554 .channel_mode = alc883_3ST_2ch_modes,
10555 .need_dac_fix = 1,
10556 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010557 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010558 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010559 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010560 },
10561 [ALC888_LENOVO_MS7195_DIG] = {
10562 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10563 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10564 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10565 .dac_nids = alc883_dac_nids,
10566 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010567 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10568 .channel_mode = alc883_3ST_6ch_modes,
10569 .need_dac_fix = 1,
10570 .input_mux = &alc883_capture_source,
10571 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10572 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010573 },
10574 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010575 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010576 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10577 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10578 .dac_nids = alc883_dac_nids,
10579 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10581 .channel_mode = alc883_3ST_2ch_modes,
10582 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010583 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010584 .setup = alc883_haier_w66_setup,
10585 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010586 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010587 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010588 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010589 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010590 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10591 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010592 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10593 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010594 .need_dac_fix = 1,
10595 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010596 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010597 .setup = alc888_3st_hp_setup,
10598 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010599 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010600 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010601 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010602 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10603 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10604 .dac_nids = alc883_dac_nids,
10605 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010606 .dig_in_nid = ALC883_DIGIN_NID,
10607 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10608 .channel_mode = alc883_sixstack_modes,
10609 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010610 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010611 .setup = alc888_6st_dell_setup,
10612 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010613 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010614 [ALC883_MITAC] = {
10615 .mixers = { alc883_mitac_mixer },
10616 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10617 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10618 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010619 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10620 .channel_mode = alc883_3ST_2ch_modes,
10621 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010622 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010623 .setup = alc883_mitac_setup,
10624 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010625 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010626 [ALC883_FUJITSU_PI2515] = {
10627 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10628 .init_verbs = { alc883_init_verbs,
10629 alc883_2ch_fujitsu_pi2515_verbs},
10630 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10631 .dac_nids = alc883_dac_nids,
10632 .dig_out_nid = ALC883_DIGOUT_NID,
10633 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10634 .channel_mode = alc883_3ST_2ch_modes,
10635 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010636 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010637 .setup = alc883_2ch_fujitsu_pi2515_setup,
10638 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010639 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010640 [ALC888_FUJITSU_XA3530] = {
10641 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10642 .init_verbs = { alc883_init_verbs,
10643 alc888_fujitsu_xa3530_verbs },
10644 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10645 .dac_nids = alc883_dac_nids,
10646 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10647 .adc_nids = alc883_adc_nids_rev,
10648 .capsrc_nids = alc883_capsrc_nids_rev,
10649 .dig_out_nid = ALC883_DIGOUT_NID,
10650 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10651 .channel_mode = alc888_4ST_8ch_intel_modes,
10652 .num_mux_defs =
10653 ARRAY_SIZE(alc888_2_capture_sources),
10654 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010655 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010656 .setup = alc888_fujitsu_xa3530_setup,
10657 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010658 },
Kailang Yange2757d52008-08-26 13:17:46 +020010659 [ALC888_LENOVO_SKY] = {
10660 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10661 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10662 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10663 .dac_nids = alc883_dac_nids,
10664 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010665 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10666 .channel_mode = alc883_sixstack_modes,
10667 .need_dac_fix = 1,
10668 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010669 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010670 .setup = alc888_lenovo_sky_setup,
10671 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010672 },
10673 [ALC888_ASUS_M90V] = {
10674 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10675 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10676 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10677 .dac_nids = alc883_dac_nids,
10678 .dig_out_nid = ALC883_DIGOUT_NID,
10679 .dig_in_nid = ALC883_DIGIN_NID,
10680 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10681 .channel_mode = alc883_3ST_6ch_modes,
10682 .need_dac_fix = 1,
10683 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010684 .unsol_event = alc_sku_unsol_event,
10685 .setup = alc883_mode2_setup,
10686 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010687 },
10688 [ALC888_ASUS_EEE1601] = {
10689 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010690 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010691 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10692 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10693 .dac_nids = alc883_dac_nids,
10694 .dig_out_nid = ALC883_DIGOUT_NID,
10695 .dig_in_nid = ALC883_DIGIN_NID,
10696 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10697 .channel_mode = alc883_3ST_2ch_modes,
10698 .need_dac_fix = 1,
10699 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010700 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010701 .init_hook = alc883_eee1601_inithook,
10702 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010703 [ALC1200_ASUS_P5Q] = {
10704 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10705 .init_verbs = { alc883_init_verbs },
10706 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10707 .dac_nids = alc883_dac_nids,
10708 .dig_out_nid = ALC1200_DIGOUT_NID,
10709 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010710 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010711 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10712 .channel_mode = alc883_sixstack_modes,
10713 .input_mux = &alc883_capture_source,
10714 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010715 [ALC889A_MB31] = {
10716 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10717 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10718 alc880_gpio1_init_verbs },
10719 .adc_nids = alc883_adc_nids,
10720 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010721 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010722 .dac_nids = alc883_dac_nids,
10723 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10724 .channel_mode = alc889A_mb31_6ch_modes,
10725 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10726 .input_mux = &alc889A_mb31_capture_source,
10727 .dig_out_nid = ALC883_DIGOUT_NID,
10728 .unsol_event = alc889A_mb31_unsol_event,
10729 .init_hook = alc889A_mb31_automute,
10730 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010731 [ALC883_SONY_VAIO_TT] = {
10732 .mixers = { alc883_vaiott_mixer },
10733 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10734 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10735 .dac_nids = alc883_dac_nids,
10736 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10737 .channel_mode = alc883_3ST_2ch_modes,
10738 .input_mux = &alc883_capture_source,
10739 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010740 .setup = alc883_vaiott_setup,
10741 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010742 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010743};
10744
10745
10746/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010747 * Pin config fixes
10748 */
10749enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010750 PINFIX_ABIT_AW9D_MAX,
10751 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010752 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010753};
10754
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010755static const struct alc_fixup alc882_fixups[] = {
10756 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010757 .type = ALC_FIXUP_PINS,
10758 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010759 { 0x15, 0x01080104 }, /* side */
10760 { 0x16, 0x01011012 }, /* rear */
10761 { 0x17, 0x01016011 }, /* clfe */
10762 { }
10763 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010764 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010765 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010766 .type = ALC_FIXUP_VERBS,
10767 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010768 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10769 {}
10770 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010771 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010772 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010773 .type = ALC_FIXUP_SKU,
10774 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010775 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010776};
10777
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010778static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010779 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010780 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010781 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010782 {}
10783};
10784
10785/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010786 * BIOS auto configuration
10787 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010788static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10789 const struct auto_pin_cfg *cfg)
10790{
10791 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10792}
10793
Takashi Iwai4953550a2009-06-30 15:28:30 +020010794static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010795 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010796 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010797{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010798 int idx;
10799
Takashi Iwai489008c2010-04-07 09:06:00 +020010800 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010801 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010802
Takashi Iwai489008c2010-04-07 09:06:00 +020010803 if (dac == 0x25)
10804 idx = 4;
10805 else if (dac >= 0x02 && dac <= 0x05)
10806 idx = dac - 2;
10807 else
10808 return;
10809 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010810}
10811
Takashi Iwai4953550a2009-06-30 15:28:30 +020010812static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010813{
10814 struct alc_spec *spec = codec->spec;
10815 int i;
10816
10817 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010818 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010819 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010820 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010821 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010822 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010823 }
10824}
10825
Takashi Iwai4953550a2009-06-30 15:28:30 +020010826static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010827{
10828 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010829 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010830 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010831
Takashi Iwai5855fb82010-09-16 18:24:02 +020010832 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10833 pin = spec->autocfg.hp_pins[i];
10834 if (!pin)
10835 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010836 dac = spec->multiout.hp_nid;
10837 if (!dac)
10838 dac = spec->multiout.dac_nids[0]; /* to front */
10839 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10840 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010841 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10842 pin = spec->autocfg.speaker_pins[i];
10843 if (!pin)
10844 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010845 dac = spec->multiout.extra_out_nid[0];
10846 if (!dac)
10847 dac = spec->multiout.dac_nids[0]; /* to front */
10848 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10849 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010850}
10851
Takashi Iwai4953550a2009-06-30 15:28:30 +020010852static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010853{
10854 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010855 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010856 int i;
10857
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010858 for (i = 0; i < cfg->num_inputs; i++) {
10859 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010860 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010861 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10862 snd_hda_codec_write(codec, nid, 0,
10863 AC_VERB_SET_AMP_GAIN_MUTE,
10864 AMP_OUT_MUTE);
10865 }
10866}
10867
10868static void alc882_auto_init_input_src(struct hda_codec *codec)
10869{
10870 struct alc_spec *spec = codec->spec;
10871 int c;
10872
10873 for (c = 0; c < spec->num_adc_nids; c++) {
10874 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10875 hda_nid_t nid = spec->capsrc_nids[c];
10876 unsigned int mux_idx;
10877 const struct hda_input_mux *imux;
10878 int conns, mute, idx, item;
10879
10880 conns = snd_hda_get_connections(codec, nid, conn_list,
10881 ARRAY_SIZE(conn_list));
10882 if (conns < 0)
10883 continue;
10884 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10885 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010886 if (!imux->num_items && mux_idx > 0)
10887 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010888 for (idx = 0; idx < conns; idx++) {
10889 /* if the current connection is the selected one,
10890 * unmute it as default - otherwise mute it
10891 */
10892 mute = AMP_IN_MUTE(idx);
10893 for (item = 0; item < imux->num_items; item++) {
10894 if (imux->items[item].index == idx) {
10895 if (spec->cur_mux[c] == item)
10896 mute = AMP_IN_UNMUTE(idx);
10897 break;
10898 }
10899 }
10900 /* check if we have a selector or mixer
10901 * we could check for the widget type instead, but
10902 * just check for Amp-In presence (in case of mixer
10903 * without amp-in there is something wrong, this
10904 * function shouldn't be used or capsrc nid is wrong)
10905 */
10906 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010907 snd_hda_codec_write(codec, nid, 0,
10908 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010909 mute);
10910 else if (mute != AMP_IN_MUTE(idx))
10911 snd_hda_codec_write(codec, nid, 0,
10912 AC_VERB_SET_CONNECT_SEL,
10913 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010914 }
10915 }
10916}
10917
Takashi Iwai4953550a2009-06-30 15:28:30 +020010918/* add mic boosts if needed */
10919static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010920{
10921 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010922 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010923 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010924 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010925 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010926 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010927
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010928 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010929 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010930 break;
10931 nid = cfg->inputs[i].pin;
10932 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010933 const char *label;
10934 char boost_label[32];
10935
10936 label = hda_get_autocfg_input_label(codec, cfg, i);
10937 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010938 type_idx++;
10939 else
10940 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010941 prev_label = label;
10942
10943 snprintf(boost_label, sizeof(boost_label),
10944 "%s Boost Volume", label);
10945 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10946 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010947 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010948 if (err < 0)
10949 return err;
10950 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010951 }
10952 return 0;
10953}
10954
10955/* almost identical with ALC880 parser... */
10956static int alc882_parse_auto_config(struct hda_codec *codec)
10957{
10958 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010959 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010960 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010961
Takashi Iwai05f5f472009-08-25 13:10:18 +020010962 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10963 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010964 if (err < 0)
10965 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010966 if (!spec->autocfg.line_outs)
10967 return 0; /* can't find valid BIOS pin config */
10968
10969 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10970 if (err < 0)
10971 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010010972 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010973 if (err < 0)
10974 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010975 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10976 "Headphone");
10977 if (err < 0)
10978 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010979 err = alc880_auto_create_extra_out(spec,
10980 spec->autocfg.speaker_pins[0],
10981 "Speaker");
10982 if (err < 0)
10983 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010984 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10985 if (err < 0)
10986 return err;
10987
10988 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10989
Takashi Iwai757899a2010-07-30 10:48:14 +020010990 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010991
10992 if (spec->kctls.list)
10993 add_mixer(spec, spec->kctls.list);
10994
10995 add_verb(spec, alc883_auto_init_verbs);
10996 /* if ADC 0x07 is available, initialize it, too */
10997 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10998 add_verb(spec, alc882_adc1_init_verbs);
10999
11000 spec->num_mux_defs = 1;
11001 spec->input_mux = &spec->private_imux[0];
11002
Kailang Yang6227cdc2010-02-25 08:36:52 +010011003 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020011004
11005 err = alc_auto_add_mic_boost(codec);
11006 if (err < 0)
11007 return err;
11008
Takashi Iwai776e1842007-08-29 15:07:11 +020011009 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011010}
11011
11012/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011013static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011014{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011015 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011016 alc882_auto_init_multi_out(codec);
11017 alc882_auto_init_hp_out(codec);
11018 alc882_auto_init_analog_input(codec);
11019 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020011020 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011021 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011022 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011023}
11024
Takashi Iwai4953550a2009-06-30 15:28:30 +020011025static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011026{
11027 struct alc_spec *spec;
11028 int err, board_config;
11029
11030 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11031 if (spec == NULL)
11032 return -ENOMEM;
11033
11034 codec->spec = spec;
11035
Takashi Iwai4953550a2009-06-30 15:28:30 +020011036 switch (codec->vendor_id) {
11037 case 0x10ec0882:
11038 case 0x10ec0885:
11039 break;
11040 default:
11041 /* ALC883 and variants */
11042 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11043 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011044 }
11045
Takashi Iwai4953550a2009-06-30 15:28:30 +020011046 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
11047 alc882_models,
11048 alc882_cfg_tbl);
11049
11050 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
11051 board_config = snd_hda_check_board_codec_sid_config(codec,
11052 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
11053
11054 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011055 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011056 codec->chip_name);
11057 board_config = ALC882_AUTO;
11058 }
11059
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011060 if (board_config == ALC882_AUTO) {
11061 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11062 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11063 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011064
David Henningsson90622912010-10-14 14:50:18 +020011065 alc_auto_parse_customize_define(codec);
11066
Takashi Iwai4953550a2009-06-30 15:28:30 +020011067 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011068 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011069 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011070 if (err < 0) {
11071 alc_free(codec);
11072 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011073 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011074 printk(KERN_INFO
11075 "hda_codec: Cannot set up configuration "
11076 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011077 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011078 }
11079 }
11080
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011081 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011082 err = snd_hda_attach_beep_device(codec, 0x1);
11083 if (err < 0) {
11084 alc_free(codec);
11085 return err;
11086 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011087 }
11088
Takashi Iwai4953550a2009-06-30 15:28:30 +020011089 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011090 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011091
Takashi Iwai4953550a2009-06-30 15:28:30 +020011092 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11093 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11094 /* FIXME: setup DAC5 */
11095 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11096 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11097
11098 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11099 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11100
Takashi Iwai4953550a2009-06-30 15:28:30 +020011101 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011102 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011103 spec->num_adc_nids = 0;
11104 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011105 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011106 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011107 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011108 hda_nid_t nid = alc882_adc_nids[i];
11109 unsigned int wcap = get_wcaps(codec, nid);
11110 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011111 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011112 if (wcap != AC_WID_AUD_IN)
11113 continue;
11114 spec->private_adc_nids[spec->num_adc_nids] = nid;
11115 err = snd_hda_get_connections(codec, nid, &cap, 1);
11116 if (err < 0)
11117 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011118 err = snd_hda_get_connections(codec, cap, items,
11119 ARRAY_SIZE(items));
11120 if (err < 0)
11121 continue;
11122 for (j = 0; j < imux->num_items; j++)
11123 if (imux->items[j].index >= err)
11124 break;
11125 if (j < imux->num_items)
11126 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011127 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11128 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011129 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011130 spec->adc_nids = spec->private_adc_nids;
11131 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011132 }
11133
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011134 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011135
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011136 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011137 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011138
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011139 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011140
Takashi Iwai2134ea42008-01-10 16:53:55 +010011141 spec->vmaster_nid = 0x0c;
11142
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011143 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011144 if (board_config == ALC882_AUTO)
11145 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011146
11147 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011148#ifdef CONFIG_SND_HDA_POWER_SAVE
11149 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011150 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011151#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011152
11153 return 0;
11154}
11155
Takashi Iwai4953550a2009-06-30 15:28:30 +020011156
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011157/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011158 * ALC262 support
11159 */
11160
11161#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11162#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11163
11164#define alc262_dac_nids alc260_dac_nids
11165#define alc262_adc_nids alc882_adc_nids
11166#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011167#define alc262_capsrc_nids alc882_capsrc_nids
11168#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011169
11170#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011171#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011172
Kailang Yang4e555fe2008-08-26 13:05:55 +020011173static hda_nid_t alc262_dmic_adc_nids[1] = {
11174 /* ADC0 */
11175 0x09
11176};
11177
11178static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11179
Kailang Yangdf694da2005-12-05 19:42:22 +010011180static struct snd_kcontrol_new alc262_base_mixer[] = {
11181 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11182 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11183 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11184 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11185 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11186 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011189 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011190 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11191 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011192 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011193 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11195 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11196 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011197 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011198};
11199
Takashi Iwaice875f02008-01-28 18:17:43 +010011200/* update HP, line and mono-out pins according to the master switch */
11201static void alc262_hp_master_update(struct hda_codec *codec)
11202{
11203 struct alc_spec *spec = codec->spec;
11204 int val = spec->master_sw;
11205
11206 /* HP & line-out */
11207 snd_hda_codec_write_cache(codec, 0x1b, 0,
11208 AC_VERB_SET_PIN_WIDGET_CONTROL,
11209 val ? PIN_HP : 0);
11210 snd_hda_codec_write_cache(codec, 0x15, 0,
11211 AC_VERB_SET_PIN_WIDGET_CONTROL,
11212 val ? PIN_HP : 0);
11213 /* mono (speaker) depending on the HP jack sense */
11214 val = val && !spec->jack_present;
11215 snd_hda_codec_write_cache(codec, 0x16, 0,
11216 AC_VERB_SET_PIN_WIDGET_CONTROL,
11217 val ? PIN_OUT : 0);
11218}
11219
11220static void alc262_hp_bpc_automute(struct hda_codec *codec)
11221{
11222 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011223
11224 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011225 alc262_hp_master_update(codec);
11226}
11227
11228static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11229{
11230 if ((res >> 26) != ALC880_HP_EVENT)
11231 return;
11232 alc262_hp_bpc_automute(codec);
11233}
11234
11235static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11236{
11237 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011238
11239 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011240 alc262_hp_master_update(codec);
11241}
11242
11243static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11244 unsigned int res)
11245{
11246 if ((res >> 26) != ALC880_HP_EVENT)
11247 return;
11248 alc262_hp_wildwest_automute(codec);
11249}
11250
Takashi Iwaib72519b2009-05-08 14:31:55 +020011251#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011252
11253static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11254 struct snd_ctl_elem_value *ucontrol)
11255{
11256 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11257 struct alc_spec *spec = codec->spec;
11258 int val = !!*ucontrol->value.integer.value;
11259
11260 if (val == spec->master_sw)
11261 return 0;
11262 spec->master_sw = val;
11263 alc262_hp_master_update(codec);
11264 return 1;
11265}
11266
Takashi Iwaib72519b2009-05-08 14:31:55 +020011267#define ALC262_HP_MASTER_SWITCH \
11268 { \
11269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11270 .name = "Master Playback Switch", \
11271 .info = snd_ctl_boolean_mono_info, \
11272 .get = alc262_hp_master_sw_get, \
11273 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011274 }, \
11275 { \
11276 .iface = NID_MAPPING, \
11277 .name = "Master Playback Switch", \
11278 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011279 }
11280
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011281
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011282static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011283 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011284 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11285 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11286 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011287 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11288 HDA_OUTPUT),
11289 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11290 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011293 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011294 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11295 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011296 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011297 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11298 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11299 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11300 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011301 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11302 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11303 { } /* end */
11304};
11305
Kailang Yangcd7509a2007-01-26 18:33:17 +010011306static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011307 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011308 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11309 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11310 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011312 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11313 HDA_OUTPUT),
11314 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11315 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011316 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11317 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011318 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011319 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11320 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11321 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11322 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011323 { } /* end */
11324};
11325
11326static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11327 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11328 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011329 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011330 { } /* end */
11331};
11332
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011333/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011334static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011335{
11336 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011337
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011338 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011339 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011340}
11341
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011342static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011343 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11344 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011345 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11346 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11348 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011349 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011350 { } /* end */
11351};
11352
11353static struct hda_verb alc262_hp_t5735_verbs[] = {
11354 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11356
11357 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11358 { }
11359};
11360
Kailang Yang8c427222008-01-10 13:03:59 +010011361static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011362 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11363 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011364 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11365 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011366 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11367 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11368 { } /* end */
11369};
11370
11371static struct hda_verb alc262_hp_rp5700_verbs[] = {
11372 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11373 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11374 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11375 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11376 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11377 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11378 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11379 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11381 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11382 {}
11383};
11384
11385static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11386 .num_items = 1,
11387 .items = {
11388 { "Line", 0x1 },
11389 },
11390};
11391
Takashi Iwai42171c12009-05-08 14:11:43 +020011392/* bind hp and internal speaker mute (with plug check) as master switch */
11393static void alc262_hippo_master_update(struct hda_codec *codec)
11394{
11395 struct alc_spec *spec = codec->spec;
11396 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11397 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11398 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11399 unsigned int mute;
11400
11401 /* HP */
11402 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11403 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11404 HDA_AMP_MUTE, mute);
11405 /* mute internal speaker per jack sense */
11406 if (spec->jack_present)
11407 mute = HDA_AMP_MUTE;
11408 if (line_nid)
11409 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11410 HDA_AMP_MUTE, mute);
11411 if (speaker_nid && speaker_nid != line_nid)
11412 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11413 HDA_AMP_MUTE, mute);
11414}
11415
11416#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11417
11418static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11419 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011420{
11421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011422 struct alc_spec *spec = codec->spec;
11423 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011424
Takashi Iwai42171c12009-05-08 14:11:43 +020011425 if (val == spec->master_sw)
11426 return 0;
11427 spec->master_sw = val;
11428 alc262_hippo_master_update(codec);
11429 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011430}
Takashi Iwai5b319542007-07-26 11:49:22 +020011431
Takashi Iwai42171c12009-05-08 14:11:43 +020011432#define ALC262_HIPPO_MASTER_SWITCH \
11433 { \
11434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11435 .name = "Master Playback Switch", \
11436 .info = snd_ctl_boolean_mono_info, \
11437 .get = alc262_hippo_master_sw_get, \
11438 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011439 }, \
11440 { \
11441 .iface = NID_MAPPING, \
11442 .name = "Master Playback Switch", \
11443 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11444 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011445 }
11446
11447static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11448 ALC262_HIPPO_MASTER_SWITCH,
11449 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11450 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11451 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11452 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11453 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11454 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11455 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011456 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011457 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11458 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011459 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011460 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11461 { } /* end */
11462};
11463
11464static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11465 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11466 ALC262_HIPPO_MASTER_SWITCH,
11467 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11468 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11469 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11470 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011473 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011474 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11475 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011476 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011477 { } /* end */
11478};
11479
11480/* mute/unmute internal speaker according to the hp jack and mute state */
11481static void alc262_hippo_automute(struct hda_codec *codec)
11482{
11483 struct alc_spec *spec = codec->spec;
11484 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011485
Wu Fengguang864f92b2009-11-18 12:38:02 +080011486 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011487 alc262_hippo_master_update(codec);
11488}
11489
11490static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11491{
11492 if ((res >> 26) != ALC880_HP_EVENT)
11493 return;
11494 alc262_hippo_automute(codec);
11495}
11496
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011497static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011498{
11499 struct alc_spec *spec = codec->spec;
11500
11501 spec->autocfg.hp_pins[0] = 0x15;
11502 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011503}
11504
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011505static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011506{
11507 struct alc_spec *spec = codec->spec;
11508
11509 spec->autocfg.hp_pins[0] = 0x1b;
11510 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011511}
11512
11513
Kailang Yang272a5272007-05-14 11:00:38 +020011514static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011515 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011516 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011517 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11518 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11519 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11520 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11521 { } /* end */
11522};
11523
Kailang Yang83c34212007-07-05 11:43:05 +020011524static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011525 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11526 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11530 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11531 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11532 { } /* end */
11533};
Kailang Yang272a5272007-05-14 11:00:38 +020011534
Tony Vroonba340e82009-02-02 19:01:30 +000011535static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11536 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11537 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11538 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11539 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11540 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11541 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11542 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11543 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011544 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011545 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11546 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011547 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011548 { } /* end */
11549};
11550
11551static struct hda_verb alc262_tyan_verbs[] = {
11552 /* Headphone automute */
11553 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11554 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11555 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11556
11557 /* P11 AUX_IN, white 4-pin connector */
11558 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11559 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11560 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11561 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11562
11563 {}
11564};
11565
11566/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011567static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011568{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011569 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011570
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011571 spec->autocfg.hp_pins[0] = 0x1b;
11572 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011573}
11574
Tony Vroonba340e82009-02-02 19:01:30 +000011575
Kailang Yangdf694da2005-12-05 19:42:22 +010011576#define alc262_capture_mixer alc882_capture_mixer
11577#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11578
11579/*
11580 * generic initialization of ADC, input mixers and output mixers
11581 */
11582static struct hda_verb alc262_init_verbs[] = {
11583 /*
11584 * Unmute ADC0-2 and set the default input to mic-in
11585 */
11586 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11588 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11589 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11590 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11592
Takashi Iwaicb53c622007-08-10 17:21:45 +020011593 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011594 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011595 * Note: PASD motherboards uses the Line In 2 as the input for
11596 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011597 */
11598 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011599 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11600 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011604
11605 /*
11606 * Set up output mixers (0x0c - 0x0e)
11607 */
11608 /* set vol=0 to output mixers */
11609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11610 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11611 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11612 /* set up input amps for analog loopback */
11613 /* Amp Indices: DAC = 0, mixer = 1 */
11614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11615 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11616 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11617 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11620
11621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11622 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11623 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11624 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11625 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11626 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11627
11628 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11630 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11631 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11632 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011633
Kailang Yangdf694da2005-12-05 19:42:22 +010011634 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11635 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011636
Kailang Yangdf694da2005-12-05 19:42:22 +010011637 /* FIXME: use matrix-type input source selection */
11638 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11639 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11640 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11641 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11642 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11643 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11644 /* Input mixer2 */
11645 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11646 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11647 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11648 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11649 /* Input mixer3 */
11650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11652 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011653 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011654
11655 { }
11656};
11657
Kailang Yang4e555fe2008-08-26 13:05:55 +020011658static struct hda_verb alc262_eapd_verbs[] = {
11659 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11660 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11661 { }
11662};
11663
Kailang Yangccc656c2006-10-17 12:32:26 +020011664static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11665 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11666 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11667 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11668
11669 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11671 {}
11672};
11673
Kailang Yang272a5272007-05-14 11:00:38 +020011674static struct hda_verb alc262_sony_unsol_verbs[] = {
11675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11678
11679 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011681 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011682};
11683
Kailang Yang4e555fe2008-08-26 13:05:55 +020011684static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11685 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11686 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11687 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011690 { } /* end */
11691};
11692
11693static struct hda_verb alc262_toshiba_s06_verbs[] = {
11694 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11696 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11697 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11698 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11699 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11700 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11701 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11702 {}
11703};
11704
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011705static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011706{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011707 struct alc_spec *spec = codec->spec;
11708
11709 spec->autocfg.hp_pins[0] = 0x15;
11710 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011711 spec->ext_mic.pin = 0x18;
11712 spec->ext_mic.mux_idx = 0;
11713 spec->int_mic.pin = 0x12;
11714 spec->int_mic.mux_idx = 9;
11715 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011716}
11717
Takashi Iwai834be882006-03-01 14:16:17 +010011718/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011719 * nec model
11720 * 0x15 = headphone
11721 * 0x16 = internal speaker
11722 * 0x18 = external mic
11723 */
11724
11725static struct snd_kcontrol_new alc262_nec_mixer[] = {
11726 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11727 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11728
11729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011731 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011732
11733 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11734 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11735 { } /* end */
11736};
11737
11738static struct hda_verb alc262_nec_verbs[] = {
11739 /* Unmute Speaker */
11740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11741
11742 /* Headphone */
11743 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11744 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11745
11746 /* External mic to headphone */
11747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11748 /* External mic to speaker */
11749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11750 {}
11751};
11752
11753/*
Takashi Iwai834be882006-03-01 14:16:17 +010011754 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011755 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11756 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011757 */
11758
11759#define ALC_HP_EVENT 0x37
11760
11761static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11762 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11763 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011764 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11765 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011766 {}
11767};
11768
Jiang zhe0e31daf2008-03-20 12:12:39 +010011769static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11770 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11771 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11772 {}
11773};
11774
Daniel T Chene2595322009-12-19 18:19:02 -050011775static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11776 /* Front Mic pin: input vref at 50% */
11777 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11779 {}
11780};
11781
Takashi Iwai834be882006-03-01 14:16:17 +010011782static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011783 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011784 .items = {
11785 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011786 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011787 { "CD", 0x4 },
11788 },
11789};
11790
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011791static struct hda_input_mux alc262_HP_capture_source = {
11792 .num_items = 5,
11793 .items = {
11794 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011795 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011796 { "Line", 0x2 },
11797 { "CD", 0x4 },
11798 { "AUX IN", 0x6 },
11799 },
11800};
11801
zhejiangaccbe492007-08-31 12:36:05 +020011802static struct hda_input_mux alc262_HP_D7000_capture_source = {
11803 .num_items = 4,
11804 .items = {
11805 { "Mic", 0x0 },
11806 { "Front Mic", 0x2 },
11807 { "Line", 0x1 },
11808 { "CD", 0x4 },
11809 },
11810};
11811
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011812/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011813static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11814{
11815 struct alc_spec *spec = codec->spec;
11816 unsigned int mute;
11817
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011818 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011819 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11820 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011821 spec->sense_updated = 1;
11822 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011823 /* unmute internal speaker only if both HPs are unplugged and
11824 * master switch is on
11825 */
11826 if (spec->jack_present)
11827 mute = HDA_AMP_MUTE;
11828 else
Takashi Iwai834be882006-03-01 14:16:17 +010011829 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011830 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11831 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011832}
11833
11834/* unsolicited event for HP jack sensing */
11835static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11836 unsigned int res)
11837{
11838 if ((res >> 26) != ALC_HP_EVENT)
11839 return;
11840 alc262_fujitsu_automute(codec, 1);
11841}
11842
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011843static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11844{
11845 alc262_fujitsu_automute(codec, 1);
11846}
11847
Takashi Iwai834be882006-03-01 14:16:17 +010011848/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011849static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11850 .ops = &snd_hda_bind_vol,
11851 .values = {
11852 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11853 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11854 0
11855 },
11856};
Takashi Iwai834be882006-03-01 14:16:17 +010011857
Jiang zhe0e31daf2008-03-20 12:12:39 +010011858/* mute/unmute internal speaker according to the hp jack and mute state */
11859static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11860{
11861 struct alc_spec *spec = codec->spec;
11862 unsigned int mute;
11863
11864 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011865 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011866 spec->sense_updated = 1;
11867 }
11868 if (spec->jack_present) {
11869 /* mute internal speaker */
11870 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11871 HDA_AMP_MUTE, HDA_AMP_MUTE);
11872 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11873 HDA_AMP_MUTE, HDA_AMP_MUTE);
11874 } else {
11875 /* unmute internal speaker if necessary */
11876 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11877 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11878 HDA_AMP_MUTE, mute);
11879 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11880 HDA_AMP_MUTE, mute);
11881 }
11882}
11883
11884/* unsolicited event for HP jack sensing */
11885static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11886 unsigned int res)
11887{
11888 if ((res >> 26) != ALC_HP_EVENT)
11889 return;
11890 alc262_lenovo_3000_automute(codec, 1);
11891}
11892
Takashi Iwai8de56b72009-07-24 16:51:47 +020011893static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11894 int dir, int idx, long *valp)
11895{
11896 int i, change = 0;
11897
11898 for (i = 0; i < 2; i++, valp++)
11899 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11900 HDA_AMP_MUTE,
11901 *valp ? 0 : HDA_AMP_MUTE);
11902 return change;
11903}
11904
Takashi Iwai834be882006-03-01 14:16:17 +010011905/* bind hp and internal speaker mute (with plug check) */
11906static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11907 struct snd_ctl_elem_value *ucontrol)
11908{
11909 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11910 long *valp = ucontrol->value.integer.value;
11911 int change;
11912
Takashi Iwai8de56b72009-07-24 16:51:47 +020011913 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11914 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011915 if (change)
11916 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011917 return change;
11918}
11919
11920static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011921 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011922 {
11923 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11924 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011925 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011926 .info = snd_hda_mixer_amp_switch_info,
11927 .get = snd_hda_mixer_amp_switch_get,
11928 .put = alc262_fujitsu_master_sw_put,
11929 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11930 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011931 {
11932 .iface = NID_MAPPING,
11933 .name = "Master Playback Switch",
11934 .private_value = 0x1b,
11935 },
Takashi Iwai834be882006-03-01 14:16:17 +010011936 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11937 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011938 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011939 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011941 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011942 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11943 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011944 { } /* end */
11945};
11946
Jiang zhe0e31daf2008-03-20 12:12:39 +010011947/* bind hp and internal speaker mute (with plug check) */
11948static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11949 struct snd_ctl_elem_value *ucontrol)
11950{
11951 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11952 long *valp = ucontrol->value.integer.value;
11953 int change;
11954
Takashi Iwai8de56b72009-07-24 16:51:47 +020011955 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011956 if (change)
11957 alc262_lenovo_3000_automute(codec, 0);
11958 return change;
11959}
11960
11961static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11962 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11963 {
11964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11965 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011966 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011967 .info = snd_hda_mixer_amp_switch_info,
11968 .get = snd_hda_mixer_amp_switch_get,
11969 .put = alc262_lenovo_3000_master_sw_put,
11970 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11971 },
11972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011974 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11976 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011977 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011978 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11979 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011980 { } /* end */
11981};
11982
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011983static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11984 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011985 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011988 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011989 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011991 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011992 { } /* end */
11993};
11994
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011995/* additional init verbs for Benq laptops */
11996static struct hda_verb alc262_EAPD_verbs[] = {
11997 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11998 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11999 {}
12000};
12001
Kailang Yang83c34212007-07-05 11:43:05 +020012002static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
12003 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12004 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12005
12006 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
12007 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
12008 {}
12009};
12010
Tobin Davisf651b502007-10-26 12:40:47 +020012011/* Samsung Q1 Ultra Vista model setup */
12012static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012013 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
12014 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012015 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12016 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012017 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
12018 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012019 { } /* end */
12020};
12021
12022static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012023 /* output mixer */
12024 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12027 /* speaker */
12028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12029 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12030 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12031 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12032 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020012033 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12036 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12037 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12038 /* internal mic */
12039 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12041 /* ADC, choose mic */
12042 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12050 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
12051 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020012052 {}
12053};
12054
Tobin Davisf651b502007-10-26 12:40:47 +020012055/* mute/unmute internal speaker according to the hp jack and mute state */
12056static void alc262_ultra_automute(struct hda_codec *codec)
12057{
12058 struct alc_spec *spec = codec->spec;
12059 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012060
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012061 mute = 0;
12062 /* auto-mute only when HP is used as HP */
12063 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012064 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012065 if (spec->jack_present)
12066 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012067 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012068 /* mute/unmute internal speaker */
12069 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12070 HDA_AMP_MUTE, mute);
12071 /* mute/unmute HP */
12072 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12073 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012074}
12075
12076/* unsolicited event for HP jack sensing */
12077static void alc262_ultra_unsol_event(struct hda_codec *codec,
12078 unsigned int res)
12079{
12080 if ((res >> 26) != ALC880_HP_EVENT)
12081 return;
12082 alc262_ultra_automute(codec);
12083}
12084
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012085static struct hda_input_mux alc262_ultra_capture_source = {
12086 .num_items = 2,
12087 .items = {
12088 { "Mic", 0x1 },
12089 { "Headphone", 0x7 },
12090 },
12091};
12092
12093static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12094 struct snd_ctl_elem_value *ucontrol)
12095{
12096 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12097 struct alc_spec *spec = codec->spec;
12098 int ret;
12099
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012100 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012101 if (!ret)
12102 return 0;
12103 /* reprogram the HP pin as mic or HP according to the input source */
12104 snd_hda_codec_write_cache(codec, 0x15, 0,
12105 AC_VERB_SET_PIN_WIDGET_CONTROL,
12106 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12107 alc262_ultra_automute(codec); /* mute/unmute HP */
12108 return ret;
12109}
12110
12111static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12112 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12113 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12114 {
12115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12116 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012117 .info = alc_mux_enum_info,
12118 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012119 .put = alc262_ultra_mux_enum_put,
12120 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012121 {
12122 .iface = NID_MAPPING,
12123 .name = "Capture Source",
12124 .private_value = 0x15,
12125 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012126 { } /* end */
12127};
12128
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012129/* We use two mixers depending on the output pin; 0x16 is a mono output
12130 * and thus it's bound with a different mixer.
12131 * This function returns which mixer amp should be used.
12132 */
12133static int alc262_check_volbit(hda_nid_t nid)
12134{
12135 if (!nid)
12136 return 0;
12137 else if (nid == 0x16)
12138 return 2;
12139 else
12140 return 1;
12141}
12142
12143static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012144 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012145{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012146 unsigned long val;
12147 int vbit;
12148
12149 vbit = alc262_check_volbit(nid);
12150 if (!vbit)
12151 return 0;
12152 if (*vbits & vbit) /* a volume control for this mixer already there */
12153 return 0;
12154 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012155 if (vbit == 2)
12156 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12157 else
12158 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012159 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012160}
12161
12162static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012163 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012164{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012165 unsigned long val;
12166
12167 if (!nid)
12168 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012169 if (nid == 0x16)
12170 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12171 else
12172 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012173 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012174}
12175
Kailang Yangdf694da2005-12-05 19:42:22 +010012176/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012177static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12178 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012179{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012180 const char *pfx;
12181 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012182 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012183
12184 spec->multiout.num_dacs = 1; /* only use one dac */
12185 spec->multiout.dac_nids = spec->private_dac_nids;
12186 spec->multiout.dac_nids[0] = 2;
12187
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012188 pfx = alc_get_line_out_pfx(cfg, true);
12189 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012190 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012191 for (i = 0; i < 2; i++) {
12192 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12193 if (err < 0)
12194 return err;
12195 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12196 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12197 "Speaker", i);
12198 if (err < 0)
12199 return err;
12200 }
12201 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12202 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12203 "Headphone", i);
12204 if (err < 0)
12205 return err;
12206 }
12207 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012208
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012209 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12210 alc262_check_volbit(cfg->speaker_pins[0]) |
12211 alc262_check_volbit(cfg->hp_pins[0]);
12212 if (vbits == 1 || vbits == 2)
12213 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012214 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012215 for (i = 0; i < 2; i++) {
12216 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12217 &vbits, i);
12218 if (err < 0)
12219 return err;
12220 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12221 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12222 "Speaker", &vbits, i);
12223 if (err < 0)
12224 return err;
12225 }
12226 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12227 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12228 "Headphone", &vbits, i);
12229 if (err < 0)
12230 return err;
12231 }
12232 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012233 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012234}
12235
Takashi Iwai05f5f472009-08-25 13:10:18 +020012236#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012237 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012238
12239/*
12240 * generic initialization of ADC, input mixers and output mixers
12241 */
12242static struct hda_verb alc262_volume_init_verbs[] = {
12243 /*
12244 * Unmute ADC0-2 and set the default input to mic-in
12245 */
12246 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12248 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12249 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12250 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12252
Takashi Iwaicb53c622007-08-10 17:21:45 +020012253 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012254 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012255 * Note: PASD motherboards uses the Line In 2 as the input for
12256 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012257 */
12258 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012264
12265 /*
12266 * Set up output mixers (0x0c - 0x0f)
12267 */
12268 /* set vol=0 to output mixers */
12269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12271 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012272
Kailang Yangdf694da2005-12-05 19:42:22 +010012273 /* set up input amps for analog loopback */
12274 /* Amp Indices: DAC = 0, mixer = 1 */
12275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12277 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12278 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12279 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12280 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12281
12282 /* FIXME: use matrix-type input source selection */
12283 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12284 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12289 /* Input mixer2 */
12290 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12294 /* Input mixer3 */
12295 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12299
12300 { }
12301};
12302
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012303static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12304 /*
12305 * Unmute ADC0-2 and set the default input to mic-in
12306 */
12307 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12309 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12310 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12311 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12312 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12313
Takashi Iwaicb53c622007-08-10 17:21:45 +020012314 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012315 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012316 * Note: PASD motherboards uses the Line In 2 as the input for
12317 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012318 */
12319 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012327
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012328 /*
12329 * Set up output mixers (0x0c - 0x0e)
12330 */
12331 /* set vol=0 to output mixers */
12332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12335
12336 /* set up input amps for analog loopback */
12337 /* Amp Indices: DAC = 0, mixer = 1 */
12338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12341 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12343 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12344
Takashi Iwaice875f02008-01-28 18:17:43 +010012345 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12347 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12348
12349 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12350 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12351
12352 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12353 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12354
12355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12356 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12357 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12359 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12360
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012361 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012362 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12363 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012364 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012365 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12366 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12367
12368
12369 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012370 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12371 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12374 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12375 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12376 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12377 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12378 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12379 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12380 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012381 /* Input mixer2 */
12382 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012383 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12386 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12387 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12388 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12389 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012391 /* Input mixer3 */
12392 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12394 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012401
Takashi Iwaice875f02008-01-28 18:17:43 +010012402 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12403
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012404 { }
12405};
12406
Kailang Yangcd7509a2007-01-26 18:33:17 +010012407static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12408 /*
12409 * Unmute ADC0-2 and set the default input to mic-in
12410 */
12411 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12413 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12414 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12415 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12416 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12417
Takashi Iwaicb53c622007-08-10 17:21:45 +020012418 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012419 * mixer widget
12420 * Note: PASD motherboards uses the Line In 2 as the input for front
12421 * panel mic (mic 2)
12422 */
12423 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012424 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12425 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12426 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12427 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12428 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12429 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12430 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12431 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012432 /*
12433 * Set up output mixers (0x0c - 0x0e)
12434 */
12435 /* set vol=0 to output mixers */
12436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12439
12440 /* set up input amps for analog loopback */
12441 /* Amp Indices: DAC = 0, mixer = 1 */
12442 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12443 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12444 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12445 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12446 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12447 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12448
12449
12450 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12451 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12453 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12454 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12455 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12456 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12457
12458 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12460
12461 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12463
12464 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12465 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12467 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12468 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12469 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12470
12471 /* FIXME: use matrix-type input source selection */
12472 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12473 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12474 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12475 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12476 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12477 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12478 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12479 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12480 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12481 /* Input mixer2 */
12482 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12483 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12487 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12489 /* Input mixer3 */
12490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12495 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12496 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12497
Takashi Iwaice875f02008-01-28 18:17:43 +010012498 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12499
Kailang Yangcd7509a2007-01-26 18:33:17 +010012500 { }
12501};
12502
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012503static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12504
12505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12507 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12508
12509 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12510 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12513
12514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12515 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12516 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12517 {}
12518};
12519
Takashi Iwai18675e42010-09-08 15:55:44 +020012520/*
12521 * Pin config fixes
12522 */
12523enum {
12524 PINFIX_FSC_H270,
12525};
12526
12527static const struct alc_fixup alc262_fixups[] = {
12528 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012529 .type = ALC_FIXUP_PINS,
12530 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012531 { 0x14, 0x99130110 }, /* speaker */
12532 { 0x15, 0x0221142f }, /* front HP */
12533 { 0x1b, 0x0121141f }, /* rear HP */
12534 { }
12535 }
12536 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012537};
12538
12539static struct snd_pci_quirk alc262_fixup_tbl[] = {
12540 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12541 {}
12542};
12543
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012544
Takashi Iwaicb53c622007-08-10 17:21:45 +020012545#ifdef CONFIG_SND_HDA_POWER_SAVE
12546#define alc262_loopbacks alc880_loopbacks
12547#endif
12548
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012549/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012550#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12551#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12552#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12553#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12554
12555/*
12556 * BIOS auto configuration
12557 */
12558static int alc262_parse_auto_config(struct hda_codec *codec)
12559{
12560 struct alc_spec *spec = codec->spec;
12561 int err;
12562 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12563
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012564 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12565 alc262_ignore);
12566 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012567 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012568 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012569 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012570 spec->multiout.max_channels = 2;
12571 spec->no_analog = 1;
12572 goto dig_only;
12573 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012574 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012575 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012576 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12577 if (err < 0)
12578 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012579 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012580 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012581 return err;
12582
12583 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12584
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012585 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012586 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012587
Takashi Iwai603c4012008-07-30 15:01:44 +020012588 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012589 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012590
Takashi Iwaid88897e2008-10-31 15:01:37 +010012591 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012592 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012593 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012594
Takashi Iwai776e1842007-08-29 15:07:11 +020012595 err = alc_auto_add_mic_boost(codec);
12596 if (err < 0)
12597 return err;
12598
Kailang Yang6227cdc2010-02-25 08:36:52 +010012599 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012600
Kailang Yangdf694da2005-12-05 19:42:22 +010012601 return 1;
12602}
12603
12604#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12605#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12606#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012607#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012608
12609
12610/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012611static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012612{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012613 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012614 alc262_auto_init_multi_out(codec);
12615 alc262_auto_init_hp_out(codec);
12616 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012617 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012618 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012619 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012620 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012621}
12622
12623/*
12624 * configuration and preset
12625 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012626static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012627 [ALC262_BASIC] = "basic",
12628 [ALC262_HIPPO] = "hippo",
12629 [ALC262_HIPPO_1] = "hippo_1",
12630 [ALC262_FUJITSU] = "fujitsu",
12631 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012632 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012633 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012634 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012635 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012636 [ALC262_BENQ_T31] = "benq-t31",
12637 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012638 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012639 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012640 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012641 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012642 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012643 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012644 [ALC262_AUTO] = "auto",
12645};
12646
12647static struct snd_pci_quirk alc262_cfg_tbl[] = {
12648 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012649 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012650 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12651 ALC262_HP_BPC),
12652 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12653 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012654 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12655 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012656 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12657 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012658 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012659 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012660 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012661 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012662 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012663 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012664 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012665 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012666 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12667 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12668 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012669 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12670 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012671 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012672 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012673 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012674 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012675 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012676 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012677 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012678 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012679#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012680 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12681 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012682#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012683 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012684 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012685 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012686 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012687 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012688 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012689 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12690 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012691 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012692 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012693 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012694 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012695 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012696 {}
12697};
12698
12699static struct alc_config_preset alc262_presets[] = {
12700 [ALC262_BASIC] = {
12701 .mixers = { alc262_base_mixer },
12702 .init_verbs = { alc262_init_verbs },
12703 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12704 .dac_nids = alc262_dac_nids,
12705 .hp_nid = 0x03,
12706 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12707 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012708 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012709 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012710 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012711 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012712 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012713 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12714 .dac_nids = alc262_dac_nids,
12715 .hp_nid = 0x03,
12716 .dig_out_nid = ALC262_DIGOUT_NID,
12717 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12718 .channel_mode = alc262_modes,
12719 .input_mux = &alc262_capture_source,
12720 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012721 .setup = alc262_hippo_setup,
12722 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012723 },
12724 [ALC262_HIPPO_1] = {
12725 .mixers = { alc262_hippo1_mixer },
12726 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12727 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12728 .dac_nids = alc262_dac_nids,
12729 .hp_nid = 0x02,
12730 .dig_out_nid = ALC262_DIGOUT_NID,
12731 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12732 .channel_mode = alc262_modes,
12733 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012734 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012735 .setup = alc262_hippo1_setup,
12736 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012737 },
Takashi Iwai834be882006-03-01 14:16:17 +010012738 [ALC262_FUJITSU] = {
12739 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012740 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12741 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012742 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12743 .dac_nids = alc262_dac_nids,
12744 .hp_nid = 0x03,
12745 .dig_out_nid = ALC262_DIGOUT_NID,
12746 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12747 .channel_mode = alc262_modes,
12748 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012749 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012750 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012751 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012752 [ALC262_HP_BPC] = {
12753 .mixers = { alc262_HP_BPC_mixer },
12754 .init_verbs = { alc262_HP_BPC_init_verbs },
12755 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12756 .dac_nids = alc262_dac_nids,
12757 .hp_nid = 0x03,
12758 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12759 .channel_mode = alc262_modes,
12760 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012761 .unsol_event = alc262_hp_bpc_unsol_event,
12762 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012763 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012764 [ALC262_HP_BPC_D7000_WF] = {
12765 .mixers = { alc262_HP_BPC_WildWest_mixer },
12766 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12767 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12768 .dac_nids = alc262_dac_nids,
12769 .hp_nid = 0x03,
12770 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12771 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012772 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012773 .unsol_event = alc262_hp_wildwest_unsol_event,
12774 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012775 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012776 [ALC262_HP_BPC_D7000_WL] = {
12777 .mixers = { alc262_HP_BPC_WildWest_mixer,
12778 alc262_HP_BPC_WildWest_option_mixer },
12779 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12780 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12781 .dac_nids = alc262_dac_nids,
12782 .hp_nid = 0x03,
12783 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12784 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012785 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012786 .unsol_event = alc262_hp_wildwest_unsol_event,
12787 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012788 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012789 [ALC262_HP_TC_T5735] = {
12790 .mixers = { alc262_hp_t5735_mixer },
12791 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12792 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12793 .dac_nids = alc262_dac_nids,
12794 .hp_nid = 0x03,
12795 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12796 .channel_mode = alc262_modes,
12797 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012798 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012799 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012800 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012801 },
12802 [ALC262_HP_RP5700] = {
12803 .mixers = { alc262_hp_rp5700_mixer },
12804 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12805 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12806 .dac_nids = alc262_dac_nids,
12807 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12808 .channel_mode = alc262_modes,
12809 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012810 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012811 [ALC262_BENQ_ED8] = {
12812 .mixers = { alc262_base_mixer },
12813 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12814 .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,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012820 },
Kailang Yang272a5272007-05-14 11:00:38 +020012821 [ALC262_SONY_ASSAMD] = {
12822 .mixers = { alc262_sony_mixer },
12823 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12824 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12825 .dac_nids = alc262_dac_nids,
12826 .hp_nid = 0x02,
12827 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12828 .channel_mode = alc262_modes,
12829 .input_mux = &alc262_capture_source,
12830 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012831 .setup = alc262_hippo_setup,
12832 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012833 },
12834 [ALC262_BENQ_T31] = {
12835 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012836 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12837 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012838 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12839 .dac_nids = alc262_dac_nids,
12840 .hp_nid = 0x03,
12841 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12842 .channel_mode = alc262_modes,
12843 .input_mux = &alc262_capture_source,
12844 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012845 .setup = alc262_hippo_setup,
12846 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012847 },
Tobin Davisf651b502007-10-26 12:40:47 +020012848 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012849 .mixers = { alc262_ultra_mixer },
12850 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012851 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012852 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12853 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012854 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12855 .channel_mode = alc262_modes,
12856 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012857 .adc_nids = alc262_adc_nids, /* ADC0 */
12858 .capsrc_nids = alc262_capsrc_nids,
12859 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012860 .unsol_event = alc262_ultra_unsol_event,
12861 .init_hook = alc262_ultra_automute,
12862 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012863 [ALC262_LENOVO_3000] = {
12864 .mixers = { alc262_lenovo_3000_mixer },
12865 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012866 alc262_lenovo_3000_unsol_verbs,
12867 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012868 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12869 .dac_nids = alc262_dac_nids,
12870 .hp_nid = 0x03,
12871 .dig_out_nid = ALC262_DIGOUT_NID,
12872 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12873 .channel_mode = alc262_modes,
12874 .input_mux = &alc262_fujitsu_capture_source,
12875 .unsol_event = alc262_lenovo_3000_unsol_event,
12876 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012877 [ALC262_NEC] = {
12878 .mixers = { alc262_nec_mixer },
12879 .init_verbs = { alc262_nec_verbs },
12880 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12881 .dac_nids = alc262_dac_nids,
12882 .hp_nid = 0x03,
12883 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12884 .channel_mode = alc262_modes,
12885 .input_mux = &alc262_capture_source,
12886 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012887 [ALC262_TOSHIBA_S06] = {
12888 .mixers = { alc262_toshiba_s06_mixer },
12889 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12890 alc262_eapd_verbs },
12891 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12892 .capsrc_nids = alc262_dmic_capsrc_nids,
12893 .dac_nids = alc262_dac_nids,
12894 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012895 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012896 .dig_out_nid = ALC262_DIGOUT_NID,
12897 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12898 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012899 .unsol_event = alc_sku_unsol_event,
12900 .setup = alc262_toshiba_s06_setup,
12901 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012902 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012903 [ALC262_TOSHIBA_RX1] = {
12904 .mixers = { alc262_toshiba_rx1_mixer },
12905 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12906 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12907 .dac_nids = alc262_dac_nids,
12908 .hp_nid = 0x03,
12909 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12910 .channel_mode = alc262_modes,
12911 .input_mux = &alc262_capture_source,
12912 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012913 .setup = alc262_hippo_setup,
12914 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012915 },
Tony Vroonba340e82009-02-02 19:01:30 +000012916 [ALC262_TYAN] = {
12917 .mixers = { alc262_tyan_mixer },
12918 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12919 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12920 .dac_nids = alc262_dac_nids,
12921 .hp_nid = 0x02,
12922 .dig_out_nid = ALC262_DIGOUT_NID,
12923 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12924 .channel_mode = alc262_modes,
12925 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012926 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012927 .setup = alc262_tyan_setup,
12928 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012929 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012930};
12931
12932static int patch_alc262(struct hda_codec *codec)
12933{
12934 struct alc_spec *spec;
12935 int board_config;
12936 int err;
12937
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012938 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012939 if (spec == NULL)
12940 return -ENOMEM;
12941
12942 codec->spec = spec;
12943#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012944 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12945 * under-run
12946 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012947 {
12948 int tmp;
12949 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12950 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12951 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12952 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12953 }
12954#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012955 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012956
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012957 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12958
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012959 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12960 alc262_models,
12961 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012962
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012963 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012964 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12965 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012966 board_config = ALC262_AUTO;
12967 }
12968
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012969 if (board_config == ALC262_AUTO) {
12970 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12971 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12972 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012973
Kailang Yangdf694da2005-12-05 19:42:22 +010012974 if (board_config == ALC262_AUTO) {
12975 /* automatic parse from the BIOS config */
12976 err = alc262_parse_auto_config(codec);
12977 if (err < 0) {
12978 alc_free(codec);
12979 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012980 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012981 printk(KERN_INFO
12982 "hda_codec: Cannot set up configuration "
12983 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012984 board_config = ALC262_BASIC;
12985 }
12986 }
12987
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012988 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012989 err = snd_hda_attach_beep_device(codec, 0x1);
12990 if (err < 0) {
12991 alc_free(codec);
12992 return err;
12993 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012994 }
12995
Kailang Yangdf694da2005-12-05 19:42:22 +010012996 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012997 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012998
Kailang Yangdf694da2005-12-05 19:42:22 +010012999 spec->stream_analog_playback = &alc262_pcm_analog_playback;
13000 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020013001
Kailang Yangdf694da2005-12-05 19:42:22 +010013002 spec->stream_digital_playback = &alc262_pcm_digital_playback;
13003 spec->stream_digital_capture = &alc262_pcm_digital_capture;
13004
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013005 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020013006 int i;
13007 /* check whether the digital-mic has to be supported */
13008 for (i = 0; i < spec->input_mux->num_items; i++) {
13009 if (spec->input_mux->items[i].index >= 9)
13010 break;
13011 }
13012 if (i < spec->input_mux->num_items) {
13013 /* use only ADC0 */
13014 spec->adc_nids = alc262_dmic_adc_nids;
13015 spec->num_adc_nids = 1;
13016 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010013017 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020013018 /* all analog inputs */
13019 /* check whether NID 0x07 is valid */
13020 unsigned int wcap = get_wcaps(codec, 0x07);
13021
13022 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013023 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020013024 if (wcap != AC_WID_AUD_IN) {
13025 spec->adc_nids = alc262_adc_nids_alt;
13026 spec->num_adc_nids =
13027 ARRAY_SIZE(alc262_adc_nids_alt);
13028 spec->capsrc_nids = alc262_capsrc_nids_alt;
13029 } else {
13030 spec->adc_nids = alc262_adc_nids;
13031 spec->num_adc_nids =
13032 ARRAY_SIZE(alc262_adc_nids);
13033 spec->capsrc_nids = alc262_capsrc_nids;
13034 }
Kailang Yangdf694da2005-12-05 19:42:22 +010013035 }
13036 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010013037 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013038 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013039 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010013040 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010013041
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013042 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020013043
Takashi Iwai2134ea42008-01-10 16:53:55 +010013044 spec->vmaster_nid = 0x0c;
13045
Kailang Yangdf694da2005-12-05 19:42:22 +010013046 codec->patch_ops = alc_patch_ops;
13047 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013048 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020013049
13050 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020013051#ifdef CONFIG_SND_HDA_POWER_SAVE
13052 if (!spec->loopback.amplist)
13053 spec->loopback.amplist = alc262_loopbacks;
13054#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013055
Kailang Yangdf694da2005-12-05 19:42:22 +010013056 return 0;
13057}
13058
Kailang Yangdf694da2005-12-05 19:42:22 +010013059/*
Kailang Yanga361d842007-06-05 12:30:55 +020013060 * ALC268 channel source setting (2 channel)
13061 */
13062#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13063#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013064
Kailang Yanga361d842007-06-05 12:30:55 +020013065static hda_nid_t alc268_dac_nids[2] = {
13066 /* front, hp */
13067 0x02, 0x03
13068};
13069
13070static hda_nid_t alc268_adc_nids[2] = {
13071 /* ADC0-1 */
13072 0x08, 0x07
13073};
13074
13075static hda_nid_t alc268_adc_nids_alt[1] = {
13076 /* ADC0 */
13077 0x08
13078};
13079
Takashi Iwaie1406342008-02-11 18:32:32 +010013080static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13081
Kailang Yanga361d842007-06-05 12:30:55 +020013082static struct snd_kcontrol_new alc268_base_mixer[] = {
13083 /* output mixer control */
13084 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13085 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13086 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13087 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013088 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13089 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13090 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013091 { }
13092};
13093
Takashi Iwai42171c12009-05-08 14:11:43 +020013094static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13095 /* output mixer control */
13096 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13097 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13098 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013099 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13100 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13101 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013102 { }
13103};
13104
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013105/* bind Beep switches of both NID 0x0f and 0x10 */
13106static struct hda_bind_ctls alc268_bind_beep_sw = {
13107 .ops = &snd_hda_bind_sw,
13108 .values = {
13109 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13110 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13111 0
13112 },
13113};
13114
13115static struct snd_kcontrol_new alc268_beep_mixer[] = {
13116 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13117 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13118 { }
13119};
13120
Kailang Yangd1a991a2007-08-15 16:21:59 +020013121static struct hda_verb alc268_eapd_verbs[] = {
13122 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13123 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13124 { }
13125};
13126
Takashi Iwaid2738092007-08-16 14:59:45 +020013127/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013128static struct hda_verb alc268_toshiba_verbs[] = {
13129 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13130 { } /* end */
13131};
13132
13133/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013134/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013135static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13136 .ops = &snd_hda_bind_vol,
13137 .values = {
13138 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13139 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13140 0
13141 },
13142};
13143
Takashi Iwai889c4392007-08-23 18:56:52 +020013144/* mute/unmute internal speaker according to the hp jack and mute state */
13145static void alc268_acer_automute(struct hda_codec *codec, int force)
13146{
13147 struct alc_spec *spec = codec->spec;
13148 unsigned int mute;
13149
13150 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013151 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013152 spec->sense_updated = 1;
13153 }
13154 if (spec->jack_present)
13155 mute = HDA_AMP_MUTE; /* mute internal speaker */
13156 else /* unmute internal speaker if necessary */
13157 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13158 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13159 HDA_AMP_MUTE, mute);
13160}
13161
13162
13163/* bind hp and internal speaker mute (with plug check) */
13164static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13165 struct snd_ctl_elem_value *ucontrol)
13166{
13167 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13168 long *valp = ucontrol->value.integer.value;
13169 int change;
13170
Takashi Iwai8de56b72009-07-24 16:51:47 +020013171 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013172 if (change)
13173 alc268_acer_automute(codec, 0);
13174 return change;
13175}
Takashi Iwaid2738092007-08-16 14:59:45 +020013176
Kailang Yang8ef355d2008-08-26 13:10:22 +020013177static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13178 /* output mixer control */
13179 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13180 {
13181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13182 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013183 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013184 .info = snd_hda_mixer_amp_switch_info,
13185 .get = snd_hda_mixer_amp_switch_get,
13186 .put = alc268_acer_master_sw_put,
13187 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13188 },
13189 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13190 { }
13191};
13192
Takashi Iwaid2738092007-08-16 14:59:45 +020013193static struct snd_kcontrol_new alc268_acer_mixer[] = {
13194 /* output mixer control */
13195 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13196 {
13197 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13198 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013199 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013200 .info = snd_hda_mixer_amp_switch_info,
13201 .get = snd_hda_mixer_amp_switch_get,
13202 .put = alc268_acer_master_sw_put,
13203 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13204 },
David Henningsson5f99f862011-01-04 15:24:24 +010013205 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13206 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13207 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013208 { }
13209};
13210
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013211static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13212 /* output mixer control */
13213 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13214 {
13215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13216 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013217 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013218 .info = snd_hda_mixer_amp_switch_info,
13219 .get = snd_hda_mixer_amp_switch_get,
13220 .put = alc268_acer_master_sw_put,
13221 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13222 },
David Henningsson5f99f862011-01-04 15:24:24 +010013223 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13224 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013225 { }
13226};
13227
Kailang Yang8ef355d2008-08-26 13:10:22 +020013228static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13229 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13231 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13232 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13233 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13235 { }
13236};
13237
Takashi Iwaid2738092007-08-16 14:59:45 +020013238static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013239 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13240 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013243 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13244 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013245 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13246 { }
13247};
13248
13249/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013250#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013251#define alc268_toshiba_setup alc262_hippo_setup
13252#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013253
13254static void alc268_acer_unsol_event(struct hda_codec *codec,
13255 unsigned int res)
13256{
Takashi Iwai889c4392007-08-23 18:56:52 +020013257 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013258 return;
13259 alc268_acer_automute(codec, 1);
13260}
13261
Takashi Iwai889c4392007-08-23 18:56:52 +020013262static void alc268_acer_init_hook(struct hda_codec *codec)
13263{
13264 alc268_acer_automute(codec, 1);
13265}
13266
Kailang Yang8ef355d2008-08-26 13:10:22 +020013267/* toggle speaker-output according to the hp-jack state */
13268static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13269{
13270 unsigned int present;
13271 unsigned char bits;
13272
Wu Fengguang864f92b2009-11-18 12:38:02 +080013273 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013274 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013275 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013276 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013277 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013278 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013279}
13280
Kailang Yang8ef355d2008-08-26 13:10:22 +020013281static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13282 unsigned int res)
13283{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013284 switch (res >> 26) {
13285 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013286 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013287 break;
13288 case ALC880_MIC_EVENT:
13289 alc_mic_automute(codec);
13290 break;
13291 }
13292}
13293
13294static void alc268_acer_lc_setup(struct hda_codec *codec)
13295{
13296 struct alc_spec *spec = codec->spec;
13297 spec->ext_mic.pin = 0x18;
13298 spec->ext_mic.mux_idx = 0;
13299 spec->int_mic.pin = 0x12;
13300 spec->int_mic.mux_idx = 6;
13301 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013302}
13303
13304static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13305{
13306 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013307 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013308}
13309
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013310static struct snd_kcontrol_new alc268_dell_mixer[] = {
13311 /* output mixer control */
13312 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13313 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13314 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13315 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013316 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13317 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013318 { }
13319};
13320
13321static struct hda_verb alc268_dell_verbs[] = {
13322 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13324 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013325 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013326 { }
13327};
13328
13329/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013330static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013331{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013332 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013333
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013334 spec->autocfg.hp_pins[0] = 0x15;
13335 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013336 spec->ext_mic.pin = 0x18;
13337 spec->ext_mic.mux_idx = 0;
13338 spec->int_mic.pin = 0x19;
13339 spec->int_mic.mux_idx = 1;
13340 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013341}
13342
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013343static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13344 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13345 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13346 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13348 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13349 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013350 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13351 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013352 { }
13353};
13354
13355static struct hda_verb alc267_quanta_il1_verbs[] = {
13356 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13357 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13358 { }
13359};
13360
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013361static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013362{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013363 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013364 spec->autocfg.hp_pins[0] = 0x15;
13365 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013366 spec->ext_mic.pin = 0x18;
13367 spec->ext_mic.mux_idx = 0;
13368 spec->int_mic.pin = 0x19;
13369 spec->int_mic.mux_idx = 1;
13370 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013371}
13372
Kailang Yanga361d842007-06-05 12:30:55 +020013373/*
13374 * generic initialization of ADC, input mixers and output mixers
13375 */
13376static struct hda_verb alc268_base_init_verbs[] = {
13377 /* Unmute DAC0-1 and set vol = 0 */
13378 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013379 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013380
13381 /*
13382 * Set up output mixers (0x0c - 0x0e)
13383 */
13384 /* set vol=0 to output mixers */
13385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013386 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13387
13388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13389 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13390
13391 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13392 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13393 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13394 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13395 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13396 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13397 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13398 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13399
13400 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13401 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13402 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13403 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013404 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013405
13406 /* set PCBEEP vol = 0, mute connections */
13407 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13409 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013410
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013411 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013412
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013413 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13415 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013417
Kailang Yanga361d842007-06-05 12:30:55 +020013418 { }
13419};
13420
13421/*
13422 * generic initialization of ADC, input mixers and output mixers
13423 */
13424static struct hda_verb alc268_volume_init_verbs[] = {
13425 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013426 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13427 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013428
13429 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13430 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13431 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13432 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13433 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13434
Kailang Yanga361d842007-06-05 12:30:55 +020013435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013436 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13437 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13438
13439 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013441
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013442 /* set PCBEEP vol = 0, mute connections */
13443 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13444 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13445 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013446
13447 { }
13448};
13449
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013450static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13451 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13452 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13453 { } /* end */
13454};
13455
Kailang Yanga361d842007-06-05 12:30:55 +020013456static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13457 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13458 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013459 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013460 { } /* end */
13461};
13462
13463static struct snd_kcontrol_new alc268_capture_mixer[] = {
13464 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13465 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13466 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13467 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013468 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013469 { } /* end */
13470};
13471
13472static struct hda_input_mux alc268_capture_source = {
13473 .num_items = 4,
13474 .items = {
13475 { "Mic", 0x0 },
13476 { "Front Mic", 0x1 },
13477 { "Line", 0x2 },
13478 { "CD", 0x3 },
13479 },
13480};
13481
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013482static struct hda_input_mux alc268_acer_capture_source = {
13483 .num_items = 3,
13484 .items = {
13485 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013486 { "Internal Mic", 0x1 },
13487 { "Line", 0x2 },
13488 },
13489};
13490
13491static struct hda_input_mux alc268_acer_dmic_capture_source = {
13492 .num_items = 3,
13493 .items = {
13494 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013495 { "Internal Mic", 0x6 },
13496 { "Line", 0x2 },
13497 },
13498};
13499
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013500#ifdef CONFIG_SND_DEBUG
13501static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013502 /* Volume widgets */
13503 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13504 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13505 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13506 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13507 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13508 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13509 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13510 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13511 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13512 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13513 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13514 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13515 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013516 /* The below appears problematic on some hardwares */
13517 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013518 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13519 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13520 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13521 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13522
13523 /* Modes for retasking pin widgets */
13524 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13525 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13526 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13527 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13528
13529 /* Controls for GPIO pins, assuming they are configured as outputs */
13530 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13531 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13532 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13533 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13534
13535 /* Switches to allow the digital SPDIF output pin to be enabled.
13536 * The ALC268 does not have an SPDIF input.
13537 */
13538 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13539
13540 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13541 * this output to turn on an external amplifier.
13542 */
13543 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13544 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13545
13546 { } /* end */
13547};
13548#endif
13549
Kailang Yanga361d842007-06-05 12:30:55 +020013550/* create input playback/capture controls for the given pin */
13551static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13552 const char *ctlname, int idx)
13553{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013554 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013555 int err;
13556
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013557 switch (nid) {
13558 case 0x14:
13559 case 0x16:
13560 dac = 0x02;
13561 break;
13562 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013563 case 0x1a: /* ALC259/269 only */
13564 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013565 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013566 dac = 0x03;
13567 break;
13568 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013569 snd_printd(KERN_WARNING "hda_codec: "
13570 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013571 return 0;
13572 }
13573 if (spec->multiout.dac_nids[0] != dac &&
13574 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013575 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013576 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013577 HDA_OUTPUT));
13578 if (err < 0)
13579 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013580 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13581 }
13582
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013583 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013584 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013585 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013586 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013587 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013588 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013589 if (err < 0)
13590 return err;
13591 return 0;
13592}
13593
13594/* add playback controls from the parsed DAC table */
13595static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13596 const struct auto_pin_cfg *cfg)
13597{
13598 hda_nid_t nid;
13599 int err;
13600
Kailang Yanga361d842007-06-05 12:30:55 +020013601 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013602
13603 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013604 if (nid) {
13605 const char *name;
13606 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13607 name = "Speaker";
13608 else
13609 name = "Front";
13610 err = alc268_new_analog_output(spec, nid, name, 0);
13611 if (err < 0)
13612 return err;
13613 }
Kailang Yanga361d842007-06-05 12:30:55 +020013614
13615 nid = cfg->speaker_pins[0];
13616 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013617 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013618 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13619 if (err < 0)
13620 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013621 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013622 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13623 if (err < 0)
13624 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013625 }
13626 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013627 if (nid) {
13628 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13629 if (err < 0)
13630 return err;
13631 }
Kailang Yanga361d842007-06-05 12:30:55 +020013632
13633 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13634 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013635 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013636 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013637 if (err < 0)
13638 return err;
13639 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013640 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013641}
13642
13643/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013644static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013645 const struct auto_pin_cfg *cfg)
13646{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013647 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013648}
13649
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013650static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13651 hda_nid_t nid, int pin_type)
13652{
13653 int idx;
13654
13655 alc_set_pin_output(codec, nid, pin_type);
13656 if (nid == 0x14 || nid == 0x16)
13657 idx = 0;
13658 else
13659 idx = 1;
13660 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13661}
13662
13663static void alc268_auto_init_multi_out(struct hda_codec *codec)
13664{
13665 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013666 int i;
13667
13668 for (i = 0; i < spec->autocfg.line_outs; i++) {
13669 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013670 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13671 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13672 }
13673}
13674
13675static void alc268_auto_init_hp_out(struct hda_codec *codec)
13676{
13677 struct alc_spec *spec = codec->spec;
13678 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013679 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013680
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013681 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13682 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013683 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013684 }
13685 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13686 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013687 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013688 }
13689 if (spec->autocfg.mono_out_pin)
13690 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13691 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013692}
13693
Kailang Yanga361d842007-06-05 12:30:55 +020013694static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13695{
13696 struct alc_spec *spec = codec->spec;
13697 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13698 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13699 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13700 unsigned int dac_vol1, dac_vol2;
13701
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013702 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013703 snd_hda_codec_write(codec, speaker_nid, 0,
13704 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013705 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013706 snd_hda_codec_write(codec, 0x0f, 0,
13707 AC_VERB_SET_AMP_GAIN_MUTE,
13708 AMP_IN_UNMUTE(1));
13709 snd_hda_codec_write(codec, 0x10, 0,
13710 AC_VERB_SET_AMP_GAIN_MUTE,
13711 AMP_IN_UNMUTE(1));
13712 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013713 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013714 snd_hda_codec_write(codec, 0x0f, 0,
13715 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13716 snd_hda_codec_write(codec, 0x10, 0,
13717 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13718 }
13719
13720 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013721 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013722 dac_vol2 = AMP_OUT_ZERO;
13723 else if (line_nid == 0x15)
13724 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013725 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013726 dac_vol2 = AMP_OUT_ZERO;
13727 else if (hp_nid == 0x15)
13728 dac_vol1 = AMP_OUT_ZERO;
13729 if (line_nid != 0x16 || hp_nid != 0x16 ||
13730 spec->autocfg.line_out_pins[1] != 0x16 ||
13731 spec->autocfg.line_out_pins[2] != 0x16)
13732 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13733
13734 snd_hda_codec_write(codec, 0x02, 0,
13735 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13736 snd_hda_codec_write(codec, 0x03, 0,
13737 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13738}
13739
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013740/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013741#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13742#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013743#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013744#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13745
13746/*
13747 * BIOS auto configuration
13748 */
13749static int alc268_parse_auto_config(struct hda_codec *codec)
13750{
13751 struct alc_spec *spec = codec->spec;
13752 int err;
13753 static hda_nid_t alc268_ignore[] = { 0 };
13754
13755 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13756 alc268_ignore);
13757 if (err < 0)
13758 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013759 if (!spec->autocfg.line_outs) {
13760 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13761 spec->multiout.max_channels = 2;
13762 spec->no_analog = 1;
13763 goto dig_only;
13764 }
Kailang Yanga361d842007-06-05 12:30:55 +020013765 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013766 }
Kailang Yanga361d842007-06-05 12:30:55 +020013767 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13768 if (err < 0)
13769 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013770 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013771 if (err < 0)
13772 return err;
13773
13774 spec->multiout.max_channels = 2;
13775
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013776 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013777 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013778 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013779 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013780 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013781
Takashi Iwai892981f2009-03-02 08:04:35 +010013782 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013783 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013784
Takashi Iwaid88897e2008-10-31 15:01:37 +010013785 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013786 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013787 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013788
Takashi Iwai776e1842007-08-29 15:07:11 +020013789 err = alc_auto_add_mic_boost(codec);
13790 if (err < 0)
13791 return err;
13792
Kailang Yang6227cdc2010-02-25 08:36:52 +010013793 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013794
Kailang Yanga361d842007-06-05 12:30:55 +020013795 return 1;
13796}
13797
Kailang Yanga361d842007-06-05 12:30:55 +020013798#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13799
13800/* init callback for auto-configuration model -- overriding the default init */
13801static void alc268_auto_init(struct hda_codec *codec)
13802{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013803 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013804 alc268_auto_init_multi_out(codec);
13805 alc268_auto_init_hp_out(codec);
13806 alc268_auto_init_mono_speaker_out(codec);
13807 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013808 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013809 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013810 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013811}
13812
13813/*
13814 * configuration and preset
13815 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013816static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013817 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013818 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013819 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013820 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013821 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013822 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013823 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013824 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013825#ifdef CONFIG_SND_DEBUG
13826 [ALC268_TEST] = "test",
13827#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013828 [ALC268_AUTO] = "auto",
13829};
13830
13831static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013832 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013833 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013834 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013835 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013836 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013837 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13838 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013839 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013840 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13841 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013842 /* almost compatible with toshiba but with optional digital outs;
13843 * auto-probing seems working fine
13844 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013845 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013846 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013847 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013848 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013849 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013850 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013851 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013852 {}
13853};
13854
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013855/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13856static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13857 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13858 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13859 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13860 ALC268_TOSHIBA),
13861 {}
13862};
13863
Kailang Yanga361d842007-06-05 12:30:55 +020013864static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013865 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013866 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13867 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013868 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13869 alc267_quanta_il1_verbs },
13870 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13871 .dac_nids = alc268_dac_nids,
13872 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13873 .adc_nids = alc268_adc_nids_alt,
13874 .hp_nid = 0x03,
13875 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13876 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013877 .unsol_event = alc_sku_unsol_event,
13878 .setup = alc267_quanta_il1_setup,
13879 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013880 },
Kailang Yanga361d842007-06-05 12:30:55 +020013881 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013882 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13883 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013884 .init_verbs = { alc268_base_init_verbs },
13885 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13886 .dac_nids = alc268_dac_nids,
13887 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13888 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013889 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013890 .hp_nid = 0x03,
13891 .dig_out_nid = ALC268_DIGOUT_NID,
13892 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13893 .channel_mode = alc268_modes,
13894 .input_mux = &alc268_capture_source,
13895 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013896 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013897 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013898 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013899 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13900 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013901 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13902 .dac_nids = alc268_dac_nids,
13903 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13904 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013905 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013906 .hp_nid = 0x03,
13907 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13908 .channel_mode = alc268_modes,
13909 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013910 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013911 .setup = alc268_toshiba_setup,
13912 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013913 },
13914 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013915 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013916 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013917 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13918 alc268_acer_verbs },
13919 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13920 .dac_nids = alc268_dac_nids,
13921 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13922 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013923 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013924 .hp_nid = 0x02,
13925 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13926 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013927 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013928 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013929 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013930 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013931 [ALC268_ACER_DMIC] = {
13932 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13933 alc268_beep_mixer },
13934 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13935 alc268_acer_verbs },
13936 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13937 .dac_nids = alc268_dac_nids,
13938 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13939 .adc_nids = alc268_adc_nids_alt,
13940 .capsrc_nids = alc268_capsrc_nids,
13941 .hp_nid = 0x02,
13942 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13943 .channel_mode = alc268_modes,
13944 .input_mux = &alc268_acer_dmic_capture_source,
13945 .unsol_event = alc268_acer_unsol_event,
13946 .init_hook = alc268_acer_init_hook,
13947 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013948 [ALC268_ACER_ASPIRE_ONE] = {
13949 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013950 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013951 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013952 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13953 alc268_acer_aspire_one_verbs },
13954 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13955 .dac_nids = alc268_dac_nids,
13956 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13957 .adc_nids = alc268_adc_nids_alt,
13958 .capsrc_nids = alc268_capsrc_nids,
13959 .hp_nid = 0x03,
13960 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13961 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013962 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013963 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013964 .init_hook = alc268_acer_lc_init_hook,
13965 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013966 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013967 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13968 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013969 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13970 alc268_dell_verbs },
13971 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13972 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013973 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13974 .adc_nids = alc268_adc_nids_alt,
13975 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013976 .hp_nid = 0x02,
13977 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13978 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013979 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013980 .setup = alc268_dell_setup,
13981 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013982 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013983 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013984 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13985 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013986 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13987 alc268_toshiba_verbs },
13988 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13989 .dac_nids = alc268_dac_nids,
13990 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13991 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013992 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013993 .hp_nid = 0x03,
13994 .dig_out_nid = ALC268_DIGOUT_NID,
13995 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13996 .channel_mode = alc268_modes,
13997 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013998 .setup = alc268_toshiba_setup,
13999 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010014000 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010014001#ifdef CONFIG_SND_DEBUG
14002 [ALC268_TEST] = {
14003 .mixers = { alc268_test_mixer, alc268_capture_mixer },
14004 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
14005 alc268_volume_init_verbs },
14006 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
14007 .dac_nids = alc268_dac_nids,
14008 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
14009 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010014010 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010014011 .hp_nid = 0x03,
14012 .dig_out_nid = ALC268_DIGOUT_NID,
14013 .num_channel_mode = ARRAY_SIZE(alc268_modes),
14014 .channel_mode = alc268_modes,
14015 .input_mux = &alc268_capture_source,
14016 },
14017#endif
Kailang Yanga361d842007-06-05 12:30:55 +020014018};
14019
14020static int patch_alc268(struct hda_codec *codec)
14021{
14022 struct alc_spec *spec;
14023 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010014024 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020014025
Julia Lawallef86f582009-12-19 08:18:03 +010014026 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020014027 if (spec == NULL)
14028 return -ENOMEM;
14029
14030 codec->spec = spec;
14031
14032 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
14033 alc268_models,
14034 alc268_cfg_tbl);
14035
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014036 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
14037 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010014038 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014039
Kailang Yanga361d842007-06-05 12:30:55 +020014040 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014041 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14042 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020014043 board_config = ALC268_AUTO;
14044 }
14045
14046 if (board_config == ALC268_AUTO) {
14047 /* automatic parse from the BIOS config */
14048 err = alc268_parse_auto_config(codec);
14049 if (err < 0) {
14050 alc_free(codec);
14051 return err;
14052 } else if (!err) {
14053 printk(KERN_INFO
14054 "hda_codec: Cannot set up configuration "
14055 "from BIOS. Using base mode...\n");
14056 board_config = ALC268_3ST;
14057 }
14058 }
14059
14060 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014061 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014062
Kailang Yanga361d842007-06-05 12:30:55 +020014063 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14064 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014065 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014066
Kailang Yanga361d842007-06-05 12:30:55 +020014067 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14068
Takashi Iwai22971e32009-02-10 11:56:44 +010014069 has_beep = 0;
14070 for (i = 0; i < spec->num_mixers; i++) {
14071 if (spec->mixers[i] == alc268_beep_mixer) {
14072 has_beep = 1;
14073 break;
14074 }
14075 }
14076
14077 if (has_beep) {
14078 err = snd_hda_attach_beep_device(codec, 0x1);
14079 if (err < 0) {
14080 alc_free(codec);
14081 return err;
14082 }
14083 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14084 /* override the amp caps for beep generator */
14085 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014086 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14087 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14088 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14089 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014090 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014091
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014092 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014093 /* check whether NID 0x07 is valid */
14094 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010014095 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014096
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014097 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014098 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014099 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014100 if (spec->auto_mic ||
14101 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014102 spec->adc_nids = alc268_adc_nids_alt;
14103 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014104 if (spec->auto_mic)
14105 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014106 if (spec->auto_mic || spec->input_mux->num_items == 1)
14107 add_mixer(spec, alc268_capture_nosrc_mixer);
14108 else
14109 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014110 } else {
14111 spec->adc_nids = alc268_adc_nids;
14112 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014113 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014114 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014115 /* set default input source */
14116 for (i = 0; i < spec->num_adc_nids; i++)
14117 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14118 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014119 i < spec->num_mux_defs ?
14120 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014121 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014122 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014123
14124 spec->vmaster_nid = 0x02;
14125
Kailang Yanga361d842007-06-05 12:30:55 +020014126 codec->patch_ops = alc_patch_ops;
14127 if (board_config == ALC268_AUTO)
14128 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014129
Kailang Yangbf1b0222010-10-21 08:49:56 +020014130 alc_init_jacks(codec);
14131
Kailang Yanga361d842007-06-05 12:30:55 +020014132 return 0;
14133}
14134
14135/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014136 * ALC269 channel source setting (2 channel)
14137 */
14138#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14139
14140#define alc269_dac_nids alc260_dac_nids
14141
14142static hda_nid_t alc269_adc_nids[1] = {
14143 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014144 0x08,
14145};
14146
Takashi Iwaie01bf502008-08-21 16:25:07 +020014147static hda_nid_t alc269_capsrc_nids[1] = {
14148 0x23,
14149};
14150
Kailang Yang84898e82010-02-04 14:16:14 +010014151static hda_nid_t alc269vb_adc_nids[1] = {
14152 /* ADC1 */
14153 0x09,
14154};
14155
14156static hda_nid_t alc269vb_capsrc_nids[1] = {
14157 0x22,
14158};
14159
Takashi Iwai66946352010-03-29 17:21:45 +020014160static hda_nid_t alc269_adc_candidates[] = {
14161 0x08, 0x09, 0x07,
14162};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014163
Kailang Yangf6a92242007-12-13 16:52:54 +010014164#define alc269_modes alc260_modes
14165#define alc269_capture_source alc880_lg_lw_capture_source
14166
14167static struct snd_kcontrol_new alc269_base_mixer[] = {
14168 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14169 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14170 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14171 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14173 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014174 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014175 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14176 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014177 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14179 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14180 { } /* end */
14181};
14182
Kailang Yang60db6b52008-08-26 13:13:00 +020014183static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14184 /* output mixer control */
14185 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14186 {
14187 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14188 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014189 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014190 .info = snd_hda_mixer_amp_switch_info,
14191 .get = snd_hda_mixer_amp_switch_get,
14192 .put = alc268_acer_master_sw_put,
14193 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14194 },
14195 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14196 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014197 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014198 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14199 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014200 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014201 { }
14202};
14203
Tony Vroon64154832008-11-06 15:08:49 +000014204static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14205 /* output mixer control */
14206 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14207 {
14208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14209 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014210 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014211 .info = snd_hda_mixer_amp_switch_info,
14212 .get = snd_hda_mixer_amp_switch_get,
14213 .put = alc268_acer_master_sw_put,
14214 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14215 },
14216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014218 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014219 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14220 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014221 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014222 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14223 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014224 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014225 { }
14226};
14227
Kailang Yang84898e82010-02-04 14:16:14 +010014228static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014229 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014230 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014231 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014232 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014233 { } /* end */
14234};
14235
Kailang Yang84898e82010-02-04 14:16:14 +010014236static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14237 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14238 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14239 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14240 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14241 { } /* end */
14242};
14243
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014244static struct snd_kcontrol_new alc269_asus_mixer[] = {
14245 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14246 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14247 { } /* end */
14248};
14249
Kailang Yangf6a92242007-12-13 16:52:54 +010014250/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014251static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14252 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14253 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014254 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14255 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014256 { } /* end */
14257};
14258
14259static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014260 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14261 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014262 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014263 { } /* end */
14264};
14265
Kailang Yang84898e82010-02-04 14:16:14 +010014266static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14267 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14268 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014269 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14270 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014271 { } /* end */
14272};
14273
14274static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14275 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14276 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014277 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014278 { } /* end */
14279};
14280
Takashi Iwai26f5df22008-11-03 17:39:46 +010014281/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014282#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014283
Kailang Yang60db6b52008-08-26 13:13:00 +020014284static struct hda_verb alc269_quanta_fl1_verbs[] = {
14285 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14286 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14288 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14289 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14290 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14291 { }
14292};
14293
Tony Vroon64154832008-11-06 15:08:49 +000014294static struct hda_verb alc269_lifebook_verbs[] = {
14295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14296 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14297 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14298 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14299 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14300 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14302 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14303 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14304 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14305 { }
14306};
14307
Kailang Yang60db6b52008-08-26 13:13:00 +020014308/* toggle speaker-output according to the hp-jack state */
14309static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14310{
14311 unsigned int present;
14312 unsigned char bits;
14313
Wu Fengguang864f92b2009-11-18 12:38:02 +080014314 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014315 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014316 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014317 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014318 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014319 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014320
14321 snd_hda_codec_write(codec, 0x20, 0,
14322 AC_VERB_SET_COEF_INDEX, 0x0c);
14323 snd_hda_codec_write(codec, 0x20, 0,
14324 AC_VERB_SET_PROC_COEF, 0x680);
14325
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, 0x480);
14330}
14331
Tony Vroon64154832008-11-06 15:08:49 +000014332/* toggle speaker-output according to the hp-jacks state */
14333static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14334{
14335 unsigned int present;
14336 unsigned char bits;
14337
14338 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014339 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014340
14341 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014342 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014343
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014344 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014345 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014346 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014347 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014348 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014349
14350 snd_hda_codec_write(codec, 0x20, 0,
14351 AC_VERB_SET_COEF_INDEX, 0x0c);
14352 snd_hda_codec_write(codec, 0x20, 0,
14353 AC_VERB_SET_PROC_COEF, 0x680);
14354
14355 snd_hda_codec_write(codec, 0x20, 0,
14356 AC_VERB_SET_COEF_INDEX, 0x0c);
14357 snd_hda_codec_write(codec, 0x20, 0,
14358 AC_VERB_SET_PROC_COEF, 0x480);
14359}
14360
Tony Vroon64154832008-11-06 15:08:49 +000014361static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14362{
14363 unsigned int present_laptop;
14364 unsigned int present_dock;
14365
Wu Fengguang864f92b2009-11-18 12:38:02 +080014366 present_laptop = snd_hda_jack_detect(codec, 0x18);
14367 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014368
14369 /* Laptop mic port overrides dock mic port, design decision */
14370 if (present_dock)
14371 snd_hda_codec_write(codec, 0x23, 0,
14372 AC_VERB_SET_CONNECT_SEL, 0x3);
14373 if (present_laptop)
14374 snd_hda_codec_write(codec, 0x23, 0,
14375 AC_VERB_SET_CONNECT_SEL, 0x0);
14376 if (!present_dock && !present_laptop)
14377 snd_hda_codec_write(codec, 0x23, 0,
14378 AC_VERB_SET_CONNECT_SEL, 0x1);
14379}
14380
Kailang Yang60db6b52008-08-26 13:13:00 +020014381static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14382 unsigned int res)
14383{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014384 switch (res >> 26) {
14385 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014386 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014387 break;
14388 case ALC880_MIC_EVENT:
14389 alc_mic_automute(codec);
14390 break;
14391 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014392}
14393
Tony Vroon64154832008-11-06 15:08:49 +000014394static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14395 unsigned int res)
14396{
14397 if ((res >> 26) == ALC880_HP_EVENT)
14398 alc269_lifebook_speaker_automute(codec);
14399 if ((res >> 26) == ALC880_MIC_EVENT)
14400 alc269_lifebook_mic_autoswitch(codec);
14401}
14402
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014403static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14404{
14405 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014406 spec->autocfg.hp_pins[0] = 0x15;
14407 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014408 spec->ext_mic.pin = 0x18;
14409 spec->ext_mic.mux_idx = 0;
14410 spec->int_mic.pin = 0x19;
14411 spec->int_mic.mux_idx = 1;
14412 spec->auto_mic = 1;
14413}
14414
Kailang Yang60db6b52008-08-26 13:13:00 +020014415static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14416{
14417 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014418 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014419}
14420
Tony Vroon64154832008-11-06 15:08:49 +000014421static void alc269_lifebook_init_hook(struct hda_codec *codec)
14422{
14423 alc269_lifebook_speaker_automute(codec);
14424 alc269_lifebook_mic_autoswitch(codec);
14425}
14426
Kailang Yang84898e82010-02-04 14:16:14 +010014427static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014428 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14429 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14430 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14432 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14433 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14434 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14435 {}
14436};
14437
Kailang Yang84898e82010-02-04 14:16:14 +010014438static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014439 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14440 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14441 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14443 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14444 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14445 {}
14446};
14447
Kailang Yang84898e82010-02-04 14:16:14 +010014448static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14449 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14450 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14451 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14452 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14453 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14454 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14455 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14456 {}
14457};
14458
14459static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14460 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14461 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14462 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14463 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14464 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14465 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14466 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14467 {}
14468};
14469
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014470static struct hda_verb alc271_acer_dmic_verbs[] = {
14471 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14472 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14473 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14475 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14476 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14477 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14478 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14479 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14480 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14481 { }
14482};
14483
Kailang Yang60db6b52008-08-26 13:13:00 +020014484/* toggle speaker-output according to the hp-jack state */
14485static void alc269_speaker_automute(struct hda_codec *codec)
14486{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014487 struct alc_spec *spec = codec->spec;
14488 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014489 unsigned int present;
14490 unsigned char bits;
14491
Kailang Yangebb83ee2009-12-17 12:23:00 +010014492 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014493 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014494 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014495 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014496 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014497 HDA_AMP_MUTE, bits);
Kailang Yangbf1b0222010-10-21 08:49:56 +020014498 alc_report_jack(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014499}
14500
Kailang Yang60db6b52008-08-26 13:13:00 +020014501/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014502static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014503 unsigned int res)
14504{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014505 switch (res >> 26) {
14506 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014507 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014508 break;
14509 case ALC880_MIC_EVENT:
14510 alc_mic_automute(codec);
14511 break;
14512 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014513}
14514
Kailang Yang226b1ec2010-04-09 11:01:20 +020014515static void alc269_laptop_amic_setup(struct hda_codec *codec)
14516{
14517 struct alc_spec *spec = codec->spec;
14518 spec->autocfg.hp_pins[0] = 0x15;
14519 spec->autocfg.speaker_pins[0] = 0x14;
14520 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 Yang84898e82010-02-04 14:16:14 +010014527static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014528{
14529 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014530 spec->autocfg.hp_pins[0] = 0x15;
14531 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014532 spec->ext_mic.pin = 0x18;
14533 spec->ext_mic.mux_idx = 0;
14534 spec->int_mic.pin = 0x12;
14535 spec->int_mic.mux_idx = 5;
14536 spec->auto_mic = 1;
14537}
14538
Kailang Yang226b1ec2010-04-09 11:01:20 +020014539static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014540{
14541 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014542 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014543 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014544 spec->ext_mic.pin = 0x18;
14545 spec->ext_mic.mux_idx = 0;
14546 spec->int_mic.pin = 0x19;
14547 spec->int_mic.mux_idx = 1;
14548 spec->auto_mic = 1;
14549}
14550
Kailang Yang226b1ec2010-04-09 11:01:20 +020014551static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14552{
14553 struct alc_spec *spec = codec->spec;
14554 spec->autocfg.hp_pins[0] = 0x21;
14555 spec->autocfg.speaker_pins[0] = 0x14;
14556 spec->ext_mic.pin = 0x18;
14557 spec->ext_mic.mux_idx = 0;
14558 spec->int_mic.pin = 0x12;
14559 spec->int_mic.mux_idx = 6;
14560 spec->auto_mic = 1;
14561}
14562
Kailang Yang84898e82010-02-04 14:16:14 +010014563static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014564{
14565 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014566 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014567}
14568
Kailang Yangf6a92242007-12-13 16:52:54 +010014569/*
14570 * generic initialization of ADC, input mixers and output mixers
14571 */
14572static struct hda_verb alc269_init_verbs[] = {
14573 /*
14574 * Unmute ADC0 and set the default input to mic-in
14575 */
Kailang Yang84898e82010-02-04 14:16:14 +010014576 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014577
14578 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014579 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014580 */
14581 /* set vol=0 to output mixers */
14582 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14583 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14584
14585 /* set up input amps for analog loopback */
14586 /* Amp Indices: DAC = 0, mixer = 1 */
14587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14592 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14593
14594 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14595 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14596 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14597 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14598 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14599 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14600 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14601
14602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014604
Kailang Yang84898e82010-02-04 14:16:14 +010014605 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014606 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14607 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014608 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014609
14610 /* set EAPD */
14611 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014612 { }
14613};
14614
14615static struct hda_verb alc269vb_init_verbs[] = {
14616 /*
14617 * Unmute ADC0 and set the default input to mic-in
14618 */
14619 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14620
14621 /*
14622 * Set up output mixers (0x02 - 0x03)
14623 */
14624 /* set vol=0 to output mixers */
14625 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14626 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14627
14628 /* set up input amps for analog loopback */
14629 /* Amp Indices: DAC = 0, mixer = 1 */
14630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14631 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14633 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14634 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14635 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14636
14637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14638 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14639 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14640 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14641 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14642 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14643 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14644
14645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14646 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14647
14648 /* FIXME: use Mux-type input source selection */
14649 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14650 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14651 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14652
14653 /* set EAPD */
14654 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014655 { }
14656};
14657
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014658#define alc269_auto_create_multi_out_ctls \
14659 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014660#define alc269_auto_create_input_ctls \
14661 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014662
14663#ifdef CONFIG_SND_HDA_POWER_SAVE
14664#define alc269_loopbacks alc880_loopbacks
14665#endif
14666
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014667/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014668#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14669#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14670#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14671#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14672
Takashi Iwaif03d3112009-03-05 14:18:16 +010014673static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14674 .substreams = 1,
14675 .channels_min = 2,
14676 .channels_max = 8,
14677 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14678 /* NID is set in alc_build_pcms */
14679 .ops = {
14680 .open = alc880_playback_pcm_open,
14681 .prepare = alc880_playback_pcm_prepare,
14682 .cleanup = alc880_playback_pcm_cleanup
14683 },
14684};
14685
14686static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14687 .substreams = 1,
14688 .channels_min = 2,
14689 .channels_max = 2,
14690 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14691 /* NID is set in alc_build_pcms */
14692};
14693
Takashi Iwaiad358792010-03-30 18:00:59 +020014694#ifdef CONFIG_SND_HDA_POWER_SAVE
14695static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14696{
14697 switch (codec->subsystem_id) {
14698 case 0x103c1586:
14699 return 1;
14700 }
14701 return 0;
14702}
14703
14704static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14705{
14706 /* update mute-LED according to the speaker mute state */
14707 if (nid == 0x01 || nid == 0x14) {
14708 int pinval;
14709 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14710 HDA_AMP_MUTE)
14711 pinval = 0x24;
14712 else
14713 pinval = 0x20;
14714 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014715 snd_hda_codec_update_cache(codec, 0x19, 0,
14716 AC_VERB_SET_PIN_WIDGET_CONTROL,
14717 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014718 }
14719 return alc_check_power_status(codec, nid);
14720}
14721#endif /* CONFIG_SND_HDA_POWER_SAVE */
14722
Takashi Iwai840b64c2010-07-13 22:49:01 +020014723static int alc275_setup_dual_adc(struct hda_codec *codec)
14724{
14725 struct alc_spec *spec = codec->spec;
14726
14727 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14728 return 0;
14729 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14730 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14731 if (spec->ext_mic.pin <= 0x12) {
14732 spec->private_adc_nids[0] = 0x08;
14733 spec->private_adc_nids[1] = 0x11;
14734 spec->private_capsrc_nids[0] = 0x23;
14735 spec->private_capsrc_nids[1] = 0x22;
14736 } else {
14737 spec->private_adc_nids[0] = 0x11;
14738 spec->private_adc_nids[1] = 0x08;
14739 spec->private_capsrc_nids[0] = 0x22;
14740 spec->private_capsrc_nids[1] = 0x23;
14741 }
14742 spec->adc_nids = spec->private_adc_nids;
14743 spec->capsrc_nids = spec->private_capsrc_nids;
14744 spec->num_adc_nids = 2;
14745 spec->dual_adc_switch = 1;
14746 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14747 spec->adc_nids[0], spec->adc_nids[1]);
14748 return 1;
14749 }
14750 return 0;
14751}
14752
Takashi Iwaid433a672010-09-20 15:11:54 +020014753/* different alc269-variants */
14754enum {
14755 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014756 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014757 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014758 ALC269_TYPE_ALC269VB,
14759 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014760 ALC269_TYPE_ALC271X,
14761};
14762
Kailang Yangf6a92242007-12-13 16:52:54 +010014763/*
14764 * BIOS auto configuration
14765 */
14766static int alc269_parse_auto_config(struct hda_codec *codec)
14767{
14768 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014769 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014770 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14771
14772 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14773 alc269_ignore);
14774 if (err < 0)
14775 return err;
14776
14777 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14778 if (err < 0)
14779 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014780 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14781 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14782 else
14783 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14784 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014785 if (err < 0)
14786 return err;
14787
14788 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14789
Takashi Iwai757899a2010-07-30 10:48:14 +020014790 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014791
Takashi Iwai603c4012008-07-30 15:01:44 +020014792 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014793 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014794
Takashi Iwaid433a672010-09-20 15:11:54 +020014795 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014796 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014797 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014798 } else {
14799 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014800 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014801 }
14802
Kailang Yangf6a92242007-12-13 16:52:54 +010014803 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014804 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014805
14806 if (!alc275_setup_dual_adc(codec))
14807 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14808 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014809
Takashi Iwaie01bf502008-08-21 16:25:07 +020014810 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014811 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014812 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14813 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014814
14815 err = alc_auto_add_mic_boost(codec);
14816 if (err < 0)
14817 return err;
14818
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014819 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014820 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014821
Kailang Yangf6a92242007-12-13 16:52:54 +010014822 return 1;
14823}
14824
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014825#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14826#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014827#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14828
14829
14830/* init callback for auto-configuration model -- overriding the default init */
14831static void alc269_auto_init(struct hda_codec *codec)
14832{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014833 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014834 alc269_auto_init_multi_out(codec);
14835 alc269_auto_init_hp_out(codec);
14836 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014837 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014838 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014839 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014840}
14841
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014842#ifdef SND_HDA_NEEDS_RESUME
14843static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14844{
14845 int val = alc_read_coef_idx(codec, 0x04);
14846 if (power_up)
14847 val |= 1 << 11;
14848 else
14849 val &= ~(1 << 11);
14850 alc_write_coef_idx(codec, 0x04, val);
14851}
14852
Kailang Yang977ddd62010-09-15 10:02:29 +020014853#ifdef CONFIG_SND_HDA_POWER_SAVE
14854static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14855{
14856 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014857
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014858 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14859 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014860 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014861 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014862 msleep(150);
14863 }
14864
14865 alc_shutup(codec);
14866 if (spec && spec->power_hook)
14867 spec->power_hook(codec);
14868 return 0;
14869}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014870#endif /* CONFIG_SND_HDA_POWER_SAVE */
14871
Kailang Yang977ddd62010-09-15 10:02:29 +020014872static int alc269_resume(struct hda_codec *codec)
14873{
Kailang Yang977ddd62010-09-15 10:02:29 +020014874 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014875 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014876 msleep(150);
14877 }
14878
14879 codec->patch_ops.init(codec);
14880
14881 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014882 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014883 msleep(200);
14884 }
14885
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014886 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14887 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014888
14889 snd_hda_codec_resume_amp(codec);
14890 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014891 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014892 return 0;
14893}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014894#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014895
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014896static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014897 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014898{
14899 int coef;
14900
Takashi Iwai58701122011-01-13 15:41:45 +010014901 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014902 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014903 coef = alc_read_coef_idx(codec, 0x1e);
14904 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14905}
14906
Takashi Iwaiff818c22010-04-12 08:59:25 +020014907enum {
14908 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014909 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014910 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014911 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014912 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014913 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014914 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014915};
14916
Takashi Iwaiff818c22010-04-12 08:59:25 +020014917static const struct alc_fixup alc269_fixups[] = {
14918 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014919 .type = ALC_FIXUP_VERBS,
14920 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014921 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14922 {}
14923 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014924 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014925 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014926 .type = ALC_FIXUP_VERBS,
14927 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014928 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14929 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14930 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14931 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014932 },
14933 .chained = true,
14934 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014935 },
David Henningsson145a9022010-09-16 10:07:53 +020014936 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014937 .type = ALC_FIXUP_VERBS,
14938 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014939 /* Enables internal speaker */
14940 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14941 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14942 {}
14943 }
14944 },
David Henningsson022c92b2010-12-17 20:43:04 +010014945 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014946 .type = ALC_FIXUP_SKU,
14947 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014948 },
David Henningssonac612402010-12-15 09:18:18 +010014949 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014950 .type = ALC_FIXUP_PINS,
14951 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014952 { 0x17, 0x99130111 }, /* subwoofer */
14953 { }
14954 }
14955 },
Kailang Yang357f9152011-01-12 08:12:52 +010014956 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014957 .type = ALC_FIXUP_VERBS,
14958 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014959 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14960 {}
14961 }
14962 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014963 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014964 .type = ALC_FIXUP_FUNC,
14965 .v.func = alc269_fixup_hweq,
14966 .chained = true,
14967 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014968 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014969};
14970
14971static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014972 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014973 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14974 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014975 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014976 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson022c92b2010-12-17 20:43:04 +010014977 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014978 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14979 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14980 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14981 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014982 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014983 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014984 {}
14985};
14986
14987
Kailang Yangf6a92242007-12-13 16:52:54 +010014988/*
14989 * configuration and preset
14990 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014991static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014992 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014993 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014994 [ALC269_AMIC] = "laptop-amic",
14995 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014996 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014997 [ALC269_LIFEBOOK] = "lifebook",
14998 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014999};
15000
15001static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020015002 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015003 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020015004 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010015005 ALC269_AMIC),
15006 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
15007 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
15008 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
15009 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
15010 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
15011 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
15012 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
15013 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
15014 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080015015 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010015016 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
15017 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
15018 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
15019 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
15020 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
15021 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
15022 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
15023 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
15024 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
15025 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
15026 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
15027 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
15028 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
15029 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
15030 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
15031 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
15032 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
15033 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
15034 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
15035 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
15036 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
15037 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
15038 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
15039 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
15040 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
15041 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020015042 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010015043 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020015044 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010015045 ALC269_DMIC),
15046 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
15047 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020015048 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000015049 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010015050 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
15051 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
15052 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
15053 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
15054 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
15055 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010015056 {}
15057};
15058
15059static struct alc_config_preset alc269_presets[] = {
15060 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015061 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010015062 .init_verbs = { alc269_init_verbs },
15063 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15064 .dac_nids = alc269_dac_nids,
15065 .hp_nid = 0x03,
15066 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15067 .channel_mode = alc269_modes,
15068 .input_mux = &alc269_capture_source,
15069 },
Kailang Yang60db6b52008-08-26 13:13:00 +020015070 [ALC269_QUANTA_FL1] = {
15071 .mixers = { alc269_quanta_fl1_mixer },
15072 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15073 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15074 .dac_nids = alc269_dac_nids,
15075 .hp_nid = 0x03,
15076 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15077 .channel_mode = alc269_modes,
15078 .input_mux = &alc269_capture_source,
15079 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015080 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015081 .init_hook = alc269_quanta_fl1_init_hook,
15082 },
Kailang Yang84898e82010-02-04 14:16:14 +010015083 [ALC269_AMIC] = {
15084 .mixers = { alc269_laptop_mixer },
15085 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015086 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015087 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015088 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15089 .dac_nids = alc269_dac_nids,
15090 .hp_nid = 0x03,
15091 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15092 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015093 .unsol_event = alc269_laptop_unsol_event,
15094 .setup = alc269_laptop_amic_setup,
15095 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015096 },
Kailang Yang84898e82010-02-04 14:16:14 +010015097 [ALC269_DMIC] = {
15098 .mixers = { alc269_laptop_mixer },
15099 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015100 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015101 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015102 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15103 .dac_nids = alc269_dac_nids,
15104 .hp_nid = 0x03,
15105 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15106 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015107 .unsol_event = alc269_laptop_unsol_event,
15108 .setup = alc269_laptop_dmic_setup,
15109 .init_hook = alc269_laptop_inithook,
15110 },
15111 [ALC269VB_AMIC] = {
15112 .mixers = { alc269vb_laptop_mixer },
15113 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15114 .init_verbs = { alc269vb_init_verbs,
15115 alc269vb_laptop_amic_init_verbs },
15116 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15117 .dac_nids = alc269_dac_nids,
15118 .hp_nid = 0x03,
15119 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15120 .channel_mode = alc269_modes,
15121 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015122 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010015123 .init_hook = alc269_laptop_inithook,
15124 },
15125 [ALC269VB_DMIC] = {
15126 .mixers = { alc269vb_laptop_mixer },
15127 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15128 .init_verbs = { alc269vb_init_verbs,
15129 alc269vb_laptop_dmic_init_verbs },
15130 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15131 .dac_nids = alc269_dac_nids,
15132 .hp_nid = 0x03,
15133 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15134 .channel_mode = alc269_modes,
15135 .unsol_event = alc269_laptop_unsol_event,
15136 .setup = alc269vb_laptop_dmic_setup,
15137 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015138 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015139 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015140 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015141 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015142 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015143 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015144 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15145 .dac_nids = alc269_dac_nids,
15146 .hp_nid = 0x03,
15147 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15148 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015149 .unsol_event = alc269_laptop_unsol_event,
15150 .setup = alc269_laptop_dmic_setup,
15151 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015152 },
Tony Vroon64154832008-11-06 15:08:49 +000015153 [ALC269_LIFEBOOK] = {
15154 .mixers = { alc269_lifebook_mixer },
15155 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15156 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15157 .dac_nids = alc269_dac_nids,
15158 .hp_nid = 0x03,
15159 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15160 .channel_mode = alc269_modes,
15161 .input_mux = &alc269_capture_source,
15162 .unsol_event = alc269_lifebook_unsol_event,
15163 .init_hook = alc269_lifebook_init_hook,
15164 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015165 [ALC271_ACER] = {
15166 .mixers = { alc269_asus_mixer },
15167 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15168 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15169 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15170 .dac_nids = alc269_dac_nids,
15171 .adc_nids = alc262_dmic_adc_nids,
15172 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15173 .capsrc_nids = alc262_dmic_capsrc_nids,
15174 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15175 .channel_mode = alc269_modes,
15176 .input_mux = &alc269_capture_source,
15177 .dig_out_nid = ALC880_DIGOUT_NID,
15178 .unsol_event = alc_sku_unsol_event,
15179 .setup = alc269vb_laptop_dmic_setup,
15180 .init_hook = alc_inithook,
15181 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015182};
15183
Kailang Yang977ddd62010-09-15 10:02:29 +020015184static int alc269_fill_coef(struct hda_codec *codec)
15185{
15186 int val;
15187
15188 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15189 alc_write_coef_idx(codec, 0xf, 0x960b);
15190 alc_write_coef_idx(codec, 0xe, 0x8817);
15191 }
15192
15193 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15194 alc_write_coef_idx(codec, 0xf, 0x960b);
15195 alc_write_coef_idx(codec, 0xe, 0x8814);
15196 }
15197
15198 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15199 val = alc_read_coef_idx(codec, 0x04);
15200 /* Power up output pin */
15201 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15202 }
15203
15204 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15205 val = alc_read_coef_idx(codec, 0xd);
15206 if ((val & 0x0c00) >> 10 != 0x1) {
15207 /* Capless ramp up clock control */
15208 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15209 }
15210 val = alc_read_coef_idx(codec, 0x17);
15211 if ((val & 0x01c0) >> 6 != 0x4) {
15212 /* Class D power on reset */
15213 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15214 }
15215 }
15216 return 0;
15217}
15218
Kailang Yangf6a92242007-12-13 16:52:54 +010015219static int patch_alc269(struct hda_codec *codec)
15220{
15221 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015222 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015223 int err;
15224
15225 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15226 if (spec == NULL)
15227 return -ENOMEM;
15228
15229 codec->spec = spec;
15230
Kailang Yangda00c242010-03-19 11:23:45 +010015231 alc_auto_parse_customize_define(codec);
15232
Kailang Yangc793bec2010-12-21 09:14:13 +010015233 if (codec->vendor_id == 0x10ec0269) {
15234 coef = alc_read_coef_idx(codec, 0);
15235 if ((coef & 0x00f0) == 0x0010) {
15236 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15237 spec->cdefine.platform_type == 1) {
15238 alc_codec_rename(codec, "ALC271X");
15239 spec->codec_variant = ALC269_TYPE_ALC271X;
15240 } else if ((coef & 0xf000) == 0x1000) {
15241 spec->codec_variant = ALC269_TYPE_ALC270;
15242 } else if ((coef & 0xf000) == 0x2000) {
15243 alc_codec_rename(codec, "ALC259");
15244 spec->codec_variant = ALC269_TYPE_ALC259;
15245 } else if ((coef & 0xf000) == 0x3000) {
15246 alc_codec_rename(codec, "ALC258");
15247 spec->codec_variant = ALC269_TYPE_ALC258;
15248 } else {
15249 alc_codec_rename(codec, "ALC269VB");
15250 spec->codec_variant = ALC269_TYPE_ALC269VB;
15251 }
15252 } else
15253 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15254 alc269_fill_coef(codec);
15255 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015256
Kailang Yangf6a92242007-12-13 16:52:54 +010015257 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15258 alc269_models,
15259 alc269_cfg_tbl);
15260
15261 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015262 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15263 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015264 board_config = ALC269_AUTO;
15265 }
15266
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015267 if (board_config == ALC269_AUTO) {
15268 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15269 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15270 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015271
Kailang Yangf6a92242007-12-13 16:52:54 +010015272 if (board_config == ALC269_AUTO) {
15273 /* automatic parse from the BIOS config */
15274 err = alc269_parse_auto_config(codec);
15275 if (err < 0) {
15276 alc_free(codec);
15277 return err;
15278 } else if (!err) {
15279 printk(KERN_INFO
15280 "hda_codec: Cannot set up configuration "
15281 "from BIOS. Using base mode...\n");
15282 board_config = ALC269_BASIC;
15283 }
15284 }
15285
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015286 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015287 err = snd_hda_attach_beep_device(codec, 0x1);
15288 if (err < 0) {
15289 alc_free(codec);
15290 return err;
15291 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015292 }
15293
Kailang Yangf6a92242007-12-13 16:52:54 +010015294 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015295 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015296
Kailang Yang84898e82010-02-04 14:16:14 +010015297 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015298 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15299 * fix the sample rate of analog I/O to 44.1kHz
15300 */
15301 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15302 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015303 } else if (spec->dual_adc_switch) {
15304 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15305 /* switch ADC dynamically */
15306 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015307 } else {
15308 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15309 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15310 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015311 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15312 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15313
Takashi Iwai66946352010-03-29 17:21:45 +020015314 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015315 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015316 spec->adc_nids = alc269_adc_nids;
15317 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15318 spec->capsrc_nids = alc269_capsrc_nids;
15319 } else {
15320 spec->adc_nids = alc269vb_adc_nids;
15321 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15322 spec->capsrc_nids = alc269vb_capsrc_nids;
15323 }
Kailang Yang84898e82010-02-04 14:16:14 +010015324 }
15325
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015326 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015327 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015328 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015329 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015330
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015331 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015332
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015333 spec->vmaster_nid = 0x02;
15334
Kailang Yangf6a92242007-12-13 16:52:54 +010015335 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015336#ifdef CONFIG_SND_HDA_POWER_SAVE
15337 codec->patch_ops.suspend = alc269_suspend;
15338#endif
15339#ifdef SND_HDA_NEEDS_RESUME
15340 codec->patch_ops.resume = alc269_resume;
15341#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015342 if (board_config == ALC269_AUTO)
15343 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015344
15345 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015346#ifdef CONFIG_SND_HDA_POWER_SAVE
15347 if (!spec->loopback.amplist)
15348 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015349 if (alc269_mic2_for_mute_led(codec))
15350 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015351#endif
15352
15353 return 0;
15354}
15355
15356/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015357 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15358 */
15359
15360/*
15361 * set the path ways for 2 channel output
15362 * need to set the codec line out and mic 1 pin widgets to inputs
15363 */
15364static struct hda_verb alc861_threestack_ch2_init[] = {
15365 /* set pin widget 1Ah (line in) for input */
15366 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015367 /* set pin widget 18h (mic1/2) for input, for mic also enable
15368 * the vref
15369 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015370 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15371
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015372 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15373#if 0
15374 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15375 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15376#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015377 { } /* end */
15378};
15379/*
15380 * 6ch mode
15381 * need to set the codec line out and mic 1 pin widgets to outputs
15382 */
15383static struct hda_verb alc861_threestack_ch6_init[] = {
15384 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15385 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15386 /* set pin widget 18h (mic1) for output (CLFE)*/
15387 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15388
15389 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015390 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015391
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015392 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15393#if 0
15394 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15395 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15396#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015397 { } /* end */
15398};
15399
15400static struct hda_channel_mode alc861_threestack_modes[2] = {
15401 { 2, alc861_threestack_ch2_init },
15402 { 6, alc861_threestack_ch6_init },
15403};
Takashi Iwai22309c32006-08-09 16:57:28 +020015404/* Set mic1 as input and unmute the mixer */
15405static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15406 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15407 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15408 { } /* end */
15409};
15410/* Set mic1 as output and mute mixer */
15411static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15412 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15413 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15414 { } /* end */
15415};
15416
15417static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15418 { 2, alc861_uniwill_m31_ch2_init },
15419 { 4, alc861_uniwill_m31_ch4_init },
15420};
Kailang Yangdf694da2005-12-05 19:42:22 +010015421
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015422/* Set mic1 and line-in as input and unmute the mixer */
15423static struct hda_verb alc861_asus_ch2_init[] = {
15424 /* set pin widget 1Ah (line in) for input */
15425 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015426 /* set pin widget 18h (mic1/2) for input, for mic also enable
15427 * the vref
15428 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015429 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15430
15431 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15432#if 0
15433 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15434 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15435#endif
15436 { } /* end */
15437};
15438/* Set mic1 nad line-in as output and mute mixer */
15439static struct hda_verb alc861_asus_ch6_init[] = {
15440 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15441 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15442 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15443 /* set pin widget 18h (mic1) for output (CLFE)*/
15444 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15445 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15446 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15447 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15448
15449 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15450#if 0
15451 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15452 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15453#endif
15454 { } /* end */
15455};
15456
15457static struct hda_channel_mode alc861_asus_modes[2] = {
15458 { 2, alc861_asus_ch2_init },
15459 { 6, alc861_asus_ch6_init },
15460};
15461
Kailang Yangdf694da2005-12-05 19:42:22 +010015462/* patch-ALC861 */
15463
15464static struct snd_kcontrol_new alc861_base_mixer[] = {
15465 /* output mixer control */
15466 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15467 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15468 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15469 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15470 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15471
15472 /*Input mixer control */
15473 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15474 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15475 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15476 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15477 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15478 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15479 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15480 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15481 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15482 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015483
Kailang Yangdf694da2005-12-05 19:42:22 +010015484 { } /* end */
15485};
15486
15487static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15488 /* output mixer control */
15489 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15490 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15491 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15492 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15493 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15494
15495 /* Input mixer control */
15496 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15497 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15498 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15499 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15500 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15501 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15502 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15503 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015506
Kailang Yangdf694da2005-12-05 19:42:22 +010015507 {
15508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15509 .name = "Channel Mode",
15510 .info = alc_ch_mode_info,
15511 .get = alc_ch_mode_get,
15512 .put = alc_ch_mode_put,
15513 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15514 },
15515 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015516};
15517
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015518static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015519 /* output mixer control */
15520 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15522 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015523
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015524 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015525};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015526
Takashi Iwai22309c32006-08-09 16:57:28 +020015527static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15528 /* output mixer control */
15529 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15530 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15531 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15532 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15533 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15534
15535 /* Input mixer control */
15536 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15537 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15538 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15539 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15540 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15541 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15542 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15543 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15544 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015546
Takashi Iwai22309c32006-08-09 16:57:28 +020015547 {
15548 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15549 .name = "Channel Mode",
15550 .info = alc_ch_mode_info,
15551 .get = alc_ch_mode_get,
15552 .put = alc_ch_mode_put,
15553 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15554 },
15555 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015556};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015557
15558static struct snd_kcontrol_new alc861_asus_mixer[] = {
15559 /* output mixer control */
15560 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15561 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15562 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15563 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15564 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15565
15566 /* Input mixer control */
15567 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15568 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15569 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15570 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15571 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15572 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15574 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15575 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015576 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15577
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015578 {
15579 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15580 .name = "Channel Mode",
15581 .info = alc_ch_mode_info,
15582 .get = alc_ch_mode_get,
15583 .put = alc_ch_mode_put,
15584 .private_value = ARRAY_SIZE(alc861_asus_modes),
15585 },
15586 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015587};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015588
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015589/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015590static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015591 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15592 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015593 { }
15594};
15595
Kailang Yangdf694da2005-12-05 19:42:22 +010015596/*
15597 * generic initialization of ADC, input mixers and output mixers
15598 */
15599static struct hda_verb alc861_base_init_verbs[] = {
15600 /*
15601 * Unmute ADC0 and set the default input to mic-in
15602 */
15603 /* port-A for surround (rear panel) */
15604 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15605 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15606 /* port-B for mic-in (rear panel) with vref */
15607 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15608 /* port-C for line-in (rear panel) */
15609 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15610 /* port-D for Front */
15611 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15612 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15613 /* port-E for HP out (front panel) */
15614 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15615 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015616 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015617 /* port-F for mic-in (front panel) with vref */
15618 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15619 /* port-G for CLFE (rear panel) */
15620 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15621 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15622 /* port-H for side (rear panel) */
15623 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15624 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15625 /* CD-in */
15626 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15627 /* route front mic to ADC1*/
15628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015630
Kailang Yangdf694da2005-12-05 19:42:22 +010015631 /* Unmute DAC0~3 & spdif out*/
15632 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15633 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15634 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15635 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015637
Kailang Yangdf694da2005-12-05 19:42:22 +010015638 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15639 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15640 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15641 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15642 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015643
Kailang Yangdf694da2005-12-05 19:42:22 +010015644 /* Unmute Stereo Mixer 15 */
15645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015649
15650 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15652 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15653 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15654 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15655 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15656 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15657 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015658 /* hp used DAC 3 (Front) */
15659 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015660 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15661
15662 { }
15663};
15664
15665static struct hda_verb alc861_threestack_init_verbs[] = {
15666 /*
15667 * Unmute ADC0 and set the default input to mic-in
15668 */
15669 /* port-A for surround (rear panel) */
15670 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15671 /* port-B for mic-in (rear panel) with vref */
15672 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15673 /* port-C for line-in (rear panel) */
15674 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15675 /* port-D for Front */
15676 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15677 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15678 /* port-E for HP out (front panel) */
15679 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15680 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015681 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015682 /* port-F for mic-in (front panel) with vref */
15683 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15684 /* port-G for CLFE (rear panel) */
15685 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15686 /* port-H for side (rear panel) */
15687 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15688 /* CD-in */
15689 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15690 /* route front mic to ADC1*/
15691 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15692 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15693 /* Unmute DAC0~3 & spdif out*/
15694 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15695 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15696 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15697 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015699
Kailang Yangdf694da2005-12-05 19:42:22 +010015700 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15701 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15702 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15703 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15704 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015705
Kailang Yangdf694da2005-12-05 19:42:22 +010015706 /* Unmute Stereo Mixer 15 */
15707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015711
15712 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15715 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15716 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15718 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15719 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015720 /* hp used DAC 3 (Front) */
15721 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15723 { }
15724};
Takashi Iwai22309c32006-08-09 16:57:28 +020015725
15726static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15727 /*
15728 * Unmute ADC0 and set the default input to mic-in
15729 */
15730 /* port-A for surround (rear panel) */
15731 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15732 /* port-B for mic-in (rear panel) with vref */
15733 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15734 /* port-C for line-in (rear panel) */
15735 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15736 /* port-D for Front */
15737 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15738 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15739 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015740 /* this has to be set to VREF80 */
15741 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015742 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015743 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015744 /* port-F for mic-in (front panel) with vref */
15745 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15746 /* port-G for CLFE (rear panel) */
15747 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15748 /* port-H for side (rear panel) */
15749 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15750 /* CD-in */
15751 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15752 /* route front mic to ADC1*/
15753 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15754 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15755 /* Unmute DAC0~3 & spdif out*/
15756 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15757 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15758 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15759 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15760 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015761
Takashi Iwai22309c32006-08-09 16:57:28 +020015762 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15763 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15764 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15765 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15766 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015767
Takashi Iwai22309c32006-08-09 16:57:28 +020015768 /* Unmute Stereo Mixer 15 */
15769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015773
15774 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15776 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15777 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15778 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15779 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15780 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015782 /* hp used DAC 3 (Front) */
15783 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015784 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15785 { }
15786};
15787
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015788static struct hda_verb alc861_asus_init_verbs[] = {
15789 /*
15790 * Unmute ADC0 and set the default input to mic-in
15791 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015792 /* port-A for surround (rear panel)
15793 * according to codec#0 this is the HP jack
15794 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015795 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15796 /* route front PCM to HP */
15797 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15798 /* port-B for mic-in (rear panel) with vref */
15799 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15800 /* port-C for line-in (rear panel) */
15801 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15802 /* port-D for Front */
15803 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15804 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15805 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015806 /* this has to be set to VREF80 */
15807 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015808 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015809 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015810 /* port-F for mic-in (front panel) with vref */
15811 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15812 /* port-G for CLFE (rear panel) */
15813 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15814 /* port-H for side (rear panel) */
15815 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15816 /* CD-in */
15817 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15818 /* route front mic to ADC1*/
15819 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15820 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15821 /* Unmute DAC0~3 & spdif out*/
15822 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15823 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15824 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15825 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15827 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15828 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15829 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15830 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15831 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015832
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015833 /* Unmute Stereo Mixer 15 */
15834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015838
15839 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15840 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15841 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15842 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15843 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15844 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15845 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15846 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015847 /* hp used DAC 3 (Front) */
15848 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15850 { }
15851};
15852
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015853/* additional init verbs for ASUS laptops */
15854static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15855 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15856 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15857 { }
15858};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015859
Kailang Yangdf694da2005-12-05 19:42:22 +010015860/*
15861 * generic initialization of ADC, input mixers and output mixers
15862 */
15863static struct hda_verb alc861_auto_init_verbs[] = {
15864 /*
15865 * Unmute ADC0 and set the default input to mic-in
15866 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015867 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015869
Kailang Yangdf694da2005-12-05 19:42:22 +010015870 /* Unmute DAC0~3 & spdif out*/
15871 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15872 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15873 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15874 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015876
Kailang Yangdf694da2005-12-05 19:42:22 +010015877 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15878 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15879 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15880 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15881 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015882
Kailang Yangdf694da2005-12-05 19:42:22 +010015883 /* Unmute Stereo Mixer 15 */
15884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15888
Takashi Iwai1c209302009-07-22 15:17:45 +020015889 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15890 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15891 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15892 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15893 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15894 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15895 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15896 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015897
15898 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15899 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015900 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15901 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015902 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15903 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015904 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15905 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015906
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015907 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015908
15909 { }
15910};
15911
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015912static struct hda_verb alc861_toshiba_init_verbs[] = {
15913 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015914
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015915 { }
15916};
15917
15918/* toggle speaker-output according to the hp-jack state */
15919static void alc861_toshiba_automute(struct hda_codec *codec)
15920{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015921 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015922
Takashi Iwai47fd8302007-08-10 17:11:07 +020015923 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15924 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15925 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15926 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015927}
15928
15929static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15930 unsigned int res)
15931{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015932 if ((res >> 26) == ALC880_HP_EVENT)
15933 alc861_toshiba_automute(codec);
15934}
15935
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015936/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015937#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15938#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15939#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15940#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15941
15942
15943#define ALC861_DIGOUT_NID 0x07
15944
15945static struct hda_channel_mode alc861_8ch_modes[1] = {
15946 { 8, NULL }
15947};
15948
15949static hda_nid_t alc861_dac_nids[4] = {
15950 /* front, surround, clfe, side */
15951 0x03, 0x06, 0x05, 0x04
15952};
15953
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015954static hda_nid_t alc660_dac_nids[3] = {
15955 /* front, clfe, surround */
15956 0x03, 0x05, 0x06
15957};
15958
Kailang Yangdf694da2005-12-05 19:42:22 +010015959static hda_nid_t alc861_adc_nids[1] = {
15960 /* ADC0-2 */
15961 0x08,
15962};
15963
15964static struct hda_input_mux alc861_capture_source = {
15965 .num_items = 5,
15966 .items = {
15967 { "Mic", 0x0 },
15968 { "Front Mic", 0x3 },
15969 { "Line", 0x1 },
15970 { "CD", 0x4 },
15971 { "Mixer", 0x5 },
15972 },
15973};
15974
Takashi Iwai1c209302009-07-22 15:17:45 +020015975static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15976{
15977 struct alc_spec *spec = codec->spec;
15978 hda_nid_t mix, srcs[5];
15979 int i, j, num;
15980
15981 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15982 return 0;
15983 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15984 if (num < 0)
15985 return 0;
15986 for (i = 0; i < num; i++) {
15987 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015988 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015989 if (type != AC_WID_AUD_OUT)
15990 continue;
15991 for (j = 0; j < spec->multiout.num_dacs; j++)
15992 if (spec->multiout.dac_nids[j] == srcs[i])
15993 break;
15994 if (j >= spec->multiout.num_dacs)
15995 return srcs[i];
15996 }
15997 return 0;
15998}
15999
Kailang Yangdf694da2005-12-05 19:42:22 +010016000/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020016001static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016002 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016003{
Takashi Iwai1c209302009-07-22 15:17:45 +020016004 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016005 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020016006 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010016007
16008 spec->multiout.dac_nids = spec->private_dac_nids;
16009 for (i = 0; i < cfg->line_outs; i++) {
16010 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020016011 dac = alc861_look_for_dac(codec, nid);
16012 if (!dac)
16013 continue;
16014 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010016015 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016016 return 0;
16017}
16018
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016019static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
16020 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016021{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016022 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020016023 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
16024}
16025
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016026#define alc861_create_out_sw(codec, pfx, nid, chs) \
16027 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
16028
Takashi Iwai1c209302009-07-22 15:17:45 +020016029/* add playback controls from the parsed DAC table */
16030static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
16031 const struct auto_pin_cfg *cfg)
16032{
16033 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010016034 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016035 "Front", "Surround", NULL /*CLFE*/, "Side"
16036 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016037 const char *pfx = alc_get_line_out_pfx(cfg, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010016038 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020016039 int i, err;
16040
Kailang Yangdf694da2005-12-05 19:42:22 +010016041 for (i = 0; i < cfg->line_outs; i++) {
16042 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016043 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010016044 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016045 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010016046 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020016047 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016048 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016049 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016050 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016051 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016052 return err;
16053 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016054 const char *name = pfx;
16055 if (!name)
16056 name = chname[i];
16057 err = __alc861_create_out_sw(codec, name, nid, i, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016058 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016059 return err;
16060 }
16061 }
16062 return 0;
16063}
16064
Takashi Iwai1c209302009-07-22 15:17:45 +020016065static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016066{
Takashi Iwai1c209302009-07-22 15:17:45 +020016067 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016068 int err;
16069 hda_nid_t nid;
16070
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016071 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016072 return 0;
16073
16074 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016075 nid = alc861_look_for_dac(codec, pin);
16076 if (nid) {
16077 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16078 if (err < 0)
16079 return err;
16080 spec->multiout.hp_nid = nid;
16081 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016082 }
16083 return 0;
16084}
16085
16086/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016087static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016088 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016089{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016090 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016091}
16092
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016093static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16094 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016095 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016096{
Takashi Iwai1c209302009-07-22 15:17:45 +020016097 hda_nid_t mix, srcs[5];
16098 int i, num;
16099
Jacek Luczak564c5be2008-05-03 18:41:23 +020016100 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16101 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016102 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016103 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016104 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16105 return;
16106 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16107 if (num < 0)
16108 return;
16109 for (i = 0; i < num; i++) {
16110 unsigned int mute;
16111 if (srcs[i] == dac || srcs[i] == 0x15)
16112 mute = AMP_IN_UNMUTE(i);
16113 else
16114 mute = AMP_IN_MUTE(i);
16115 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16116 mute);
16117 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016118}
16119
16120static void alc861_auto_init_multi_out(struct hda_codec *codec)
16121{
16122 struct alc_spec *spec = codec->spec;
16123 int i;
16124
16125 for (i = 0; i < spec->autocfg.line_outs; i++) {
16126 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016127 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016128 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016129 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016130 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016131 }
16132}
16133
16134static void alc861_auto_init_hp_out(struct hda_codec *codec)
16135{
16136 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016137
Takashi Iwai15870f02009-10-05 08:25:13 +020016138 if (spec->autocfg.hp_outs)
16139 alc861_auto_set_output_and_unmute(codec,
16140 spec->autocfg.hp_pins[0],
16141 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016142 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016143 if (spec->autocfg.speaker_outs)
16144 alc861_auto_set_output_and_unmute(codec,
16145 spec->autocfg.speaker_pins[0],
16146 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016147 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016148}
16149
16150static void alc861_auto_init_analog_input(struct hda_codec *codec)
16151{
16152 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016153 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016154 int i;
16155
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016156 for (i = 0; i < cfg->num_inputs; i++) {
16157 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016158 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016159 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016160 }
16161}
16162
16163/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016164/* return 1 if successful, 0 if the proper config is not found,
16165 * or a negative error code
16166 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016167static int alc861_parse_auto_config(struct hda_codec *codec)
16168{
16169 struct alc_spec *spec = codec->spec;
16170 int err;
16171 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16172
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016173 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16174 alc861_ignore);
16175 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016176 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016177 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016178 return 0; /* can't find valid BIOS pin config */
16179
Takashi Iwai1c209302009-07-22 15:17:45 +020016180 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016181 if (err < 0)
16182 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016183 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016184 if (err < 0)
16185 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016186 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016187 if (err < 0)
16188 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016189 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016190 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016191 return err;
16192
16193 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16194
Takashi Iwai757899a2010-07-30 10:48:14 +020016195 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016196
Takashi Iwai603c4012008-07-30 15:01:44 +020016197 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016198 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016199
Takashi Iwaid88897e2008-10-31 15:01:37 +010016200 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016201
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016202 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016203 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016204
16205 spec->adc_nids = alc861_adc_nids;
16206 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016207 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016208
Kailang Yang6227cdc2010-02-25 08:36:52 +010016209 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016210
Kailang Yangdf694da2005-12-05 19:42:22 +010016211 return 1;
16212}
16213
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016214/* additional initialization for auto-configuration model */
16215static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016216{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016217 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016218 alc861_auto_init_multi_out(codec);
16219 alc861_auto_init_hp_out(codec);
16220 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016221 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016222 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016223 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016224}
16225
Takashi Iwaicb53c622007-08-10 17:21:45 +020016226#ifdef CONFIG_SND_HDA_POWER_SAVE
16227static struct hda_amp_list alc861_loopbacks[] = {
16228 { 0x15, HDA_INPUT, 0 },
16229 { 0x15, HDA_INPUT, 1 },
16230 { 0x15, HDA_INPUT, 2 },
16231 { 0x15, HDA_INPUT, 3 },
16232 { } /* end */
16233};
16234#endif
16235
Kailang Yangdf694da2005-12-05 19:42:22 +010016236
16237/*
16238 * configuration and preset
16239 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016240static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016241 [ALC861_3ST] = "3stack",
16242 [ALC660_3ST] = "3stack-660",
16243 [ALC861_3ST_DIG] = "3stack-dig",
16244 [ALC861_6ST_DIG] = "6stack-dig",
16245 [ALC861_UNIWILL_M31] = "uniwill-m31",
16246 [ALC861_TOSHIBA] = "toshiba",
16247 [ALC861_ASUS] = "asus",
16248 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16249 [ALC861_AUTO] = "auto",
16250};
16251
16252static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016253 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016254 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16255 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16256 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016257 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016258 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016259 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016260 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16261 * Any other models that need this preset?
16262 */
16263 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016264 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16265 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016266 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16267 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16268 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16269 /* FIXME: the below seems conflict */
16270 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16271 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16272 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016273 {}
16274};
16275
16276static struct alc_config_preset alc861_presets[] = {
16277 [ALC861_3ST] = {
16278 .mixers = { alc861_3ST_mixer },
16279 .init_verbs = { alc861_threestack_init_verbs },
16280 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16281 .dac_nids = alc861_dac_nids,
16282 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16283 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016284 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016285 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16286 .adc_nids = alc861_adc_nids,
16287 .input_mux = &alc861_capture_source,
16288 },
16289 [ALC861_3ST_DIG] = {
16290 .mixers = { alc861_base_mixer },
16291 .init_verbs = { alc861_threestack_init_verbs },
16292 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16293 .dac_nids = alc861_dac_nids,
16294 .dig_out_nid = ALC861_DIGOUT_NID,
16295 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16296 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016297 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016298 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16299 .adc_nids = alc861_adc_nids,
16300 .input_mux = &alc861_capture_source,
16301 },
16302 [ALC861_6ST_DIG] = {
16303 .mixers = { alc861_base_mixer },
16304 .init_verbs = { alc861_base_init_verbs },
16305 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16306 .dac_nids = alc861_dac_nids,
16307 .dig_out_nid = ALC861_DIGOUT_NID,
16308 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16309 .channel_mode = alc861_8ch_modes,
16310 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16311 .adc_nids = alc861_adc_nids,
16312 .input_mux = &alc861_capture_source,
16313 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016314 [ALC660_3ST] = {
16315 .mixers = { alc861_3ST_mixer },
16316 .init_verbs = { alc861_threestack_init_verbs },
16317 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16318 .dac_nids = alc660_dac_nids,
16319 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16320 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016321 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016322 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16323 .adc_nids = alc861_adc_nids,
16324 .input_mux = &alc861_capture_source,
16325 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016326 [ALC861_UNIWILL_M31] = {
16327 .mixers = { alc861_uniwill_m31_mixer },
16328 .init_verbs = { alc861_uniwill_m31_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_uniwill_m31_modes),
16333 .channel_mode = alc861_uniwill_m31_modes,
16334 .need_dac_fix = 1,
16335 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16336 .adc_nids = alc861_adc_nids,
16337 .input_mux = &alc861_capture_source,
16338 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016339 [ALC861_TOSHIBA] = {
16340 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016341 .init_verbs = { alc861_base_init_verbs,
16342 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016343 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16344 .dac_nids = alc861_dac_nids,
16345 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16346 .channel_mode = alc883_3ST_2ch_modes,
16347 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16348 .adc_nids = alc861_adc_nids,
16349 .input_mux = &alc861_capture_source,
16350 .unsol_event = alc861_toshiba_unsol_event,
16351 .init_hook = alc861_toshiba_automute,
16352 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016353 [ALC861_ASUS] = {
16354 .mixers = { alc861_asus_mixer },
16355 .init_verbs = { alc861_asus_init_verbs },
16356 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16357 .dac_nids = alc861_dac_nids,
16358 .dig_out_nid = ALC861_DIGOUT_NID,
16359 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16360 .channel_mode = alc861_asus_modes,
16361 .need_dac_fix = 1,
16362 .hp_nid = 0x06,
16363 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16364 .adc_nids = alc861_adc_nids,
16365 .input_mux = &alc861_capture_source,
16366 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016367 [ALC861_ASUS_LAPTOP] = {
16368 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16369 .init_verbs = { alc861_asus_init_verbs,
16370 alc861_asus_laptop_init_verbs },
16371 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16372 .dac_nids = alc861_dac_nids,
16373 .dig_out_nid = ALC861_DIGOUT_NID,
16374 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16375 .channel_mode = alc883_3ST_2ch_modes,
16376 .need_dac_fix = 1,
16377 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16378 .adc_nids = alc861_adc_nids,
16379 .input_mux = &alc861_capture_source,
16380 },
16381};
Kailang Yangdf694da2005-12-05 19:42:22 +010016382
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016383/* Pin config fixes */
16384enum {
16385 PINFIX_FSC_AMILO_PI1505,
16386};
16387
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016388static const struct alc_fixup alc861_fixups[] = {
16389 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016390 .type = ALC_FIXUP_PINS,
16391 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016392 { 0x0b, 0x0221101f }, /* HP */
16393 { 0x0f, 0x90170310 }, /* speaker */
16394 { }
16395 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016396 },
16397};
16398
16399static struct snd_pci_quirk alc861_fixup_tbl[] = {
16400 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16401 {}
16402};
Kailang Yangdf694da2005-12-05 19:42:22 +010016403
16404static int patch_alc861(struct hda_codec *codec)
16405{
16406 struct alc_spec *spec;
16407 int board_config;
16408 int err;
16409
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016410 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016411 if (spec == NULL)
16412 return -ENOMEM;
16413
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016414 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016415
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016416 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16417 alc861_models,
16418 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016419
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016420 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016421 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16422 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016423 board_config = ALC861_AUTO;
16424 }
16425
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016426 if (board_config == ALC861_AUTO) {
16427 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16428 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16429 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016430
Kailang Yangdf694da2005-12-05 19:42:22 +010016431 if (board_config == ALC861_AUTO) {
16432 /* automatic parse from the BIOS config */
16433 err = alc861_parse_auto_config(codec);
16434 if (err < 0) {
16435 alc_free(codec);
16436 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016437 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016438 printk(KERN_INFO
16439 "hda_codec: Cannot set up configuration "
16440 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016441 board_config = ALC861_3ST_DIG;
16442 }
16443 }
16444
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016445 err = snd_hda_attach_beep_device(codec, 0x23);
16446 if (err < 0) {
16447 alc_free(codec);
16448 return err;
16449 }
16450
Kailang Yangdf694da2005-12-05 19:42:22 +010016451 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016452 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016453
Kailang Yangdf694da2005-12-05 19:42:22 +010016454 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16455 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16456
Kailang Yangdf694da2005-12-05 19:42:22 +010016457 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16458 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16459
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016460 if (!spec->cap_mixer)
16461 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016462 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16463
Takashi Iwai2134ea42008-01-10 16:53:55 +010016464 spec->vmaster_nid = 0x03;
16465
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016466 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016467
Kailang Yangdf694da2005-12-05 19:42:22 +010016468 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016469 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016470 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016471#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016472 spec->power_hook = alc_power_eapd;
16473#endif
16474 }
16475#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016476 if (!spec->loopback.amplist)
16477 spec->loopback.amplist = alc861_loopbacks;
16478#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016479
Kailang Yangdf694da2005-12-05 19:42:22 +010016480 return 0;
16481}
16482
16483/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016484 * ALC861-VD support
16485 *
16486 * Based on ALC882
16487 *
16488 * In addition, an independent DAC
16489 */
16490#define ALC861VD_DIGOUT_NID 0x06
16491
16492static hda_nid_t alc861vd_dac_nids[4] = {
16493 /* front, surr, clfe, side surr */
16494 0x02, 0x03, 0x04, 0x05
16495};
16496
16497/* dac_nids for ALC660vd are in a different order - according to
16498 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016499 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016500 * of ALC660vd codecs, but for now there is only 3stack mixer
16501 * - and it is the same as in 861vd.
16502 * adc_nids in ALC660vd are (is) the same as in 861vd
16503 */
16504static hda_nid_t alc660vd_dac_nids[3] = {
16505 /* front, rear, clfe, rear_surr */
16506 0x02, 0x04, 0x03
16507};
16508
16509static hda_nid_t alc861vd_adc_nids[1] = {
16510 /* ADC0 */
16511 0x09,
16512};
16513
Takashi Iwaie1406342008-02-11 18:32:32 +010016514static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16515
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016516/* input MUX */
16517/* FIXME: should be a matrix-type input source selection */
16518static struct hda_input_mux alc861vd_capture_source = {
16519 .num_items = 4,
16520 .items = {
16521 { "Mic", 0x0 },
16522 { "Front Mic", 0x1 },
16523 { "Line", 0x2 },
16524 { "CD", 0x4 },
16525 },
16526};
16527
Kailang Yang272a5272007-05-14 11:00:38 +020016528static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016529 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016530 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016531 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016532 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016533 },
16534};
16535
Kailang Yangd1a991a2007-08-15 16:21:59 +020016536static struct hda_input_mux alc861vd_hp_capture_source = {
16537 .num_items = 2,
16538 .items = {
16539 { "Front Mic", 0x0 },
16540 { "ATAPI Mic", 0x1 },
16541 },
16542};
16543
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016544/*
16545 * 2ch mode
16546 */
16547static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16548 { 2, NULL }
16549};
16550
16551/*
16552 * 6ch mode
16553 */
16554static struct hda_verb alc861vd_6stack_ch6_init[] = {
16555 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16556 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16557 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16558 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16559 { } /* end */
16560};
16561
16562/*
16563 * 8ch mode
16564 */
16565static struct hda_verb alc861vd_6stack_ch8_init[] = {
16566 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16567 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16568 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16569 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16570 { } /* end */
16571};
16572
16573static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16574 { 6, alc861vd_6stack_ch6_init },
16575 { 8, alc861vd_6stack_ch8_init },
16576};
16577
16578static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16579 {
16580 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16581 .name = "Channel Mode",
16582 .info = alc_ch_mode_info,
16583 .get = alc_ch_mode_get,
16584 .put = alc_ch_mode_put,
16585 },
16586 { } /* end */
16587};
16588
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016589/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16590 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16591 */
16592static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16593 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16594 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16595
16596 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16597 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16598
16599 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16600 HDA_OUTPUT),
16601 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16602 HDA_OUTPUT),
16603 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16604 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16605
16606 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16607 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16608
16609 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16610
David Henningsson5f99f862011-01-04 15:24:24 +010016611 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16614
David Henningsson5f99f862011-01-04 15:24:24 +010016615 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016616 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16617 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16618
16619 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16620 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16621
16622 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16623 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16624
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016625 { } /* end */
16626};
16627
16628static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16629 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16630 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16631
16632 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16633
David Henningsson5f99f862011-01-04 15:24:24 +010016634 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16637
David Henningsson5f99f862011-01-04 15:24:24 +010016638 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016639 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16640 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16641
16642 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16643 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16644
16645 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16646 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16647
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016648 { } /* end */
16649};
16650
Kailang Yangbdd148a2007-05-08 15:19:08 +020016651static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16652 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16653 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16654 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16655
16656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16657
David Henningsson5f99f862011-01-04 15:24:24 +010016658 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16660 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16661
David Henningsson5f99f862011-01-04 15:24:24 +010016662 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016663 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16664 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16665
16666 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16667 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16668
16669 { } /* end */
16670};
16671
Tobin Davisb419f342008-03-07 11:57:51 +010016672/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016673 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016674 */
16675static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016676 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16677 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016678 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16679 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016680 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016683 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016684 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16685 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016686 { } /* end */
16687};
16688
Kailang Yangd1a991a2007-08-15 16:21:59 +020016689/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16690 * Front Mic=0x18, ATAPI Mic = 0x19,
16691 */
16692static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16693 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16694 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16695 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16696 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16697 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16698 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16699 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16700 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016701
Kailang Yangd1a991a2007-08-15 16:21:59 +020016702 { } /* end */
16703};
16704
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016705/*
16706 * generic initialization of ADC, input mixers and output mixers
16707 */
16708static struct hda_verb alc861vd_volume_init_verbs[] = {
16709 /*
16710 * Unmute ADC0 and set the default input to mic-in
16711 */
16712 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16713 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16714
16715 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16716 * the analog-loopback mixer widget
16717 */
16718 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016719 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016724
16725 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016730
16731 /*
16732 * Set up output mixers (0x02 - 0x05)
16733 */
16734 /* set vol=0 to output mixers */
16735 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16736 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16737 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16738 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16739
16740 /* set up input amps for analog loopback */
16741 /* Amp Indices: DAC = 0, mixer = 1 */
16742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16746 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16748 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16749 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16750
16751 { }
16752};
16753
16754/*
16755 * 3-stack pin configuration:
16756 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16757 */
16758static struct hda_verb alc861vd_3stack_init_verbs[] = {
16759 /*
16760 * Set pin mode and muting
16761 */
16762 /* set front pin widgets 0x14 for output */
16763 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16764 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16765 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16766
16767 /* Mic (rear) pin: input vref at 80% */
16768 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16769 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16770 /* Front Mic pin: input vref at 80% */
16771 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16772 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16773 /* Line In pin: input */
16774 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16775 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16776 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16777 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16778 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16779 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16780 /* CD pin widget for input */
16781 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16782
16783 { }
16784};
16785
16786/*
16787 * 6-stack pin configuration:
16788 */
16789static struct hda_verb alc861vd_6stack_init_verbs[] = {
16790 /*
16791 * Set pin mode and muting
16792 */
16793 /* set front pin widgets 0x14 for output */
16794 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16795 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16796 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16797
16798 /* Rear Pin: output 1 (0x0d) */
16799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16802 /* CLFE Pin: output 2 (0x0e) */
16803 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16804 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16805 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16806 /* Side Pin: output 3 (0x0f) */
16807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16808 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16809 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16810
16811 /* Mic (rear) pin: input vref at 80% */
16812 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16813 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16814 /* Front Mic pin: input vref at 80% */
16815 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16816 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16817 /* Line In pin: input */
16818 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16819 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16820 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16821 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16822 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16823 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16824 /* CD pin widget for input */
16825 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16826
16827 { }
16828};
16829
Kailang Yangbdd148a2007-05-08 15:19:08 +020016830static struct hda_verb alc861vd_eapd_verbs[] = {
16831 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16832 { }
16833};
16834
Kailang Yangf9423e72008-05-27 12:32:25 +020016835static struct hda_verb alc660vd_eapd_verbs[] = {
16836 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16837 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16838 { }
16839};
16840
Kailang Yangbdd148a2007-05-08 15:19:08 +020016841static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16845 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016846 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016847 {}
16848};
16849
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016850static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016851{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016852 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016853 spec->autocfg.hp_pins[0] = 0x1b;
16854 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016855}
16856
16857static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16858{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016859 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016860 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016861}
16862
16863static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16864 unsigned int res)
16865{
16866 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016867 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016868 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016869 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016870 default:
16871 alc_automute_amp_unsol_event(codec, res);
16872 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016873 }
16874}
16875
Kailang Yang272a5272007-05-14 11:00:38 +020016876static struct hda_verb alc861vd_dallas_verbs[] = {
16877 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16878 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16879 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16880 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16881
16882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16884 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16885 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16886 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16887 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16888 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16889 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016890
Kailang Yang272a5272007-05-14 11:00:38 +020016891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16893 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16895 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16896 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16897 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16898 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16899
16900 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16901 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16902 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16903 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16904 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16905 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16906 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16907 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16908
16909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16913
16914 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016915 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016916 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16917
16918 { } /* end */
16919};
16920
16921/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016922static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016923{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016924 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016925
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016926 spec->autocfg.hp_pins[0] = 0x15;
16927 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016928}
16929
Takashi Iwaicb53c622007-08-10 17:21:45 +020016930#ifdef CONFIG_SND_HDA_POWER_SAVE
16931#define alc861vd_loopbacks alc880_loopbacks
16932#endif
16933
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016934/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016935#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16936#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16937#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16938#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16939
16940/*
16941 * configuration and preset
16942 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016943static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016944 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016945 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016946 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016947 [ALC861VD_3ST] = "3stack",
16948 [ALC861VD_3ST_DIG] = "3stack-digout",
16949 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016950 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016951 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016952 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016953 [ALC861VD_AUTO] = "auto",
16954};
16955
16956static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016957 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16958 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016959 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016960 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016961 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016962 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016963 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016964 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016965 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016966 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016967 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016968 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016969 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016970 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016971 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016972 {}
16973};
16974
16975static struct alc_config_preset alc861vd_presets[] = {
16976 [ALC660VD_3ST] = {
16977 .mixers = { alc861vd_3st_mixer },
16978 .init_verbs = { alc861vd_volume_init_verbs,
16979 alc861vd_3stack_init_verbs },
16980 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16981 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016982 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16983 .channel_mode = alc861vd_3stack_2ch_modes,
16984 .input_mux = &alc861vd_capture_source,
16985 },
Mike Crash6963f842007-06-25 12:12:51 +020016986 [ALC660VD_3ST_DIG] = {
16987 .mixers = { alc861vd_3st_mixer },
16988 .init_verbs = { alc861vd_volume_init_verbs,
16989 alc861vd_3stack_init_verbs },
16990 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16991 .dac_nids = alc660vd_dac_nids,
16992 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016993 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16994 .channel_mode = alc861vd_3stack_2ch_modes,
16995 .input_mux = &alc861vd_capture_source,
16996 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016997 [ALC861VD_3ST] = {
16998 .mixers = { alc861vd_3st_mixer },
16999 .init_verbs = { alc861vd_volume_init_verbs,
17000 alc861vd_3stack_init_verbs },
17001 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17002 .dac_nids = alc861vd_dac_nids,
17003 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17004 .channel_mode = alc861vd_3stack_2ch_modes,
17005 .input_mux = &alc861vd_capture_source,
17006 },
17007 [ALC861VD_3ST_DIG] = {
17008 .mixers = { alc861vd_3st_mixer },
17009 .init_verbs = { alc861vd_volume_init_verbs,
17010 alc861vd_3stack_init_verbs },
17011 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17012 .dac_nids = alc861vd_dac_nids,
17013 .dig_out_nid = ALC861VD_DIGOUT_NID,
17014 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17015 .channel_mode = alc861vd_3stack_2ch_modes,
17016 .input_mux = &alc861vd_capture_source,
17017 },
17018 [ALC861VD_6ST_DIG] = {
17019 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
17020 .init_verbs = { alc861vd_volume_init_verbs,
17021 alc861vd_6stack_init_verbs },
17022 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17023 .dac_nids = alc861vd_dac_nids,
17024 .dig_out_nid = ALC861VD_DIGOUT_NID,
17025 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
17026 .channel_mode = alc861vd_6stack_modes,
17027 .input_mux = &alc861vd_capture_source,
17028 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020017029 [ALC861VD_LENOVO] = {
17030 .mixers = { alc861vd_lenovo_mixer },
17031 .init_verbs = { alc861vd_volume_init_verbs,
17032 alc861vd_3stack_init_verbs,
17033 alc861vd_eapd_verbs,
17034 alc861vd_lenovo_unsol_verbs },
17035 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17036 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017037 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17038 .channel_mode = alc861vd_3stack_2ch_modes,
17039 .input_mux = &alc861vd_capture_source,
17040 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017041 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017042 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017043 },
Kailang Yang272a5272007-05-14 11:00:38 +020017044 [ALC861VD_DALLAS] = {
17045 .mixers = { alc861vd_dallas_mixer },
17046 .init_verbs = { alc861vd_dallas_verbs },
17047 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17048 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020017049 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17050 .channel_mode = alc861vd_3stack_2ch_modes,
17051 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017052 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017053 .setup = alc861vd_dallas_setup,
17054 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017055 },
17056 [ALC861VD_HP] = {
17057 .mixers = { alc861vd_hp_mixer },
17058 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17059 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17060 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017061 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017062 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17063 .channel_mode = alc861vd_3stack_2ch_modes,
17064 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017065 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017066 .setup = alc861vd_dallas_setup,
17067 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020017068 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017069 [ALC660VD_ASUS_V1S] = {
17070 .mixers = { alc861vd_lenovo_mixer },
17071 .init_verbs = { alc861vd_volume_init_verbs,
17072 alc861vd_3stack_init_verbs,
17073 alc861vd_eapd_verbs,
17074 alc861vd_lenovo_unsol_verbs },
17075 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17076 .dac_nids = alc660vd_dac_nids,
17077 .dig_out_nid = ALC861VD_DIGOUT_NID,
17078 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17079 .channel_mode = alc861vd_3stack_2ch_modes,
17080 .input_mux = &alc861vd_capture_source,
17081 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017082 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017083 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017084 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017085};
17086
17087/*
17088 * BIOS auto configuration
17089 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017090static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17091 const struct auto_pin_cfg *cfg)
17092{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017093 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017094}
17095
17096
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017097static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17098 hda_nid_t nid, int pin_type, int dac_idx)
17099{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017100 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017101}
17102
17103static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17104{
17105 struct alc_spec *spec = codec->spec;
17106 int i;
17107
17108 for (i = 0; i <= HDA_SIDE; i++) {
17109 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017110 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017111 if (nid)
17112 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017113 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017114 }
17115}
17116
17117
17118static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17119{
17120 struct alc_spec *spec = codec->spec;
17121 hda_nid_t pin;
17122
17123 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017124 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017125 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017126 pin = spec->autocfg.speaker_pins[0];
17127 if (pin)
17128 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017129}
17130
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017131#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17132
17133static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17134{
17135 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017136 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017137 int i;
17138
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017139 for (i = 0; i < cfg->num_inputs; i++) {
17140 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017141 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017142 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017143 if (nid != ALC861VD_PIN_CD_NID &&
17144 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017145 snd_hda_codec_write(codec, nid, 0,
17146 AC_VERB_SET_AMP_GAIN_MUTE,
17147 AMP_OUT_MUTE);
17148 }
17149 }
17150}
17151
Takashi Iwaif511b012008-08-15 16:46:42 +020017152#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17153
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017154#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17155#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17156
17157/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017158/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017159 * different NIDs for mute/unmute switch and volume control */
17160static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17161 const struct auto_pin_cfg *cfg)
17162{
Takashi Iwaiea734962011-01-17 11:29:34 +010017163 static const char * const chname[4] = {
17164 "Front", "Surround", "CLFE", "Side"
17165 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017166 const char *pfx = alc_get_line_out_pfx(cfg, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017167 hda_nid_t nid_v, nid_s;
17168 int i, err;
17169
17170 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017171 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017172 continue;
17173 nid_v = alc861vd_idx_to_mixer_vol(
17174 alc880_dac_to_idx(
17175 spec->multiout.dac_nids[i]));
17176 nid_s = alc861vd_idx_to_mixer_switch(
17177 alc880_dac_to_idx(
17178 spec->multiout.dac_nids[i]));
17179
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017180 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017181 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017182 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17183 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017184 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17185 HDA_OUTPUT));
17186 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017187 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017188 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17189 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017190 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17191 HDA_OUTPUT));
17192 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017193 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017194 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17195 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017196 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17197 HDA_INPUT));
17198 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017199 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017200 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17201 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017202 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17203 HDA_INPUT));
17204 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017205 return err;
17206 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017207 const char *name = pfx;
17208 if (!name)
17209 name = chname[i];
17210 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17211 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017212 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17213 HDA_OUTPUT));
17214 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017215 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017216 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17217 name, i,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017218 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017219 HDA_INPUT));
17220 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017221 return err;
17222 }
17223 }
17224 return 0;
17225}
17226
17227/* add playback controls for speaker and HP outputs */
17228/* Based on ALC880 version. But ALC861VD has separate,
17229 * different NIDs for mute/unmute switch and volume control */
17230static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17231 hda_nid_t pin, const char *pfx)
17232{
17233 hda_nid_t nid_v, nid_s;
17234 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017235
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017236 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017237 return 0;
17238
17239 if (alc880_is_fixed_pin(pin)) {
17240 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17241 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017242 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017243 spec->multiout.hp_nid = nid_v;
17244 else
17245 spec->multiout.extra_out_nid[0] = nid_v;
17246 /* control HP volume/switch on the output mixer amp */
17247 nid_v = alc861vd_idx_to_mixer_vol(
17248 alc880_fixed_pin_idx(pin));
17249 nid_s = alc861vd_idx_to_mixer_switch(
17250 alc880_fixed_pin_idx(pin));
17251
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017252 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017253 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17254 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017255 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017256 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017257 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17258 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017259 return err;
17260 } else if (alc880_is_multi_pin(pin)) {
17261 /* set manual connection */
17262 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017263 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017264 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17265 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017266 return err;
17267 }
17268 return 0;
17269}
17270
17271/* parse the BIOS configuration and set up the alc_spec
17272 * return 1 if successful, 0 if the proper config is not found,
17273 * or a negative error code
17274 * Based on ALC880 version - had to change it to override
17275 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17276static int alc861vd_parse_auto_config(struct hda_codec *codec)
17277{
17278 struct alc_spec *spec = codec->spec;
17279 int err;
17280 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17281
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017282 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17283 alc861vd_ignore);
17284 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017285 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017286 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017287 return 0; /* can't find valid BIOS pin config */
17288
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017289 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17290 if (err < 0)
17291 return err;
17292 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17293 if (err < 0)
17294 return err;
17295 err = alc861vd_auto_create_extra_out(spec,
17296 spec->autocfg.speaker_pins[0],
17297 "Speaker");
17298 if (err < 0)
17299 return err;
17300 err = alc861vd_auto_create_extra_out(spec,
17301 spec->autocfg.hp_pins[0],
17302 "Headphone");
17303 if (err < 0)
17304 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017305 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017306 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017307 return err;
17308
17309 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17310
Takashi Iwai757899a2010-07-30 10:48:14 +020017311 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017312
Takashi Iwai603c4012008-07-30 15:01:44 +020017313 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017314 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017315
Takashi Iwaid88897e2008-10-31 15:01:37 +010017316 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017317
17318 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017319 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017320
Takashi Iwai776e1842007-08-29 15:07:11 +020017321 err = alc_auto_add_mic_boost(codec);
17322 if (err < 0)
17323 return err;
17324
Kailang Yang6227cdc2010-02-25 08:36:52 +010017325 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017326
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017327 return 1;
17328}
17329
17330/* additional initialization for auto-configuration model */
17331static void alc861vd_auto_init(struct hda_codec *codec)
17332{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017333 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017334 alc861vd_auto_init_multi_out(codec);
17335 alc861vd_auto_init_hp_out(codec);
17336 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017337 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017338 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017339 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017340 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017341}
17342
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017343enum {
17344 ALC660VD_FIX_ASUS_GPIO1
17345};
17346
17347/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017348static const struct alc_fixup alc861vd_fixups[] = {
17349 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017350 .type = ALC_FIXUP_VERBS,
17351 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017352 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17353 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17354 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17355 { }
17356 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017357 },
17358};
17359
17360static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17361 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17362 {}
17363};
17364
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017365static int patch_alc861vd(struct hda_codec *codec)
17366{
17367 struct alc_spec *spec;
17368 int err, board_config;
17369
17370 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17371 if (spec == NULL)
17372 return -ENOMEM;
17373
17374 codec->spec = spec;
17375
17376 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17377 alc861vd_models,
17378 alc861vd_cfg_tbl);
17379
17380 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017381 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17382 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017383 board_config = ALC861VD_AUTO;
17384 }
17385
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017386 if (board_config == ALC861VD_AUTO) {
17387 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17388 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17389 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017390
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017391 if (board_config == ALC861VD_AUTO) {
17392 /* automatic parse from the BIOS config */
17393 err = alc861vd_parse_auto_config(codec);
17394 if (err < 0) {
17395 alc_free(codec);
17396 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017397 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017398 printk(KERN_INFO
17399 "hda_codec: Cannot set up configuration "
17400 "from BIOS. Using base mode...\n");
17401 board_config = ALC861VD_3ST;
17402 }
17403 }
17404
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017405 err = snd_hda_attach_beep_device(codec, 0x23);
17406 if (err < 0) {
17407 alc_free(codec);
17408 return err;
17409 }
17410
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017411 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017412 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017413
Kailang Yang2f893282008-05-27 12:14:47 +020017414 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017415 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017416 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017417 }
17418
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017419 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17420 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17421
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017422 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17423 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17424
Takashi Iwaidd704692009-08-11 08:45:11 +020017425 if (!spec->adc_nids) {
17426 spec->adc_nids = alc861vd_adc_nids;
17427 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17428 }
17429 if (!spec->capsrc_nids)
17430 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017431
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017432 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017433 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017434
Takashi Iwai2134ea42008-01-10 16:53:55 +010017435 spec->vmaster_nid = 0x02;
17436
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017437 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017438
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017439 codec->patch_ops = alc_patch_ops;
17440
17441 if (board_config == ALC861VD_AUTO)
17442 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017443#ifdef CONFIG_SND_HDA_POWER_SAVE
17444 if (!spec->loopback.amplist)
17445 spec->loopback.amplist = alc861vd_loopbacks;
17446#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017447
17448 return 0;
17449}
17450
17451/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017452 * ALC662 support
17453 *
17454 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17455 * configuration. Each pin widget can choose any input DACs and a mixer.
17456 * Each ADC is connected from a mixer of all inputs. This makes possible
17457 * 6-channel independent captures.
17458 *
17459 * In addition, an independent DAC for the multi-playback (not used in this
17460 * driver yet).
17461 */
17462#define ALC662_DIGOUT_NID 0x06
17463#define ALC662_DIGIN_NID 0x0a
17464
17465static hda_nid_t alc662_dac_nids[4] = {
17466 /* front, rear, clfe, rear_surr */
17467 0x02, 0x03, 0x04
17468};
17469
Kailang Yang622e84c2009-04-21 07:39:04 +020017470static hda_nid_t alc272_dac_nids[2] = {
17471 0x02, 0x03
17472};
17473
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017474static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017475 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017476 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017477};
Takashi Iwaie1406342008-02-11 18:32:32 +010017478
Kailang Yang622e84c2009-04-21 07:39:04 +020017479static hda_nid_t alc272_adc_nids[1] = {
17480 /* ADC1-2 */
17481 0x08,
17482};
17483
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017484static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017485static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17486
Takashi Iwaie1406342008-02-11 18:32:32 +010017487
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017488/* input MUX */
17489/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017490static struct hda_input_mux alc662_capture_source = {
17491 .num_items = 4,
17492 .items = {
17493 { "Mic", 0x0 },
17494 { "Front Mic", 0x1 },
17495 { "Line", 0x2 },
17496 { "CD", 0x4 },
17497 },
17498};
17499
17500static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17501 .num_items = 2,
17502 .items = {
17503 { "Mic", 0x1 },
17504 { "Line", 0x2 },
17505 },
17506};
Kailang Yang291702f2007-10-16 14:28:03 +020017507
Kailang Yang6dda9f42008-05-27 12:05:31 +020017508static struct hda_input_mux alc663_capture_source = {
17509 .num_items = 3,
17510 .items = {
17511 { "Mic", 0x0 },
17512 { "Front Mic", 0x1 },
17513 { "Line", 0x2 },
17514 },
17515};
17516
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017517#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017518static struct hda_input_mux alc272_nc10_capture_source = {
17519 .num_items = 16,
17520 .items = {
17521 { "Autoselect Mic", 0x0 },
17522 { "Internal Mic", 0x1 },
17523 { "In-0x02", 0x2 },
17524 { "In-0x03", 0x3 },
17525 { "In-0x04", 0x4 },
17526 { "In-0x05", 0x5 },
17527 { "In-0x06", 0x6 },
17528 { "In-0x07", 0x7 },
17529 { "In-0x08", 0x8 },
17530 { "In-0x09", 0x9 },
17531 { "In-0x0a", 0x0a },
17532 { "In-0x0b", 0x0b },
17533 { "In-0x0c", 0x0c },
17534 { "In-0x0d", 0x0d },
17535 { "In-0x0e", 0x0e },
17536 { "In-0x0f", 0x0f },
17537 },
17538};
17539#endif
17540
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017541/*
17542 * 2ch mode
17543 */
17544static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17545 { 2, NULL }
17546};
17547
17548/*
17549 * 2ch mode
17550 */
17551static struct hda_verb alc662_3ST_ch2_init[] = {
17552 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17553 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17554 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17555 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17556 { } /* end */
17557};
17558
17559/*
17560 * 6ch mode
17561 */
17562static struct hda_verb alc662_3ST_ch6_init[] = {
17563 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17564 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17565 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17566 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17567 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17568 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17569 { } /* end */
17570};
17571
17572static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17573 { 2, alc662_3ST_ch2_init },
17574 { 6, alc662_3ST_ch6_init },
17575};
17576
17577/*
17578 * 2ch mode
17579 */
17580static struct hda_verb alc662_sixstack_ch6_init[] = {
17581 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17582 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17583 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17584 { } /* end */
17585};
17586
17587/*
17588 * 6ch mode
17589 */
17590static struct hda_verb alc662_sixstack_ch8_init[] = {
17591 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17592 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17593 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17594 { } /* end */
17595};
17596
17597static struct hda_channel_mode alc662_5stack_modes[2] = {
17598 { 2, alc662_sixstack_ch6_init },
17599 { 6, alc662_sixstack_ch8_init },
17600};
17601
17602/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17603 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17604 */
17605
17606static struct snd_kcontrol_new alc662_base_mixer[] = {
17607 /* output mixer control */
17608 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017609 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017610 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017611 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017612 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17613 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017614 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17615 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17617
17618 /*Input mixer control */
17619 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17620 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17621 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17622 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17623 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17624 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17625 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17626 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017627 { } /* end */
17628};
17629
17630static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17631 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017632 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17634 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17635 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17636 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17637 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17638 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17640 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17641 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017642 { } /* end */
17643};
17644
17645static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17646 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017647 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017648 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017649 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017650 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17651 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017652 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17653 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017654 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17655 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17656 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17657 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17658 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17660 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17661 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17662 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017663 { } /* end */
17664};
17665
17666static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17667 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17668 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017669 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17670 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017671 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17672 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17673 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017676 { } /* end */
17677};
17678
Kailang Yang291702f2007-10-16 14:28:03 +020017679static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017680 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17681 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017682
David Henningsson5f99f862011-01-04 15:24:24 +010017683 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017686
David Henningsson5f99f862011-01-04 15:24:24 +010017687 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017688 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17689 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017690 { } /* end */
17691};
17692
Kailang Yang8c427222008-01-10 13:03:59 +010017693static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017694 ALC262_HIPPO_MASTER_SWITCH,
17695 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017696 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017697 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17698 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017699 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17700 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17701 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17702 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17703 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17704 { } /* end */
17705};
17706
Kailang Yangf1d4e282008-08-26 14:03:29 +020017707static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17708 .ops = &snd_hda_bind_vol,
17709 .values = {
17710 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17711 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17712 0
17713 },
17714};
17715
17716static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17717 .ops = &snd_hda_bind_sw,
17718 .values = {
17719 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17720 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17721 0
17722 },
17723};
17724
Kailang Yang6dda9f42008-05-27 12:05:31 +020017725static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017726 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17727 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17728 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17729 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17730 { } /* end */
17731};
17732
17733static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17734 .ops = &snd_hda_bind_sw,
17735 .values = {
17736 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17737 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17738 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17739 0
17740 },
17741};
17742
17743static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17744 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17745 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17747 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17748 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17749 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17750
17751 { } /* end */
17752};
17753
17754static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17755 .ops = &snd_hda_bind_sw,
17756 .values = {
17757 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17758 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17759 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17760 0
17761 },
17762};
17763
17764static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17765 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17766 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17769 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17770 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17771 { } /* end */
17772};
17773
17774static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017775 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17776 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017777 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17780 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17781 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17782 { } /* end */
17783};
17784
17785static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17786 .ops = &snd_hda_bind_vol,
17787 .values = {
17788 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17789 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17790 0
17791 },
17792};
17793
17794static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17795 .ops = &snd_hda_bind_sw,
17796 .values = {
17797 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17798 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17799 0
17800 },
17801};
17802
17803static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17804 HDA_BIND_VOL("Master Playback Volume",
17805 &alc663_asus_two_bind_master_vol),
17806 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17807 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017808 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017811 { } /* end */
17812};
17813
17814static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17815 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17816 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17817 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17818 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017821 { } /* end */
17822};
17823
17824static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17825 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17826 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17827 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17828 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17830
17831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017833 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17834 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017835 { } /* end */
17836};
17837
17838static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17840 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17842
17843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017845 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17846 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17849 { } /* end */
17850};
17851
Kailang Yangebb83ee2009-12-17 12:23:00 +010017852static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17853 .ops = &snd_hda_bind_sw,
17854 .values = {
17855 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17856 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17857 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17858 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17859 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17860 0
17861 },
17862};
17863
17864static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17865 .ops = &snd_hda_bind_sw,
17866 .values = {
17867 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17868 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17869 0
17870 },
17871};
17872
17873static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17874 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17875 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17876 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17877 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17878 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17879 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17880 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17882 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17883 { } /* end */
17884};
17885
17886static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17887 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17888 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17889 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17890 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17891 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17894 { } /* end */
17895};
17896
17897
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017898static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17899 {
17900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17901 .name = "Channel Mode",
17902 .info = alc_ch_mode_info,
17903 .get = alc_ch_mode_get,
17904 .put = alc_ch_mode_put,
17905 },
17906 { } /* end */
17907};
17908
17909static struct hda_verb alc662_init_verbs[] = {
17910 /* ADC: mute amp left and right */
17911 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17912 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017913
Kailang Yangb60dd392007-09-20 12:50:29 +020017914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017920
17921 /* Front Pin: output 0 (0x0c) */
17922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17923 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17924
17925 /* Rear Pin: output 1 (0x0d) */
17926 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17928
17929 /* CLFE Pin: output 2 (0x0e) */
17930 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17931 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17932
17933 /* Mic (rear) pin: input vref at 80% */
17934 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17935 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17936 /* Front Mic pin: input vref at 80% */
17937 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17938 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17939 /* Line In pin: input */
17940 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17941 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17942 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17945 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17946 /* CD pin widget for input */
17947 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17948
17949 /* FIXME: use matrix-type input source selection */
17950 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17951 /* Input mixer */
17952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017954
17955 /* always trun on EAPD */
17956 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17957 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17958
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017959 { }
17960};
17961
Kailang Yangcec27c82010-02-04 14:18:18 +010017962static struct hda_verb alc663_init_verbs[] = {
17963 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17964 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17965 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17966 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17967 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17968 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17969 { }
17970};
17971
17972static struct hda_verb alc272_init_verbs[] = {
17973 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17974 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17975 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17976 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17977 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17978 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17979 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17980 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17981 { }
17982};
17983
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017984static struct hda_verb alc662_sue_init_verbs[] = {
17985 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17986 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017987 {}
17988};
17989
17990static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17991 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17992 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17993 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017994};
17995
Kailang Yang8c427222008-01-10 13:03:59 +010017996/* Set Unsolicited Event*/
17997static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17998 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17999 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18000 {}
18001};
18002
Kailang Yang6dda9f42008-05-27 12:05:31 +020018003static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18005 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020018006 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18007 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020018008 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020018011 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18012 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18013 {}
18014};
18015
Kailang Yangf1d4e282008-08-26 14:03:29 +020018016static struct hda_verb alc663_21jd_amic_init_verbs[] = {
18017 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18018 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18019 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18022 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18023 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18024 {}
18025};
18026
18027static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
18028 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18029 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18030 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18031 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18032 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18033 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18034 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18035 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18036 {}
18037};
18038
18039static struct hda_verb alc663_15jd_amic_init_verbs[] = {
18040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18042 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18043 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18044 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18045 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18046 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18047 {}
18048};
18049
18050static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
18051 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18052 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18053 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18054 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18055 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18057 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18060 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18061 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18062 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18063 {}
18064};
18065
18066static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18067 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18068 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18069 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18070 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18071 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18076 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18077 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18078 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18079 {}
18080};
18081
Kailang Yang6dda9f42008-05-27 12:05:31 +020018082static struct hda_verb alc663_g71v_init_verbs[] = {
18083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18084 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18085 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18086
18087 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18088 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18089 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18090
18091 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18092 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18093 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18094 {}
18095};
18096
18097static struct hda_verb alc663_g50v_init_verbs[] = {
18098 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18099 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18100 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18101
18102 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18103 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18104 {}
18105};
18106
Kailang Yangf1d4e282008-08-26 14:03:29 +020018107static struct hda_verb alc662_ecs_init_verbs[] = {
18108 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18110 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18111 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18112 {}
18113};
18114
Kailang Yang622e84c2009-04-21 07:39:04 +020018115static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18116 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18117 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18118 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18119 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18120 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18121 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18122 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18125 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18126 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18127 {}
18128};
18129
18130static struct hda_verb alc272_dell_init_verbs[] = {
18131 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18132 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18133 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18134 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18135 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18136 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18137 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18138 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18139 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18140 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18141 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18142 {}
18143};
18144
Kailang Yangebb83ee2009-12-17 12:23:00 +010018145static struct hda_verb alc663_mode7_init_verbs[] = {
18146 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18147 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18148 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18149 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18150 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18151 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18152 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18153 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18154 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18155 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18156 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18157 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18158 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18159 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18160 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18161 {}
18162};
18163
18164static struct hda_verb alc663_mode8_init_verbs[] = {
18165 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18166 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18167 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18168 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18169 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18170 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18171 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18172 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18173 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18174 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18175 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18178 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18179 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18180 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18181 {}
18182};
18183
Kailang Yangf1d4e282008-08-26 14:03:29 +020018184static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18185 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18186 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18187 { } /* end */
18188};
18189
Kailang Yang622e84c2009-04-21 07:39:04 +020018190static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18191 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18192 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18193 { } /* end */
18194};
18195
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018196static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18197{
18198 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018199 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018200
Wu Fengguang864f92b2009-11-18 12:38:02 +080018201 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018202 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018203
Takashi Iwai47fd8302007-08-10 17:11:07 +020018204 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18205 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018206}
18207
18208static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18209{
18210 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018211 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018212
Wu Fengguang864f92b2009-11-18 12:38:02 +080018213 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018214 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018215
Takashi Iwai47fd8302007-08-10 17:11:07 +020018216 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18217 HDA_AMP_MUTE, bits);
18218 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18219 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018220}
18221
18222static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18223 unsigned int res)
18224{
18225 if ((res >> 26) == ALC880_HP_EVENT)
18226 alc662_lenovo_101e_all_automute(codec);
18227 if ((res >> 26) == ALC880_FRONT_EVENT)
18228 alc662_lenovo_101e_ispeaker_automute(codec);
18229}
18230
Kailang Yang291702f2007-10-16 14:28:03 +020018231/* unsolicited event for HP jack sensing */
18232static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18233 unsigned int res)
18234{
Kailang Yang291702f2007-10-16 14:28:03 +020018235 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018236 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018237 else
18238 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018239}
18240
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018241static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018242{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018243 struct alc_spec *spec = codec->spec;
18244
18245 alc262_hippo1_setup(codec);
18246 spec->ext_mic.pin = 0x18;
18247 spec->ext_mic.mux_idx = 0;
18248 spec->int_mic.pin = 0x19;
18249 spec->int_mic.mux_idx = 1;
18250 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018251}
18252
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018253static void alc662_eeepc_inithook(struct hda_codec *codec)
18254{
18255 alc262_hippo_automute(codec);
18256 alc_mic_automute(codec);
18257}
18258
18259static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018260{
Takashi Iwai42171c12009-05-08 14:11:43 +020018261 struct alc_spec *spec = codec->spec;
18262
18263 spec->autocfg.hp_pins[0] = 0x14;
18264 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018265}
18266
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018267#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18268
Kailang Yang6dda9f42008-05-27 12:05:31 +020018269static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18270{
18271 unsigned int present;
18272 unsigned char bits;
18273
Wu Fengguang864f92b2009-11-18 12:38:02 +080018274 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018275 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018276 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018277 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018278 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018279 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018280}
18281
18282static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18283{
18284 unsigned int present;
18285 unsigned char bits;
18286
Wu Fengguang864f92b2009-11-18 12:38:02 +080018287 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018288 bits = present ? HDA_AMP_MUTE : 0;
18289 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018290 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018291 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018292 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018293 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018294 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018295 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018296 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018297}
18298
18299static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18300{
18301 unsigned int present;
18302 unsigned char bits;
18303
Wu Fengguang864f92b2009-11-18 12:38:02 +080018304 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018305 bits = present ? HDA_AMP_MUTE : 0;
18306 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018307 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018308 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018309 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018310 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018311 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018312 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018313 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018314}
18315
18316static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18317{
18318 unsigned int present;
18319 unsigned char bits;
18320
Wu Fengguang864f92b2009-11-18 12:38:02 +080018321 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018322 bits = present ? 0 : PIN_OUT;
18323 snd_hda_codec_write(codec, 0x14, 0,
18324 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18325}
18326
18327static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18328{
18329 unsigned int present1, present2;
18330
Wu Fengguang864f92b2009-11-18 12:38:02 +080018331 present1 = snd_hda_jack_detect(codec, 0x21);
18332 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018333
18334 if (present1 || present2) {
18335 snd_hda_codec_write_cache(codec, 0x14, 0,
18336 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18337 } else {
18338 snd_hda_codec_write_cache(codec, 0x14, 0,
18339 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18340 }
18341}
18342
18343static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18344{
18345 unsigned int present1, present2;
18346
Wu Fengguang864f92b2009-11-18 12:38:02 +080018347 present1 = snd_hda_jack_detect(codec, 0x1b);
18348 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018349
18350 if (present1 || present2) {
18351 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018352 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018353 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018354 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018355 } else {
18356 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018357 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018358 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018359 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018360 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018361}
18362
Kailang Yangebb83ee2009-12-17 12:23:00 +010018363static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18364{
18365 unsigned int present1, present2;
18366
18367 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18368 AC_VERB_GET_PIN_SENSE, 0)
18369 & AC_PINSENSE_PRESENCE;
18370 present2 = snd_hda_codec_read(codec, 0x21, 0,
18371 AC_VERB_GET_PIN_SENSE, 0)
18372 & AC_PINSENSE_PRESENCE;
18373
18374 if (present1 || present2) {
18375 snd_hda_codec_write_cache(codec, 0x14, 0,
18376 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18377 snd_hda_codec_write_cache(codec, 0x17, 0,
18378 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18379 } else {
18380 snd_hda_codec_write_cache(codec, 0x14, 0,
18381 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18382 snd_hda_codec_write_cache(codec, 0x17, 0,
18383 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18384 }
18385}
18386
18387static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18388{
18389 unsigned int present1, present2;
18390
18391 present1 = snd_hda_codec_read(codec, 0x21, 0,
18392 AC_VERB_GET_PIN_SENSE, 0)
18393 & AC_PINSENSE_PRESENCE;
18394 present2 = snd_hda_codec_read(codec, 0x15, 0,
18395 AC_VERB_GET_PIN_SENSE, 0)
18396 & AC_PINSENSE_PRESENCE;
18397
18398 if (present1 || present2) {
18399 snd_hda_codec_write_cache(codec, 0x14, 0,
18400 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18401 snd_hda_codec_write_cache(codec, 0x17, 0,
18402 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18403 } else {
18404 snd_hda_codec_write_cache(codec, 0x14, 0,
18405 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18406 snd_hda_codec_write_cache(codec, 0x17, 0,
18407 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18408 }
18409}
18410
Kailang Yang6dda9f42008-05-27 12:05:31 +020018411static void alc663_m51va_unsol_event(struct hda_codec *codec,
18412 unsigned int res)
18413{
18414 switch (res >> 26) {
18415 case ALC880_HP_EVENT:
18416 alc663_m51va_speaker_automute(codec);
18417 break;
18418 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018419 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018420 break;
18421 }
18422}
18423
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018424static void alc663_m51va_setup(struct hda_codec *codec)
18425{
18426 struct alc_spec *spec = codec->spec;
18427 spec->ext_mic.pin = 0x18;
18428 spec->ext_mic.mux_idx = 0;
18429 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018430 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018431 spec->auto_mic = 1;
18432}
18433
Kailang Yang6dda9f42008-05-27 12:05:31 +020018434static void alc663_m51va_inithook(struct hda_codec *codec)
18435{
18436 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018437 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018438}
18439
Kailang Yangf1d4e282008-08-26 14:03:29 +020018440/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018441#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018442
18443static void alc663_mode1_setup(struct hda_codec *codec)
18444{
18445 struct alc_spec *spec = codec->spec;
18446 spec->ext_mic.pin = 0x18;
18447 spec->ext_mic.mux_idx = 0;
18448 spec->int_mic.pin = 0x19;
18449 spec->int_mic.mux_idx = 1;
18450 spec->auto_mic = 1;
18451}
18452
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018453#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018454
Kailang Yangf1d4e282008-08-26 14:03:29 +020018455/* ***************** Mode2 ******************************/
18456static void alc662_mode2_unsol_event(struct hda_codec *codec,
18457 unsigned int res)
18458{
18459 switch (res >> 26) {
18460 case ALC880_HP_EVENT:
18461 alc662_f5z_speaker_automute(codec);
18462 break;
18463 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018464 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018465 break;
18466 }
18467}
18468
Kailang Yangebb83ee2009-12-17 12:23:00 +010018469#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018470
Kailang Yangf1d4e282008-08-26 14:03:29 +020018471static void alc662_mode2_inithook(struct hda_codec *codec)
18472{
18473 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018474 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018475}
18476/* ***************** Mode3 ******************************/
18477static void alc663_mode3_unsol_event(struct hda_codec *codec,
18478 unsigned int res)
18479{
18480 switch (res >> 26) {
18481 case ALC880_HP_EVENT:
18482 alc663_two_hp_m1_speaker_automute(codec);
18483 break;
18484 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018485 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018486 break;
18487 }
18488}
18489
Kailang Yangebb83ee2009-12-17 12:23:00 +010018490#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018491
Kailang Yangf1d4e282008-08-26 14:03:29 +020018492static void alc663_mode3_inithook(struct hda_codec *codec)
18493{
18494 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018495 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018496}
18497/* ***************** Mode4 ******************************/
18498static void alc663_mode4_unsol_event(struct hda_codec *codec,
18499 unsigned int res)
18500{
18501 switch (res >> 26) {
18502 case ALC880_HP_EVENT:
18503 alc663_21jd_two_speaker_automute(codec);
18504 break;
18505 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018506 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018507 break;
18508 }
18509}
18510
Kailang Yangebb83ee2009-12-17 12:23:00 +010018511#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018512
Kailang Yangf1d4e282008-08-26 14:03:29 +020018513static void alc663_mode4_inithook(struct hda_codec *codec)
18514{
18515 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018516 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018517}
18518/* ***************** Mode5 ******************************/
18519static void alc663_mode5_unsol_event(struct hda_codec *codec,
18520 unsigned int res)
18521{
18522 switch (res >> 26) {
18523 case ALC880_HP_EVENT:
18524 alc663_15jd_two_speaker_automute(codec);
18525 break;
18526 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018527 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018528 break;
18529 }
18530}
18531
Kailang Yangebb83ee2009-12-17 12:23:00 +010018532#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018533
Kailang Yangf1d4e282008-08-26 14:03:29 +020018534static void alc663_mode5_inithook(struct hda_codec *codec)
18535{
18536 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018537 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018538}
18539/* ***************** Mode6 ******************************/
18540static void alc663_mode6_unsol_event(struct hda_codec *codec,
18541 unsigned int res)
18542{
18543 switch (res >> 26) {
18544 case ALC880_HP_EVENT:
18545 alc663_two_hp_m2_speaker_automute(codec);
18546 break;
18547 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018548 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018549 break;
18550 }
18551}
18552
Kailang Yangebb83ee2009-12-17 12:23:00 +010018553#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018554
Kailang Yangf1d4e282008-08-26 14:03:29 +020018555static void alc663_mode6_inithook(struct hda_codec *codec)
18556{
18557 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018558 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018559}
18560
Kailang Yangebb83ee2009-12-17 12:23:00 +010018561/* ***************** Mode7 ******************************/
18562static void alc663_mode7_unsol_event(struct hda_codec *codec,
18563 unsigned int res)
18564{
18565 switch (res >> 26) {
18566 case ALC880_HP_EVENT:
18567 alc663_two_hp_m7_speaker_automute(codec);
18568 break;
18569 case ALC880_MIC_EVENT:
18570 alc_mic_automute(codec);
18571 break;
18572 }
18573}
18574
18575#define alc663_mode7_setup alc663_mode1_setup
18576
18577static void alc663_mode7_inithook(struct hda_codec *codec)
18578{
18579 alc663_two_hp_m7_speaker_automute(codec);
18580 alc_mic_automute(codec);
18581}
18582
18583/* ***************** Mode8 ******************************/
18584static void alc663_mode8_unsol_event(struct hda_codec *codec,
18585 unsigned int res)
18586{
18587 switch (res >> 26) {
18588 case ALC880_HP_EVENT:
18589 alc663_two_hp_m8_speaker_automute(codec);
18590 break;
18591 case ALC880_MIC_EVENT:
18592 alc_mic_automute(codec);
18593 break;
18594 }
18595}
18596
18597#define alc663_mode8_setup alc663_m51va_setup
18598
18599static void alc663_mode8_inithook(struct hda_codec *codec)
18600{
18601 alc663_two_hp_m8_speaker_automute(codec);
18602 alc_mic_automute(codec);
18603}
18604
Kailang Yang6dda9f42008-05-27 12:05:31 +020018605static void alc663_g71v_hp_automute(struct hda_codec *codec)
18606{
18607 unsigned int present;
18608 unsigned char bits;
18609
Wu Fengguang864f92b2009-11-18 12:38:02 +080018610 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018611 bits = present ? HDA_AMP_MUTE : 0;
18612 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18613 HDA_AMP_MUTE, bits);
18614 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18615 HDA_AMP_MUTE, bits);
18616}
18617
18618static void alc663_g71v_front_automute(struct hda_codec *codec)
18619{
18620 unsigned int present;
18621 unsigned char bits;
18622
Wu Fengguang864f92b2009-11-18 12:38:02 +080018623 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018624 bits = present ? HDA_AMP_MUTE : 0;
18625 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18626 HDA_AMP_MUTE, bits);
18627}
18628
18629static void alc663_g71v_unsol_event(struct hda_codec *codec,
18630 unsigned int res)
18631{
18632 switch (res >> 26) {
18633 case ALC880_HP_EVENT:
18634 alc663_g71v_hp_automute(codec);
18635 break;
18636 case ALC880_FRONT_EVENT:
18637 alc663_g71v_front_automute(codec);
18638 break;
18639 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018640 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018641 break;
18642 }
18643}
18644
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018645#define alc663_g71v_setup alc663_m51va_setup
18646
Kailang Yang6dda9f42008-05-27 12:05:31 +020018647static void alc663_g71v_inithook(struct hda_codec *codec)
18648{
18649 alc663_g71v_front_automute(codec);
18650 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018651 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018652}
18653
18654static void alc663_g50v_unsol_event(struct hda_codec *codec,
18655 unsigned int res)
18656{
18657 switch (res >> 26) {
18658 case ALC880_HP_EVENT:
18659 alc663_m51va_speaker_automute(codec);
18660 break;
18661 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018662 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018663 break;
18664 }
18665}
18666
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018667#define alc663_g50v_setup alc663_m51va_setup
18668
Kailang Yang6dda9f42008-05-27 12:05:31 +020018669static void alc663_g50v_inithook(struct hda_codec *codec)
18670{
18671 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018672 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018673}
18674
Kailang Yangf1d4e282008-08-26 14:03:29 +020018675static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18676 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018677 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018678
David Henningsson5f99f862011-01-04 15:24:24 +010018679 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018680 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18681 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018682
David Henningsson5f99f862011-01-04 15:24:24 +010018683 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018684 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18685 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018686 { } /* end */
18687};
18688
Chris Pockelé9541ba12009-05-12 08:08:53 +020018689static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18690 /* Master Playback automatically created from Speaker and Headphone */
18691 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18692 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18693 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18694 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18695
David Henningsson8607f7c2010-12-20 14:43:54 +010018696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018698 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018699
David Henningsson28c4edb2010-12-20 14:24:29 +010018700 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18701 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018702 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018703 { } /* end */
18704};
18705
Takashi Iwaicb53c622007-08-10 17:21:45 +020018706#ifdef CONFIG_SND_HDA_POWER_SAVE
18707#define alc662_loopbacks alc880_loopbacks
18708#endif
18709
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018710
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018711/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018712#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18713#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18714#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18715#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18716
18717/*
18718 * configuration and preset
18719 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018720static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018721 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18722 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18723 [ALC662_3ST_6ch] = "3stack-6ch",
18724 [ALC662_5ST_DIG] = "6stack-dig",
18725 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018726 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018727 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018728 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018729 [ALC663_ASUS_M51VA] = "m51va",
18730 [ALC663_ASUS_G71V] = "g71v",
18731 [ALC663_ASUS_H13] = "h13",
18732 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018733 [ALC663_ASUS_MODE1] = "asus-mode1",
18734 [ALC662_ASUS_MODE2] = "asus-mode2",
18735 [ALC663_ASUS_MODE3] = "asus-mode3",
18736 [ALC663_ASUS_MODE4] = "asus-mode4",
18737 [ALC663_ASUS_MODE5] = "asus-mode5",
18738 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018739 [ALC663_ASUS_MODE7] = "asus-mode7",
18740 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018741 [ALC272_DELL] = "dell",
18742 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018743 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018744 [ALC662_AUTO] = "auto",
18745};
18746
18747static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018748 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018749 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18750 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018751 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18752 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018753 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018754 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18755 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18756 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18757 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018758 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18759 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018760 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018761 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18762 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18763 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18764 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18765 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018766 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018767 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18768 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018769 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18770 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18771 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18772 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018773 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018774 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18775 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18776 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018777 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18778 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18779 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18780 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018781 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018782 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18783 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018784 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018785 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18786 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18787 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018788 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018789 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018790 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18791 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018792 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18793 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18794 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018795 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018796 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18797 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018798 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018799 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018800 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018801 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18802 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18803 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018804 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018805 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18806 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018807 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018808 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018809 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018810 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018811 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18812 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018813 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018814 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018815 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18816 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018817 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018818 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018819 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018820 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018821 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018822 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018823 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18824 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018825 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018826 {}
18827};
18828
18829static struct alc_config_preset alc662_presets[] = {
18830 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018831 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018832 .init_verbs = { alc662_init_verbs },
18833 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18834 .dac_nids = alc662_dac_nids,
18835 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018836 .dig_in_nid = ALC662_DIGIN_NID,
18837 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18838 .channel_mode = alc662_3ST_2ch_modes,
18839 .input_mux = &alc662_capture_source,
18840 },
18841 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018842 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018843 .init_verbs = { alc662_init_verbs },
18844 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18845 .dac_nids = alc662_dac_nids,
18846 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018847 .dig_in_nid = ALC662_DIGIN_NID,
18848 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18849 .channel_mode = alc662_3ST_6ch_modes,
18850 .need_dac_fix = 1,
18851 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018852 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018853 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018854 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018855 .init_verbs = { alc662_init_verbs },
18856 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18857 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018858 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18859 .channel_mode = alc662_3ST_6ch_modes,
18860 .need_dac_fix = 1,
18861 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018862 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018863 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018864 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018865 .init_verbs = { alc662_init_verbs },
18866 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18867 .dac_nids = alc662_dac_nids,
18868 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018869 .dig_in_nid = ALC662_DIGIN_NID,
18870 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18871 .channel_mode = alc662_5stack_modes,
18872 .input_mux = &alc662_capture_source,
18873 },
18874 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018875 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018876 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18877 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18878 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018879 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18880 .channel_mode = alc662_3ST_2ch_modes,
18881 .input_mux = &alc662_lenovo_101e_capture_source,
18882 .unsol_event = alc662_lenovo_101e_unsol_event,
18883 .init_hook = alc662_lenovo_101e_all_automute,
18884 },
Kailang Yang291702f2007-10-16 14:28:03 +020018885 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018886 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018887 .init_verbs = { alc662_init_verbs,
18888 alc662_eeepc_sue_init_verbs },
18889 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18890 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018891 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18892 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018893 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018894 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018895 .init_hook = alc662_eeepc_inithook,
18896 },
Kailang Yang8c427222008-01-10 13:03:59 +010018897 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018898 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018899 alc662_chmode_mixer },
18900 .init_verbs = { alc662_init_verbs,
18901 alc662_eeepc_ep20_sue_init_verbs },
18902 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18903 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018904 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18905 .channel_mode = alc662_3ST_6ch_modes,
18906 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018907 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018908 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018909 .init_hook = alc662_eeepc_ep20_inithook,
18910 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018911 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018912 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018913 .init_verbs = { alc662_init_verbs,
18914 alc662_ecs_init_verbs },
18915 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18916 .dac_nids = alc662_dac_nids,
18917 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18918 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018919 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018920 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018921 .init_hook = alc662_eeepc_inithook,
18922 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018923 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018924 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018925 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18926 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18927 .dac_nids = alc662_dac_nids,
18928 .dig_out_nid = ALC662_DIGOUT_NID,
18929 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18930 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018931 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018932 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018933 .init_hook = alc663_m51va_inithook,
18934 },
18935 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018936 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018937 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18938 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18939 .dac_nids = alc662_dac_nids,
18940 .dig_out_nid = ALC662_DIGOUT_NID,
18941 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18942 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018943 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018944 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018945 .init_hook = alc663_g71v_inithook,
18946 },
18947 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018948 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018949 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18950 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18951 .dac_nids = alc662_dac_nids,
18952 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18953 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018954 .unsol_event = alc663_m51va_unsol_event,
18955 .init_hook = alc663_m51va_inithook,
18956 },
18957 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018958 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018959 .init_verbs = { alc662_init_verbs, alc663_g50v_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_6ch_modes),
18964 .channel_mode = alc662_3ST_6ch_modes,
18965 .input_mux = &alc663_capture_source,
18966 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018967 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018968 .init_hook = alc663_g50v_inithook,
18969 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018970 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018971 .mixers = { alc663_m51va_mixer },
18972 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018973 .init_verbs = { alc662_init_verbs,
18974 alc663_21jd_amic_init_verbs },
18975 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18976 .hp_nid = 0x03,
18977 .dac_nids = alc662_dac_nids,
18978 .dig_out_nid = ALC662_DIGOUT_NID,
18979 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18980 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018981 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018982 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018983 .init_hook = alc663_mode1_inithook,
18984 },
18985 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018986 .mixers = { alc662_1bjd_mixer },
18987 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018988 .init_verbs = { alc662_init_verbs,
18989 alc662_1bjd_amic_init_verbs },
18990 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
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 = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018996 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018997 .init_hook = alc662_mode2_inithook,
18998 },
18999 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019000 .mixers = { alc663_two_hp_m1_mixer },
19001 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019002 .init_verbs = { alc662_init_verbs,
19003 alc663_two_hp_amic_m1_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_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019011 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019012 .init_hook = alc663_mode3_inithook,
19013 },
19014 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019015 .mixers = { alc663_asus_21jd_clfe_mixer },
19016 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019017 .init_verbs = { alc662_init_verbs,
19018 alc663_21jd_amic_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_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019026 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019027 .init_hook = alc663_mode4_inithook,
19028 },
19029 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019030 .mixers = { alc663_asus_15jd_clfe_mixer },
19031 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019032 .init_verbs = { alc662_init_verbs,
19033 alc663_15jd_amic_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,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019040 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019041 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019042 .init_hook = alc663_mode5_inithook,
19043 },
19044 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019045 .mixers = { alc663_two_hp_m2_mixer },
19046 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019047 .init_verbs = { alc662_init_verbs,
19048 alc663_two_hp_amic_m2_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,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019055 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019056 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019057 .init_hook = alc663_mode6_inithook,
19058 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019059 [ALC663_ASUS_MODE7] = {
19060 .mixers = { alc663_mode7_mixer },
19061 .cap_mixer = alc662_auto_capture_mixer,
19062 .init_verbs = { alc662_init_verbs,
19063 alc663_mode7_init_verbs },
19064 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19065 .hp_nid = 0x03,
19066 .dac_nids = alc662_dac_nids,
19067 .dig_out_nid = ALC662_DIGOUT_NID,
19068 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19069 .channel_mode = alc662_3ST_2ch_modes,
19070 .unsol_event = alc663_mode7_unsol_event,
19071 .setup = alc663_mode7_setup,
19072 .init_hook = alc663_mode7_inithook,
19073 },
19074 [ALC663_ASUS_MODE8] = {
19075 .mixers = { alc663_mode8_mixer },
19076 .cap_mixer = alc662_auto_capture_mixer,
19077 .init_verbs = { alc662_init_verbs,
19078 alc663_mode8_init_verbs },
19079 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19080 .hp_nid = 0x03,
19081 .dac_nids = alc662_dac_nids,
19082 .dig_out_nid = ALC662_DIGOUT_NID,
19083 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19084 .channel_mode = alc662_3ST_2ch_modes,
19085 .unsol_event = alc663_mode8_unsol_event,
19086 .setup = alc663_mode8_setup,
19087 .init_hook = alc663_mode8_inithook,
19088 },
Kailang Yang622e84c2009-04-21 07:39:04 +020019089 [ALC272_DELL] = {
19090 .mixers = { alc663_m51va_mixer },
19091 .cap_mixer = alc272_auto_capture_mixer,
19092 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
19093 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19094 .dac_nids = alc662_dac_nids,
19095 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19096 .adc_nids = alc272_adc_nids,
19097 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19098 .capsrc_nids = alc272_capsrc_nids,
19099 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019100 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019101 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019102 .init_hook = alc663_m51va_inithook,
19103 },
19104 [ALC272_DELL_ZM1] = {
19105 .mixers = { alc663_m51va_mixer },
19106 .cap_mixer = alc662_auto_capture_mixer,
19107 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
19108 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19109 .dac_nids = alc662_dac_nids,
19110 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19111 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019112 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020019113 .capsrc_nids = alc662_capsrc_nids,
19114 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019115 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019116 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019117 .init_hook = alc663_m51va_inithook,
19118 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020019119 [ALC272_SAMSUNG_NC10] = {
19120 .mixers = { alc272_nc10_mixer },
19121 .init_verbs = { alc662_init_verbs,
19122 alc663_21jd_amic_init_verbs },
19123 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19124 .dac_nids = alc272_dac_nids,
19125 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19126 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019127 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020019128 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019129 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020019130 .init_hook = alc663_mode4_inithook,
19131 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019132};
19133
19134
19135/*
19136 * BIOS auto configuration
19137 */
19138
Takashi Iwai7085ec12009-10-02 09:03:58 +020019139/* convert from MIX nid to DAC */
19140static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19141{
19142 if (nid == 0x0f)
19143 return 0x02;
19144 else if (nid >= 0x0c && nid <= 0x0e)
19145 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019146 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19147 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019148 else
19149 return 0;
19150}
19151
19152/* get MIX nid connected to the given pin targeted to DAC */
19153static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19154 hda_nid_t dac)
19155{
David Henningssoncc1c4522010-11-24 14:17:47 +010019156 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019157 int i, num;
19158
19159 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19160 for (i = 0; i < num; i++) {
19161 if (alc662_mix_to_dac(mix[i]) == dac)
19162 return mix[i];
19163 }
19164 return 0;
19165}
19166
19167/* look for an empty DAC slot */
19168static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19169{
19170 struct alc_spec *spec = codec->spec;
19171 hda_nid_t srcs[5];
19172 int i, j, num;
19173
19174 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19175 if (num < 0)
19176 return 0;
19177 for (i = 0; i < num; i++) {
19178 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19179 if (!nid)
19180 continue;
19181 for (j = 0; j < spec->multiout.num_dacs; j++)
19182 if (spec->multiout.dac_nids[j] == nid)
19183 break;
19184 if (j >= spec->multiout.num_dacs)
19185 return nid;
19186 }
19187 return 0;
19188}
19189
19190/* fill in the dac_nids table from the parsed pin configuration */
19191static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19192 const struct auto_pin_cfg *cfg)
19193{
19194 struct alc_spec *spec = codec->spec;
19195 int i;
19196 hda_nid_t dac;
19197
19198 spec->multiout.dac_nids = spec->private_dac_nids;
19199 for (i = 0; i < cfg->line_outs; i++) {
19200 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19201 if (!dac)
19202 continue;
19203 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19204 }
19205 return 0;
19206}
19207
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019208static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19209 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019210{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019211 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019212 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19213}
19214
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019215static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19216 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019217{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019218 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019219 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19220}
19221
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019222#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19223 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19224#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19225 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019226#define alc662_add_stereo_vol(spec, pfx, nid) \
19227 alc662_add_vol_ctl(spec, pfx, nid, 3)
19228#define alc662_add_stereo_sw(spec, pfx, nid) \
19229 alc662_add_sw_ctl(spec, pfx, nid, 3)
19230
19231/* add playback controls from the parsed DAC table */
19232static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19233 const struct auto_pin_cfg *cfg)
19234{
19235 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010019236 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019237 "Front", "Surround", NULL /*CLFE*/, "Side"
19238 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019239 const char *pfx = alc_get_line_out_pfx(cfg, true);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019240 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019241 int i, err;
19242
19243 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019244 nid = spec->multiout.dac_nids[i];
19245 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019246 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019247 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19248 if (!mix)
19249 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019250 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019251 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019252 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019253 if (err < 0)
19254 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019255 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019256 if (err < 0)
19257 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019258 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019259 if (err < 0)
19260 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019261 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019262 if (err < 0)
19263 return err;
19264 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019265 const char *name = pfx;
19266 if (!name)
19267 name = chname[i];
19268 err = __alc662_add_vol_ctl(spec, name, nid, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019269 if (err < 0)
19270 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019271 err = __alc662_add_sw_ctl(spec, name, mix, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019272 if (err < 0)
19273 return err;
19274 }
19275 }
19276 return 0;
19277}
19278
19279/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019280/* return DAC nid if any new DAC is assigned */
19281static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019282 const char *pfx)
19283{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019284 struct alc_spec *spec = codec->spec;
19285 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019286 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019287
19288 if (!pin)
19289 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019290 nid = alc662_look_for_dac(codec, pin);
19291 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019292 /* the corresponding DAC is already occupied */
19293 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19294 return 0; /* no way */
19295 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019296 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019297 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19298 }
19299
19300 mix = alc662_dac_to_mix(codec, pin, nid);
19301 if (!mix)
19302 return 0;
19303 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19304 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019305 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019306 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19307 if (err < 0)
19308 return err;
19309 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019310}
19311
19312/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019313#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019314 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019315
19316static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19317 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019318 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019319{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019320 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019321 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019322
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019323 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019324 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019325 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19326 if (num <= 1)
19327 return;
19328 for (i = 0; i < num; i++) {
19329 if (alc662_mix_to_dac(srcs[i]) != dac)
19330 continue;
19331 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19332 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019333 }
19334}
19335
19336static void alc662_auto_init_multi_out(struct hda_codec *codec)
19337{
19338 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019339 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019340 int i;
19341
19342 for (i = 0; i <= HDA_SIDE; i++) {
19343 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19344 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019345 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019346 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019347 }
19348}
19349
19350static void alc662_auto_init_hp_out(struct hda_codec *codec)
19351{
19352 struct alc_spec *spec = codec->spec;
19353 hda_nid_t pin;
19354
19355 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019356 if (pin)
19357 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19358 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019359 pin = spec->autocfg.speaker_pins[0];
19360 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019361 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19362 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019363}
19364
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019365#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19366
19367static void alc662_auto_init_analog_input(struct hda_codec *codec)
19368{
19369 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019370 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019371 int i;
19372
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019373 for (i = 0; i < cfg->num_inputs; i++) {
19374 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019375 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019376 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019377 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019378 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019379 snd_hda_codec_write(codec, nid, 0,
19380 AC_VERB_SET_AMP_GAIN_MUTE,
19381 AMP_OUT_MUTE);
19382 }
19383 }
19384}
19385
Takashi Iwaif511b012008-08-15 16:46:42 +020019386#define alc662_auto_init_input_src alc882_auto_init_input_src
19387
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019388static int alc662_parse_auto_config(struct hda_codec *codec)
19389{
19390 struct alc_spec *spec = codec->spec;
19391 int err;
19392 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19393
19394 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19395 alc662_ignore);
19396 if (err < 0)
19397 return err;
19398 if (!spec->autocfg.line_outs)
19399 return 0; /* can't find valid BIOS pin config */
19400
Takashi Iwai7085ec12009-10-02 09:03:58 +020019401 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019402 if (err < 0)
19403 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019404 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019405 if (err < 0)
19406 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019407 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019408 spec->autocfg.speaker_pins[0],
19409 "Speaker");
19410 if (err < 0)
19411 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019412 if (err)
19413 spec->multiout.extra_out_nid[0] = err;
19414 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019415 "Headphone");
19416 if (err < 0)
19417 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019418 if (err)
19419 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019420 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019421 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019422 return err;
19423
19424 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19425
Takashi Iwai757899a2010-07-30 10:48:14 +020019426 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019427
Takashi Iwai603c4012008-07-30 15:01:44 +020019428 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019429 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019430
19431 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019432 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019433
Kailang Yangcec27c82010-02-04 14:18:18 +010019434 add_verb(spec, alc662_init_verbs);
19435 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019436 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019437 add_verb(spec, alc663_init_verbs);
19438
19439 if (codec->vendor_id == 0x10ec0272)
19440 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019441
19442 err = alc_auto_add_mic_boost(codec);
19443 if (err < 0)
19444 return err;
19445
Kailang Yang6227cdc2010-02-25 08:36:52 +010019446 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19447 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19448 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19449 else
19450 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019451
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019452 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019453}
19454
19455/* additional initialization for auto-configuration model */
19456static void alc662_auto_init(struct hda_codec *codec)
19457{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019458 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019459 alc662_auto_init_multi_out(codec);
19460 alc662_auto_init_hp_out(codec);
19461 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019462 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019463 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019464 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019465 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019466}
19467
Todd Broch6be79482010-12-07 16:51:05 -080019468static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019469 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019470{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019471 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019472 return;
Todd Broch6be79482010-12-07 16:51:05 -080019473 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19474 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19475 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19476 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19477 (0 << AC_AMPCAP_MUTE_SHIFT)))
19478 printk(KERN_WARNING
19479 "hda_codec: failed to override amp caps for NID 0x2\n");
19480}
19481
David Henningsson6cb3b702010-09-09 08:51:44 +020019482enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019483 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019484 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019485 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019486 ALC662_FIXUP_CZC_P10T,
David Henningsson6cb3b702010-09-09 08:51:44 +020019487};
19488
19489static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019490 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019491 .type = ALC_FIXUP_PINS,
19492 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019493 { 0x15, 0x99130112 }, /* subwoofer */
19494 { }
19495 }
19496 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019497 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019498 .type = ALC_FIXUP_PINS,
19499 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019500 { 0x17, 0x99130112 }, /* subwoofer */
19501 { }
19502 }
19503 },
Todd Broch6be79482010-12-07 16:51:05 -080019504 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019505 .type = ALC_FIXUP_FUNC,
19506 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019507 },
19508 [ALC662_FIXUP_CZC_P10T] = {
19509 .type = ALC_FIXUP_VERBS,
19510 .v.verbs = (const struct hda_verb[]) {
19511 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19512 {}
19513 }
19514 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019515};
19516
19517static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019518 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019519 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019520 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019521 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019522 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019523 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019524 {}
19525};
19526
Todd Broch6be79482010-12-07 16:51:05 -080019527static const struct alc_model_fixup alc662_fixup_models[] = {
19528 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19529 {}
19530};
David Henningsson6cb3b702010-09-09 08:51:44 +020019531
19532
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019533static int patch_alc662(struct hda_codec *codec)
19534{
19535 struct alc_spec *spec;
19536 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019537 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019538
19539 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19540 if (!spec)
19541 return -ENOMEM;
19542
19543 codec->spec = spec;
19544
Kailang Yangda00c242010-03-19 11:23:45 +010019545 alc_auto_parse_customize_define(codec);
19546
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019547 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19548
Kailang Yang693194f2010-10-21 08:51:48 +020019549 coef = alc_read_coef_idx(codec, 0);
19550 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019551 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019552 else if (coef & (1 << 14) &&
19553 codec->bus->pci->subsystem_vendor == 0x1025 &&
19554 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019555 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019556 else if (coef == 0x4011)
19557 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019558
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019559 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19560 alc662_models,
19561 alc662_cfg_tbl);
19562 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019563 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19564 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019565 board_config = ALC662_AUTO;
19566 }
19567
19568 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019569 alc_pick_fixup(codec, alc662_fixup_models,
19570 alc662_fixup_tbl, alc662_fixups);
19571 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019572 /* automatic parse from the BIOS config */
19573 err = alc662_parse_auto_config(codec);
19574 if (err < 0) {
19575 alc_free(codec);
19576 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019577 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019578 printk(KERN_INFO
19579 "hda_codec: Cannot set up configuration "
19580 "from BIOS. Using base mode...\n");
19581 board_config = ALC662_3ST_2ch_DIG;
19582 }
19583 }
19584
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019585 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019586 err = snd_hda_attach_beep_device(codec, 0x1);
19587 if (err < 0) {
19588 alc_free(codec);
19589 return err;
19590 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019591 }
19592
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019593 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019594 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019595
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019596 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19597 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19598
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019599 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19600 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19601
Takashi Iwaidd704692009-08-11 08:45:11 +020019602 if (!spec->adc_nids) {
19603 spec->adc_nids = alc662_adc_nids;
19604 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19605 }
19606 if (!spec->capsrc_nids)
19607 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019608
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019609 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019610 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019611
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019612 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019613 switch (codec->vendor_id) {
19614 case 0x10ec0662:
19615 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19616 break;
19617 case 0x10ec0272:
19618 case 0x10ec0663:
19619 case 0x10ec0665:
19620 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19621 break;
19622 case 0x10ec0273:
19623 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19624 break;
19625 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019626 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019627 spec->vmaster_nid = 0x02;
19628
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019629 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19630
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019631 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019632 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019633 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019634
Kailang Yangbf1b0222010-10-21 08:49:56 +020019635 alc_init_jacks(codec);
19636
Takashi Iwaicb53c622007-08-10 17:21:45 +020019637#ifdef CONFIG_SND_HDA_POWER_SAVE
19638 if (!spec->loopback.amplist)
19639 spec->loopback.amplist = alc662_loopbacks;
19640#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019641
19642 return 0;
19643}
19644
Kailang Yang274693f2009-12-03 10:07:50 +010019645static int patch_alc888(struct hda_codec *codec)
19646{
19647 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19648 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019649 if (codec->vendor_id == 0x10ec0887)
19650 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19651 else
19652 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019653 if (!codec->chip_name) {
19654 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019655 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019656 }
19657 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019658 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019659 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019660}
19661
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019662/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019663 * ALC680 support
19664 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019665#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019666#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19667#define alc680_modes alc260_modes
19668
19669static hda_nid_t alc680_dac_nids[3] = {
19670 /* Lout1, Lout2, hp */
19671 0x02, 0x03, 0x04
19672};
19673
19674static hda_nid_t alc680_adc_nids[3] = {
19675 /* ADC0-2 */
19676 /* DMIC, MIC, Line-in*/
19677 0x07, 0x08, 0x09
19678};
19679
Kailang Yangc69aefa2010-08-17 10:39:22 +020019680/*
19681 * Analog capture ADC cgange
19682 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019683static void alc680_rec_autoswitch(struct hda_codec *codec)
19684{
19685 struct alc_spec *spec = codec->spec;
19686 struct auto_pin_cfg *cfg = &spec->autocfg;
19687 int pin_found = 0;
19688 int type_found = AUTO_PIN_LAST;
19689 hda_nid_t nid;
19690 int i;
19691
19692 for (i = 0; i < cfg->num_inputs; i++) {
19693 nid = cfg->inputs[i].pin;
19694 if (!(snd_hda_query_pin_caps(codec, nid) &
19695 AC_PINCAP_PRES_DETECT))
19696 continue;
19697 if (snd_hda_jack_detect(codec, nid)) {
19698 if (cfg->inputs[i].type < type_found) {
19699 type_found = cfg->inputs[i].type;
19700 pin_found = nid;
19701 }
19702 }
19703 }
19704
19705 nid = 0x07;
19706 if (pin_found)
19707 snd_hda_get_connections(codec, pin_found, &nid, 1);
19708
19709 if (nid != spec->cur_adc)
19710 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19711 spec->cur_adc = nid;
19712 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19713 spec->cur_adc_format);
19714}
19715
Kailang Yangc69aefa2010-08-17 10:39:22 +020019716static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19717 struct hda_codec *codec,
19718 unsigned int stream_tag,
19719 unsigned int format,
19720 struct snd_pcm_substream *substream)
19721{
19722 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019723
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019724 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019725 spec->cur_adc_stream_tag = stream_tag;
19726 spec->cur_adc_format = format;
19727
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019728 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019729 return 0;
19730}
19731
19732static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19733 struct hda_codec *codec,
19734 struct snd_pcm_substream *substream)
19735{
19736 snd_hda_codec_cleanup_stream(codec, 0x07);
19737 snd_hda_codec_cleanup_stream(codec, 0x08);
19738 snd_hda_codec_cleanup_stream(codec, 0x09);
19739 return 0;
19740}
19741
19742static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19743 .substreams = 1, /* can be overridden */
19744 .channels_min = 2,
19745 .channels_max = 2,
19746 /* NID is set in alc_build_pcms */
19747 .ops = {
19748 .prepare = alc680_capture_pcm_prepare,
19749 .cleanup = alc680_capture_pcm_cleanup
19750 },
19751};
19752
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019753static struct snd_kcontrol_new alc680_base_mixer[] = {
19754 /* output mixer control */
19755 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19756 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19757 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019759 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19760 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19761 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019762 { }
19763};
19764
Kailang Yangc69aefa2010-08-17 10:39:22 +020019765static struct hda_bind_ctls alc680_bind_cap_vol = {
19766 .ops = &snd_hda_bind_vol,
19767 .values = {
19768 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19769 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19770 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19771 0
19772 },
19773};
19774
19775static struct hda_bind_ctls alc680_bind_cap_switch = {
19776 .ops = &snd_hda_bind_sw,
19777 .values = {
19778 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19779 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19780 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19781 0
19782 },
19783};
19784
19785static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19786 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19787 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019788 { } /* end */
19789};
19790
19791/*
19792 * generic initialization of ADC, input mixers and output mixers
19793 */
19794static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019795 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19796 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19797 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019798
Kailang Yangc69aefa2010-08-17 10:39:22 +020019799 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19800 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19802 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19803 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19804 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019805
19806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19807 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19808 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19809 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19810 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019811
19812 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19813 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019814 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019815
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019816 { }
19817};
19818
Kailang Yangc69aefa2010-08-17 10:39:22 +020019819/* toggle speaker-output according to the hp-jack state */
19820static void alc680_base_setup(struct hda_codec *codec)
19821{
19822 struct alc_spec *spec = codec->spec;
19823
19824 spec->autocfg.hp_pins[0] = 0x16;
19825 spec->autocfg.speaker_pins[0] = 0x14;
19826 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019827 spec->autocfg.num_inputs = 2;
19828 spec->autocfg.inputs[0].pin = 0x18;
19829 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19830 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019831 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019832}
19833
19834static void alc680_unsol_event(struct hda_codec *codec,
19835 unsigned int res)
19836{
19837 if ((res >> 26) == ALC880_HP_EVENT)
19838 alc_automute_amp(codec);
19839 if ((res >> 26) == ALC880_MIC_EVENT)
19840 alc680_rec_autoswitch(codec);
19841}
19842
19843static void alc680_inithook(struct hda_codec *codec)
19844{
19845 alc_automute_amp(codec);
19846 alc680_rec_autoswitch(codec);
19847}
19848
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019849/* create input playback/capture controls for the given pin */
19850static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19851 const char *ctlname, int idx)
19852{
19853 hda_nid_t dac;
19854 int err;
19855
19856 switch (nid) {
19857 case 0x14:
19858 dac = 0x02;
19859 break;
19860 case 0x15:
19861 dac = 0x03;
19862 break;
19863 case 0x16:
19864 dac = 0x04;
19865 break;
19866 default:
19867 return 0;
19868 }
19869 if (spec->multiout.dac_nids[0] != dac &&
19870 spec->multiout.dac_nids[1] != dac) {
19871 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19872 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19873 HDA_OUTPUT));
19874 if (err < 0)
19875 return err;
19876
19877 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19878 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19879
19880 if (err < 0)
19881 return err;
19882 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19883 }
19884
19885 return 0;
19886}
19887
19888/* add playback controls from the parsed DAC table */
19889static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19890 const struct auto_pin_cfg *cfg)
19891{
19892 hda_nid_t nid;
19893 int err;
19894
19895 spec->multiout.dac_nids = spec->private_dac_nids;
19896
19897 nid = cfg->line_out_pins[0];
19898 if (nid) {
19899 const char *name;
19900 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19901 name = "Speaker";
19902 else
19903 name = "Front";
19904 err = alc680_new_analog_output(spec, nid, name, 0);
19905 if (err < 0)
19906 return err;
19907 }
19908
19909 nid = cfg->speaker_pins[0];
19910 if (nid) {
19911 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19912 if (err < 0)
19913 return err;
19914 }
19915 nid = cfg->hp_pins[0];
19916 if (nid) {
19917 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19918 if (err < 0)
19919 return err;
19920 }
19921
19922 return 0;
19923}
19924
19925static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19926 hda_nid_t nid, int pin_type)
19927{
19928 alc_set_pin_output(codec, nid, pin_type);
19929}
19930
19931static void alc680_auto_init_multi_out(struct hda_codec *codec)
19932{
19933 struct alc_spec *spec = codec->spec;
19934 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19935 if (nid) {
19936 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19937 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19938 }
19939}
19940
19941static void alc680_auto_init_hp_out(struct hda_codec *codec)
19942{
19943 struct alc_spec *spec = codec->spec;
19944 hda_nid_t pin;
19945
19946 pin = spec->autocfg.hp_pins[0];
19947 if (pin)
19948 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19949 pin = spec->autocfg.speaker_pins[0];
19950 if (pin)
19951 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19952}
19953
19954/* pcm configuration: identical with ALC880 */
19955#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19956#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19957#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19958#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019959#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019960
19961/*
19962 * BIOS auto configuration
19963 */
19964static int alc680_parse_auto_config(struct hda_codec *codec)
19965{
19966 struct alc_spec *spec = codec->spec;
19967 int err;
19968 static hda_nid_t alc680_ignore[] = { 0 };
19969
19970 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19971 alc680_ignore);
19972 if (err < 0)
19973 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019974
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019975 if (!spec->autocfg.line_outs) {
19976 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19977 spec->multiout.max_channels = 2;
19978 spec->no_analog = 1;
19979 goto dig_only;
19980 }
19981 return 0; /* can't find valid BIOS pin config */
19982 }
19983 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19984 if (err < 0)
19985 return err;
19986
19987 spec->multiout.max_channels = 2;
19988
19989 dig_only:
19990 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019991 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019992 if (spec->kctls.list)
19993 add_mixer(spec, spec->kctls.list);
19994
19995 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019996
19997 err = alc_auto_add_mic_boost(codec);
19998 if (err < 0)
19999 return err;
20000
20001 return 1;
20002}
20003
20004#define alc680_auto_init_analog_input alc882_auto_init_analog_input
20005
20006/* init callback for auto-configuration model -- overriding the default init */
20007static void alc680_auto_init(struct hda_codec *codec)
20008{
20009 struct alc_spec *spec = codec->spec;
20010 alc680_auto_init_multi_out(codec);
20011 alc680_auto_init_hp_out(codec);
20012 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020020013 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020014 if (spec->unsol_event)
20015 alc_inithook(codec);
20016}
20017
20018/*
20019 * configuration and preset
20020 */
Takashi Iwaiea734962011-01-17 11:29:34 +010020021static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020020022 [ALC680_BASE] = "base",
20023 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020024};
20025
20026static struct snd_pci_quirk alc680_cfg_tbl[] = {
20027 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
20028 {}
20029};
20030
20031static struct alc_config_preset alc680_presets[] = {
20032 [ALC680_BASE] = {
20033 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020020034 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020035 .init_verbs = { alc680_init_verbs },
20036 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
20037 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020038 .dig_out_nid = ALC680_DIGOUT_NID,
20039 .num_channel_mode = ARRAY_SIZE(alc680_modes),
20040 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020020041 .unsol_event = alc680_unsol_event,
20042 .setup = alc680_base_setup,
20043 .init_hook = alc680_inithook,
20044
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020045 },
20046};
20047
20048static int patch_alc680(struct hda_codec *codec)
20049{
20050 struct alc_spec *spec;
20051 int board_config;
20052 int err;
20053
20054 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
20055 if (spec == NULL)
20056 return -ENOMEM;
20057
20058 codec->spec = spec;
20059
20060 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
20061 alc680_models,
20062 alc680_cfg_tbl);
20063
20064 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
20065 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
20066 codec->chip_name);
20067 board_config = ALC680_AUTO;
20068 }
20069
20070 if (board_config == ALC680_AUTO) {
20071 /* automatic parse from the BIOS config */
20072 err = alc680_parse_auto_config(codec);
20073 if (err < 0) {
20074 alc_free(codec);
20075 return err;
20076 } else if (!err) {
20077 printk(KERN_INFO
20078 "hda_codec: Cannot set up configuration "
20079 "from BIOS. Using base mode...\n");
20080 board_config = ALC680_BASE;
20081 }
20082 }
20083
20084 if (board_config != ALC680_AUTO)
20085 setup_preset(codec, &alc680_presets[board_config]);
20086
20087 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020088 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020089 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020090 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020091
20092 if (!spec->adc_nids) {
20093 spec->adc_nids = alc680_adc_nids;
20094 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20095 }
20096
20097 if (!spec->cap_mixer)
20098 set_capture_mixer(codec);
20099
20100 spec->vmaster_nid = 0x02;
20101
20102 codec->patch_ops = alc_patch_ops;
20103 if (board_config == ALC680_AUTO)
20104 spec->init_hook = alc680_auto_init;
20105
20106 return 0;
20107}
20108
20109/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020110 * patch entries
20111 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020112static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020113 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020114 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020115 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020116 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020117 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020118 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020119 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020120 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020121 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020122 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020123 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20124 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20125 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020126 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020127 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020128 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20129 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020130 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020131 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020132 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020133 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020134 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020135 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020136 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020137 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020138 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020139 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020140 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020141 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020142 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020143 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020144 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020145 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020146 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020147 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020148 {} /* terminator */
20149};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020150
20151MODULE_ALIAS("snd-hda-codec-id:10ec*");
20152
20153MODULE_LICENSE("GPL");
20154MODULE_DESCRIPTION("Realtek HD-audio codec");
20155
20156static struct hda_codec_preset_list realtek_list = {
20157 .preset = snd_hda_preset_realtek,
20158 .owner = THIS_MODULE,
20159};
20160
20161static int __init patch_realtek_init(void)
20162{
20163 return snd_hda_add_codec_preset(&realtek_list);
20164}
20165
20166static void __exit patch_realtek_exit(void)
20167{
20168 snd_hda_delete_codec_preset(&realtek_list);
20169}
20170
20171module_init(patch_realtek_init)
20172module_exit(patch_realtek_exit)