blob: f6cd8ed3272f4017faff8b35274ee8f178c47904 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100134 ALC269_AMIC,
135 ALC269_DMIC,
136 ALC269VB_AMIC,
137 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100138 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000139 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100140 ALC269_AUTO,
141 ALC269_MODEL_LAST /* last tag */
142};
143
Kailang Yangdf694da2005-12-05 19:42:22 +0100144/* ALC861 models */
145enum {
146 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200147 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100148 ALC861_3ST_DIG,
149 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200150 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200151 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200152 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100153 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100154 ALC861_AUTO,
155 ALC861_MODEL_LAST,
156};
157
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158/* ALC861-VD models */
159enum {
160 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200161 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100162 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100163 ALC861VD_3ST,
164 ALC861VD_3ST_DIG,
165 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200166 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200167 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200168 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100169 ALC861VD_AUTO,
170 ALC861VD_MODEL_LAST,
171};
172
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200173/* ALC662 models */
174enum {
175 ALC662_3ST_2ch_DIG,
176 ALC662_3ST_6ch_DIG,
177 ALC662_3ST_6ch,
178 ALC662_5ST_DIG,
179 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200180 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100181 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200182 ALC663_ASUS_M51VA,
183 ALC663_ASUS_G71V,
184 ALC663_ASUS_H13,
185 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200186 ALC662_ECS,
187 ALC663_ASUS_MODE1,
188 ALC662_ASUS_MODE2,
189 ALC663_ASUS_MODE3,
190 ALC663_ASUS_MODE4,
191 ALC663_ASUS_MODE5,
192 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100193 ALC663_ASUS_MODE7,
194 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200195 ALC272_DELL,
196 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200197 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200198 ALC662_AUTO,
199 ALC662_MODEL_LAST,
200};
201
Kailang Yangdf694da2005-12-05 19:42:22 +0100202/* ALC882 models */
203enum {
204 ALC882_3ST_DIG,
205 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200206 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200207 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200208 ALC882_TARGA,
209 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200210 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100211 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800212 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200213 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200214 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100215 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200216 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800217 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200218 ALC883_3ST_2ch_DIG,
219 ALC883_3ST_6ch_DIG,
220 ALC883_3ST_6ch,
221 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200222 ALC883_TARGA_DIG,
223 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200224 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200225 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200226 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800227 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100228 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200229 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200230 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200231 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200232 ALC883_MEDION_MD2,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200233 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100234 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200235 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200236 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200237 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200238 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200239 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200240 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100241 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100242 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430243 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100244 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100245 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800246 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200247 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200248 ALC889A_INTEL,
249 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200250 ALC888_ASUS_M90V,
251 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200252 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100253 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200254 ALC883_SONY_VAIO_TT,
Takashi Iwai49535502009-06-30 15:28:30 +0200255 ALC882_AUTO,
256 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200257};
258
Kailang Yangdf694da2005-12-05 19:42:22 +0100259/* for GPIO Poll */
260#define GPIO_MASK 0x03
261
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200262/* extra amp-initialization sequence types */
263enum {
264 ALC_INIT_NONE,
265 ALC_INIT_DEFAULT,
266 ALC_INIT_GPIO1,
267 ALC_INIT_GPIO2,
268 ALC_INIT_GPIO3,
269};
270
Takashi Iwai6c819492009-08-10 18:47:44 +0200271struct alc_mic_route {
272 hda_nid_t pin;
273 unsigned char mux_idx;
274 unsigned char amix_idx;
275};
276
277#define MUX_IDX_UNDEF ((unsigned char)-1)
278
Kailang Yangda00c242010-03-19 11:23:45 +0100279struct alc_customize_define {
280 unsigned int sku_cfg;
281 unsigned char port_connectivity;
282 unsigned char check_sum;
283 unsigned char customization;
284 unsigned char external_amp;
285 unsigned int enable_pcbeep:1;
286 unsigned int platform_type:1;
287 unsigned int swap:1;
288 unsigned int override:1;
289};
290
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291struct alc_spec {
292 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100293 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100295 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100296 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200298 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200299 * don't forget NULL
300 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200301 */
302 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200304 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 struct hda_pcm_stream *stream_analog_playback;
306 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100307 struct hda_pcm_stream *stream_analog_alt_playback;
308 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200310 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 struct hda_pcm_stream *stream_digital_playback;
312 struct hda_pcm_stream *stream_digital_capture;
313
314 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200315 struct hda_multi_out multiout; /* playback set-up
316 * max_channels, dacs must be set
317 * dig_out_nid and hp_nid are optional
318 */
Takashi Iwai63300792008-01-24 15:31:36 +0100319 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100320 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100321 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 /* capture */
324 unsigned int num_adc_nids;
325 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100326 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200327 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
329 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200330 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 const struct hda_input_mux *input_mux;
332 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200333 struct alc_mic_route ext_mic;
334 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
336 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100337 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200339 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200340 int const_channel_count;
341 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342
343 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100344 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200345
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200346 /* dynamic controls, init_verbs and input_mux */
347 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100348 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200349 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200350 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200351 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai49535502009-06-30 15:28:30 +0200352 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
353 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100354
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100355 /* hooks */
356 void (*init_hook)(struct hda_codec *codec);
357 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100358#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500359 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100360#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100361
Takashi Iwai834be882006-03-01 14:16:17 +0100362 /* for pin sensing */
363 unsigned int sense_updated: 1;
364 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100365 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200366 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200367
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100368 /* other flags */
369 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200370 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100371
Takashi Iwai2134ea42008-01-10 16:53:55 +0100372 /* for virtual master */
373 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200374#ifdef CONFIG_SND_HDA_POWER_SAVE
375 struct hda_loopback_check loopback;
376#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200377
378 /* for PLL fix */
379 hda_nid_t pll_nid;
380 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100381};
382
383/*
384 * configuration template - to be copied to the spec instance
385 */
386struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200387 struct snd_kcontrol_new *mixers[5]; /* should be identical size
388 * with spec
389 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100390 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100391 const struct hda_verb *init_verbs[5];
392 unsigned int num_dacs;
393 hda_nid_t *dac_nids;
394 hda_nid_t dig_out_nid; /* optional */
395 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800396 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100397 unsigned int num_adc_nids;
398 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100399 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100400 hda_nid_t dig_in_nid;
401 unsigned int num_channel_mode;
402 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200403 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200404 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200405 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100406 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100407 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200408 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100409 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200410#ifdef CONFIG_SND_HDA_POWER_SAVE
411 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500412 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200413#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414};
415
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
417/*
418 * input MUX handling
419 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422{
423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200425 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
426 if (mux_idx >= spec->num_mux_defs)
427 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100428 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
429 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200430 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431}
432
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
434 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435{
436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
437 struct alc_spec *spec = codec->spec;
438 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
439
440 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
441 return 0;
442}
443
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200444static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
445 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446{
447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100449 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100451 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100452 hda_nid_t nid = spec->capsrc_nids ?
453 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200454 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
Takashi Iwaicd896c32008-11-18 12:36:33 +0100456 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
457 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100458 if (!imux->num_items && mux_idx > 0)
459 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100460
Takashi Iwaia22d5432009-07-27 12:54:26 +0200461 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200462 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100463 /* Matrix-mixer style (e.g. ALC882) */
464 unsigned int *cur_val = &spec->cur_mux[adc_idx];
465 unsigned int i, idx;
466
467 idx = ucontrol->value.enumerated.item[0];
468 if (idx >= imux->num_items)
469 idx = imux->num_items - 1;
470 if (*cur_val == idx)
471 return 0;
472 for (i = 0; i < imux->num_items; i++) {
473 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
474 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
475 imux->items[i].index,
476 HDA_AMP_MUTE, v);
477 }
478 *cur_val = idx;
479 return 1;
480 } else {
481 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100482 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100483 &spec->cur_mux[adc_idx]);
484 }
485}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200486
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487/*
488 * channel mode setting
489 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200490static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492{
493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
494 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100495 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
496 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497}
498
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200499static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501{
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
503 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100504 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200505 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200506 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507}
508
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200509static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511{
512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
513 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200514 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
515 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200516 &spec->ext_channel_count);
517 if (err >= 0 && !spec->const_channel_count) {
518 spec->multiout.max_channels = spec->ext_channel_count;
519 if (spec->need_dac_fix)
520 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
521 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200522 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523}
524
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200527 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528 * being part of a format specifier. Maximum allowed length of a value is
529 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100530 *
531 * Note: some retasking pin complexes seem to ignore requests for input
532 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
533 * are requested. Therefore order this list so that this behaviour will not
534 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200535 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
536 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200537 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100539 "Mic 50pc bias", "Mic 80pc bias",
540 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541};
542static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100543 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100544};
545/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200546 * in the pin being assumed to be exclusively an input or an output pin. In
547 * addition, "input" pins may or may not process the mic bias option
548 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
549 * accept requests for bias as of chip versions up to March 2006) and/or
550 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200552#define ALC_PIN_DIR_IN 0x00
553#define ALC_PIN_DIR_OUT 0x01
554#define ALC_PIN_DIR_INOUT 0x02
555#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
556#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100557
Kailang Yangea1fb292008-08-26 12:58:38 +0200558/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559 * For each direction the minimum and maximum values are given.
560 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200561static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562 { 0, 2 }, /* ALC_PIN_DIR_IN */
563 { 3, 4 }, /* ALC_PIN_DIR_OUT */
564 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200565 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
566 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567};
568#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
569#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
570#define alc_pin_mode_n_items(_dir) \
571 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
572
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200573static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
574 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200575{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 unsigned int item_num = uinfo->value.enumerated.item;
577 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
578
579 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200580 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
582
583 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
584 item_num = alc_pin_mode_min(dir);
585 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200586 return 0;
587}
588
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200589static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
590 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200591{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200593 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
594 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100595 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200596 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
598 AC_VERB_GET_PIN_WIDGET_CONTROL,
599 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200600
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100601 /* Find enumerated value for current pinctl setting */
602 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2c2009-08-02 13:30:45 +0200603 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100604 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606 return 0;
607}
608
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200609static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
610 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100611{
612 signed int change;
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 hda_nid_t nid = kcontrol->private_value & 0xffff;
615 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
616 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200617 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
618 AC_VERB_GET_PIN_WIDGET_CONTROL,
619 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100620
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200621 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100622 val = alc_pin_mode_min(dir);
623
624 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100625 if (change) {
626 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200627 snd_hda_codec_write_cache(codec, nid, 0,
628 AC_VERB_SET_PIN_WIDGET_CONTROL,
629 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100630
Kailang Yangea1fb292008-08-26 12:58:38 +0200631 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100632 * for the requested pin mode. Enum values of 2 or less are
633 * input modes.
634 *
635 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200636 * reduces noise slightly (particularly on input) so we'll
637 * do it. However, having both input and output buffers
638 * enabled simultaneously doesn't seem to be problematic if
639 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100640 */
641 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200642 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
643 HDA_AMP_MUTE, HDA_AMP_MUTE);
644 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
645 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100646 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200647 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
648 HDA_AMP_MUTE, HDA_AMP_MUTE);
649 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
650 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100651 }
652 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200653 return change;
654}
655
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100656#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200657 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100658 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100659 .info = alc_pin_mode_info, \
660 .get = alc_pin_mode_get, \
661 .put = alc_pin_mode_put, \
662 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100663
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100664/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
665 * together using a mask with more than one bit set. This control is
666 * currently used only by the ALC260 test model. At this stage they are not
667 * needed for any "production" models.
668 */
669#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200670#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200671
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200672static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100674{
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 hda_nid_t nid = kcontrol->private_value & 0xffff;
677 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
678 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679 unsigned int val = snd_hda_codec_read(codec, nid, 0,
680 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100681
682 *valp = (val & mask) != 0;
683 return 0;
684}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200685static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
686 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100687{
688 signed int change;
689 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
690 hda_nid_t nid = kcontrol->private_value & 0xffff;
691 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
692 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200693 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
694 AC_VERB_GET_GPIO_DATA,
695 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100696
697 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200698 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
699 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100700 gpio_data &= ~mask;
701 else
702 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200703 snd_hda_codec_write_cache(codec, nid, 0,
704 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100705
706 return change;
707}
708#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
709 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100710 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100711 .info = alc_gpio_data_info, \
712 .get = alc_gpio_data_get, \
713 .put = alc_gpio_data_put, \
714 .private_value = nid | (mask<<16) }
715#endif /* CONFIG_SND_DEBUG */
716
Jonathan Woithe92621f12006-02-28 11:47:47 +0100717/* A switch control to allow the enabling of the digital IO pins on the
718 * ALC260. This is incredibly simplistic; the intention of this control is
719 * to provide something in the test model allowing digital outputs to be
720 * identified if present. If models are found which can utilise these
721 * outputs a more complete mixer control can be devised for those models if
722 * necessary.
723 */
724#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200725#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200726
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200727static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
728 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100729{
730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
731 hda_nid_t nid = kcontrol->private_value & 0xffff;
732 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
733 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200734 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100735 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100736
737 *valp = (val & mask) != 0;
738 return 0;
739}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200740static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
741 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100742{
743 signed int change;
744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
745 hda_nid_t nid = kcontrol->private_value & 0xffff;
746 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
747 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200748 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100749 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200750 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100751
752 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200753 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100754 if (val==0)
755 ctrl_data &= ~mask;
756 else
757 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200758 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
759 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100760
761 return change;
762}
763#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
764 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100765 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100766 .info = alc_spdif_ctrl_info, \
767 .get = alc_spdif_ctrl_get, \
768 .put = alc_spdif_ctrl_put, \
769 .private_value = nid | (mask<<16) }
770#endif /* CONFIG_SND_DEBUG */
771
Jonathan Woithef8225f62008-01-08 12:16:54 +0100772/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
773 * Again, this is only used in the ALC26x test models to help identify when
774 * the EAPD line must be asserted for features to work.
775 */
776#ifdef CONFIG_SND_DEBUG
777#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
778
779static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
780 struct snd_ctl_elem_value *ucontrol)
781{
782 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
783 hda_nid_t nid = kcontrol->private_value & 0xffff;
784 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
785 long *valp = ucontrol->value.integer.value;
786 unsigned int val = snd_hda_codec_read(codec, nid, 0,
787 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
788
789 *valp = (val & mask) != 0;
790 return 0;
791}
792
793static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
794 struct snd_ctl_elem_value *ucontrol)
795{
796 int change;
797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
798 hda_nid_t nid = kcontrol->private_value & 0xffff;
799 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
800 long val = *ucontrol->value.integer.value;
801 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
802 AC_VERB_GET_EAPD_BTLENABLE,
803 0x00);
804
805 /* Set/unset the masked control bit(s) as needed */
806 change = (!val ? 0 : mask) != (ctrl_data & mask);
807 if (!val)
808 ctrl_data &= ~mask;
809 else
810 ctrl_data |= mask;
811 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
812 ctrl_data);
813
814 return change;
815}
816
817#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
818 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100819 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100820 .info = alc_eapd_ctrl_info, \
821 .get = alc_eapd_ctrl_get, \
822 .put = alc_eapd_ctrl_put, \
823 .private_value = nid | (mask<<16) }
824#endif /* CONFIG_SND_DEBUG */
825
Kailang Yangdf694da2005-12-05 19:42:22 +0100826/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100827 * set up the input pin config (depending on the given auto-pin type)
828 */
829static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
830 int auto_pin_type)
831{
832 unsigned int val = PIN_IN;
833
834 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
835 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100836 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100837 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
838 if (pincap & AC_PINCAP_VREF_80)
839 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200840 else if (pincap & AC_PINCAP_VREF_50)
841 val = PIN_VREF50;
842 else if (pincap & AC_PINCAP_VREF_100)
843 val = PIN_VREF100;
844 else if (pincap & AC_PINCAP_VREF_GRD)
845 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100846 }
847 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
848}
849
850/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100851 */
852static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
853{
854 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
855 return;
856 spec->mixers[spec->num_mixers++] = mix;
857}
858
859static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
860{
861 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
862 return;
863 spec->init_verbs[spec->num_init_verbs++] = verb;
864}
865
866/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100867 * set up from the preset table
868 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200869static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200870 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100871{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200872 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100873 int i;
874
875 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100876 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100877 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200878 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
879 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100880 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200881
Kailang Yangdf694da2005-12-05 19:42:22 +0100882 spec->channel_mode = preset->channel_mode;
883 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200884 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200885 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100886
Hector Martin3b315d72009-06-02 10:54:19 +0200887 if (preset->const_channel_count)
888 spec->multiout.max_channels = preset->const_channel_count;
889 else
890 spec->multiout.max_channels = spec->channel_mode[0].channels;
891 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100892
893 spec->multiout.num_dacs = preset->num_dacs;
894 spec->multiout.dac_nids = preset->dac_nids;
895 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800896 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100897 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200898
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200899 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200900 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200901 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100902 spec->input_mux = preset->input_mux;
903
904 spec->num_adc_nids = preset->num_adc_nids;
905 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100906 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100907 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100908
909 spec->unsol_event = preset->unsol_event;
910 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200911#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100912 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200913 spec->loopback.amplist = preset->loopbacks;
914#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200915
916 if (preset->setup)
917 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100918}
919
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200920/* Enable GPIO mask and set output */
921static struct hda_verb alc_gpio1_init_verbs[] = {
922 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
923 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
924 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
925 { }
926};
927
928static struct hda_verb alc_gpio2_init_verbs[] = {
929 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
930 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
931 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
932 { }
933};
934
Kailang Yangbdd148a2007-05-08 15:19:08 +0200935static struct hda_verb alc_gpio3_init_verbs[] = {
936 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
937 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
938 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
939 { }
940};
941
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200942/*
943 * Fix hardware PLL issue
944 * On some codecs, the analog PLL gating control must be off while
945 * the default value is 1.
946 */
947static void alc_fix_pll(struct hda_codec *codec)
948{
949 struct alc_spec *spec = codec->spec;
950 unsigned int val;
951
952 if (!spec->pll_nid)
953 return;
954 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
955 spec->pll_coef_idx);
956 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
957 AC_VERB_GET_PROC_COEF, 0);
958 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
959 spec->pll_coef_idx);
960 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
961 val & ~(1 << spec->pll_coef_bit));
962}
963
964static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
965 unsigned int coef_idx, unsigned int coef_bit)
966{
967 struct alc_spec *spec = codec->spec;
968 spec->pll_nid = nid;
969 spec->pll_coef_idx = coef_idx;
970 spec->pll_coef_bit = coef_bit;
971 alc_fix_pll(codec);
972}
973
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200974static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200975{
976 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200977 unsigned int nid = spec->autocfg.hp_pins[0];
978 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200979
Takashi Iwaiad87c642009-11-02 14:23:15 +0100980 if (!nid)
981 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800982 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200983 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
984 nid = spec->autocfg.speaker_pins[i];
985 if (!nid)
986 break;
987 snd_hda_codec_write(codec, nid, 0,
988 AC_VERB_SET_PIN_WIDGET_CONTROL,
989 spec->jack_present ? 0 : PIN_OUT);
990 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200991}
992
Takashi Iwai6c819492009-08-10 18:47:44 +0200993static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
994 hda_nid_t nid)
995{
996 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
997 int i, nums;
998
999 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1000 for (i = 0; i < nums; i++)
1001 if (conn[i] == nid)
1002 return i;
1003 return -1;
1004}
1005
Kailang Yang7fb0d782008-10-15 11:12:35 +02001006static void alc_mic_automute(struct hda_codec *codec)
1007{
1008 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001009 struct alc_mic_route *dead, *alive;
1010 unsigned int present, type;
1011 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001012
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001013 if (!spec->auto_mic)
1014 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001015 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1016 return;
1017 if (snd_BUG_ON(!spec->adc_nids))
1018 return;
1019
1020 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1021
Wu Fengguang864f92b2009-11-18 12:38:02 +08001022 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001023 if (present) {
1024 alive = &spec->ext_mic;
1025 dead = &spec->int_mic;
1026 } else {
1027 alive = &spec->int_mic;
1028 dead = &spec->ext_mic;
1029 }
1030
Takashi Iwai6c819492009-08-10 18:47:44 +02001031 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1032 if (type == AC_WID_AUD_MIX) {
1033 /* Matrix-mixer style (e.g. ALC882) */
1034 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1035 alive->mux_idx,
1036 HDA_AMP_MUTE, 0);
1037 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1038 dead->mux_idx,
1039 HDA_AMP_MUTE, HDA_AMP_MUTE);
1040 } else {
1041 /* MUX style (e.g. ALC880) */
1042 snd_hda_codec_write_cache(codec, cap_nid, 0,
1043 AC_VERB_SET_CONNECT_SEL,
1044 alive->mux_idx);
1045 }
1046
1047 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001048}
1049
Kailang Yangc9b58002007-10-16 14:30:01 +02001050/* unsolicited event for HP jack sensing */
1051static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1052{
1053 if (codec->vendor_id == 0x10ec0880)
1054 res >>= 28;
1055 else
1056 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001057 switch (res) {
1058 case ALC880_HP_EVENT:
1059 alc_automute_pin(codec);
1060 break;
1061 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001062 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001063 break;
1064 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001065}
1066
1067static void alc_inithook(struct hda_codec *codec)
1068{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001069 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001070 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001071}
1072
Kailang Yangf9423e72008-05-27 12:32:25 +02001073/* additional initialization for ALC888 variants */
1074static void alc888_coef_init(struct hda_codec *codec)
1075{
1076 unsigned int tmp;
1077
1078 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1079 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1080 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001081 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001082 /* alc888S-VC */
1083 snd_hda_codec_read(codec, 0x20, 0,
1084 AC_VERB_SET_PROC_COEF, 0x830);
1085 else
1086 /* alc888-VB */
1087 snd_hda_codec_read(codec, 0x20, 0,
1088 AC_VERB_SET_PROC_COEF, 0x3030);
1089}
1090
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001091static void alc889_coef_init(struct hda_codec *codec)
1092{
1093 unsigned int tmp;
1094
1095 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1096 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1097 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1098 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1099}
1100
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001101/* turn on/off EAPD control (only if available) */
1102static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1103{
1104 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1105 return;
1106 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1107 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1108 on ? 2 : 0);
1109}
1110
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001111static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001112{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001113 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001114
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001115 switch (type) {
1116 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001117 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1118 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001119 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001120 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1121 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001122 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001123 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1124 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001125 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001126 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001128 set_eapd(codec, 0x0f, 1);
1129 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 break;
1131 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001132 case 0x10ec0267:
1133 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001135 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001136 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001137 case 0x10ec0660:
1138 case 0x10ec0662:
1139 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001140 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001141 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001142 set_eapd(codec, 0x14, 1);
1143 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001144 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001145 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001146 switch (codec->vendor_id) {
1147 case 0x10ec0260:
1148 snd_hda_codec_write(codec, 0x1a, 0,
1149 AC_VERB_SET_COEF_INDEX, 7);
1150 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1151 AC_VERB_GET_PROC_COEF, 0);
1152 snd_hda_codec_write(codec, 0x1a, 0,
1153 AC_VERB_SET_COEF_INDEX, 7);
1154 snd_hda_codec_write(codec, 0x1a, 0,
1155 AC_VERB_SET_PROC_COEF,
1156 tmp | 0x2010);
1157 break;
1158 case 0x10ec0262:
1159 case 0x10ec0880:
1160 case 0x10ec0882:
1161 case 0x10ec0883:
1162 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001163 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001164 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001165 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001166 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001167 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001168 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001169 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001170#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001171 case 0x10ec0267:
1172 case 0x10ec0268:
1173 snd_hda_codec_write(codec, 0x20, 0,
1174 AC_VERB_SET_COEF_INDEX, 7);
1175 tmp = snd_hda_codec_read(codec, 0x20, 0,
1176 AC_VERB_GET_PROC_COEF, 0);
1177 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001178 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001179 snd_hda_codec_write(codec, 0x20, 0,
1180 AC_VERB_SET_PROC_COEF,
1181 tmp | 0x3000);
1182 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001183#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001184 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001185 break;
1186 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001187}
Kailang Yangea1fb292008-08-26 12:58:38 +02001188
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001189static void alc_init_auto_hp(struct hda_codec *codec)
1190{
1191 struct alc_spec *spec = codec->spec;
1192
1193 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001194 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001195
Kailang Yangc9b58002007-10-16 14:30:01 +02001196 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001197 if (spec->autocfg.line_out_pins[0] &&
1198 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001199 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001200 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001201 else
1202 return;
1203 }
1204
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001205 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1206 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001207 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1208 AC_VERB_SET_UNSOLICITED_ENABLE,
1209 AC_USRSP_EN | ALC880_HP_EVENT);
1210 spec->unsol_event = alc_sku_unsol_event;
1211}
1212
Takashi Iwai6c819492009-08-10 18:47:44 +02001213static void alc_init_auto_mic(struct hda_codec *codec)
1214{
1215 struct alc_spec *spec = codec->spec;
1216 struct auto_pin_cfg *cfg = &spec->autocfg;
1217 hda_nid_t fixed, ext;
1218 int i;
1219
1220 /* there must be only two mic inputs exclusively */
1221 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1222 if (cfg->input_pins[i])
1223 return;
1224
1225 fixed = ext = 0;
1226 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1227 hda_nid_t nid = cfg->input_pins[i];
1228 unsigned int defcfg;
1229 if (!nid)
1230 return;
1231 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1232 switch (get_defcfg_connect(defcfg)) {
1233 case AC_JACK_PORT_FIXED:
1234 if (fixed)
1235 return; /* already occupied */
1236 fixed = nid;
1237 break;
1238 case AC_JACK_PORT_COMPLEX:
1239 if (ext)
1240 return; /* already occupied */
1241 ext = nid;
1242 break;
1243 default:
1244 return; /* invalid entry */
1245 }
1246 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001247 if (!ext || !fixed)
1248 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001249 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1250 return; /* no unsol support */
1251 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1252 ext, fixed);
1253 spec->ext_mic.pin = ext;
1254 spec->int_mic.pin = fixed;
1255 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1256 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1257 spec->auto_mic = 1;
1258 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1259 AC_VERB_SET_UNSOLICITED_ENABLE,
1260 AC_USRSP_EN | ALC880_MIC_EVENT);
1261 spec->unsol_event = alc_sku_unsol_event;
1262}
1263
Kailang Yangda00c242010-03-19 11:23:45 +01001264static int alc_auto_parse_customize_define(struct hda_codec *codec)
1265{
1266 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001267 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001268 struct alc_spec *spec = codec->spec;
1269
1270 ass = codec->subsystem_id & 0xffff;
1271 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1272 goto do_sku;
1273
1274 nid = 0x1d;
1275 if (codec->vendor_id == 0x10ec0260)
1276 nid = 0x17;
1277 ass = snd_hda_codec_get_pincfg(codec, nid);
1278
1279 if (!(ass & 1)) {
1280 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1281 codec->chip_name, ass);
1282 return -1;
1283 }
1284
1285 /* check sum */
1286 tmp = 0;
1287 for (i = 1; i < 16; i++) {
1288 if ((ass >> i) & 1)
1289 tmp++;
1290 }
1291 if (((ass >> 16) & 0xf) != tmp)
1292 return -1;
1293
1294 spec->cdefine.port_connectivity = ass >> 30;
1295 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1296 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1297 spec->cdefine.customization = ass >> 8;
1298do_sku:
1299 spec->cdefine.sku_cfg = ass;
1300 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1301 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1302 spec->cdefine.swap = (ass & 0x2) >> 1;
1303 spec->cdefine.override = ass & 0x1;
1304
1305 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1306 nid, spec->cdefine.sku_cfg);
1307 snd_printd("SKU: port_connectivity=0x%x\n",
1308 spec->cdefine.port_connectivity);
1309 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1310 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1311 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1312 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1313 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1314 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1315 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1316
1317 return 0;
1318}
1319
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001320/* check subsystem ID and set up device-specific initialization;
1321 * return 1 if initialized, 0 if invalid SSID
1322 */
1323/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1324 * 31 ~ 16 : Manufacture ID
1325 * 15 ~ 8 : SKU ID
1326 * 7 ~ 0 : Assembly ID
1327 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1328 */
1329static int alc_subsystem_id(struct hda_codec *codec,
1330 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001331 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001332{
1333 unsigned int ass, tmp, i;
1334 unsigned nid;
1335 struct alc_spec *spec = codec->spec;
1336
1337 ass = codec->subsystem_id & 0xffff;
1338 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1339 goto do_sku;
1340
1341 /* invalid SSID, check the special NID pin defcfg instead */
1342 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001343 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001344 * 29~21 : reserve
1345 * 20 : PCBEEP input
1346 * 19~16 : Check sum (15:1)
1347 * 15~1 : Custom
1348 * 0 : override
1349 */
1350 nid = 0x1d;
1351 if (codec->vendor_id == 0x10ec0260)
1352 nid = 0x17;
1353 ass = snd_hda_codec_get_pincfg(codec, nid);
1354 snd_printd("realtek: No valid SSID, "
1355 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001356 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001357 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001358 return 0;
1359 if ((ass >> 30) != 1) /* no physical connection */
1360 return 0;
1361
1362 /* check sum */
1363 tmp = 0;
1364 for (i = 1; i < 16; i++) {
1365 if ((ass >> i) & 1)
1366 tmp++;
1367 }
1368 if (((ass >> 16) & 0xf) != tmp)
1369 return 0;
1370do_sku:
1371 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1372 ass & 0xffff, codec->vendor_id);
1373 /*
1374 * 0 : override
1375 * 1 : Swap Jack
1376 * 2 : 0 --> Desktop, 1 --> Laptop
1377 * 3~5 : External Amplifier control
1378 * 7~6 : Reserved
1379 */
1380 tmp = (ass & 0x38) >> 3; /* external Amp control */
1381 switch (tmp) {
1382 case 1:
1383 spec->init_amp = ALC_INIT_GPIO1;
1384 break;
1385 case 3:
1386 spec->init_amp = ALC_INIT_GPIO2;
1387 break;
1388 case 7:
1389 spec->init_amp = ALC_INIT_GPIO3;
1390 break;
1391 case 5:
1392 spec->init_amp = ALC_INIT_DEFAULT;
1393 break;
1394 }
1395
1396 /* is laptop or Desktop and enable the function "Mute internal speaker
1397 * when the external headphone out jack is plugged"
1398 */
1399 if (!(ass & 0x8000))
1400 return 1;
1401 /*
1402 * 10~8 : Jack location
1403 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1404 * 14~13: Resvered
1405 * 15 : 1 --> enable the function "Mute internal speaker
1406 * when the external headphone out jack is plugged"
1407 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001408 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001409 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001410 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1411 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001412 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001413 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001414 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001415 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001416 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001417 else if (tmp == 3)
1418 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001419 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001420 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001421 for (i = 0; i < spec->autocfg.line_outs; i++)
1422 if (spec->autocfg.line_out_pins[i] == nid)
1423 return 1;
1424 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001425 }
1426
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001427 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001428 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001429 return 1;
1430}
Kailang Yangea1fb292008-08-26 12:58:38 +02001431
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001432static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001433 hda_nid_t porta, hda_nid_t porte,
1434 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001435{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001436 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001437 struct alc_spec *spec = codec->spec;
1438 snd_printd("realtek: "
1439 "Enable default setup for auto mode as fallback\n");
1440 spec->init_amp = ALC_INIT_DEFAULT;
1441 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001442 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001443 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001444}
1445
Takashi Iwai41e41f12005-06-08 14:48:49 +02001446/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001447 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001448 */
1449
1450struct alc_pincfg {
1451 hda_nid_t nid;
1452 u32 val;
1453};
1454
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001455struct alc_fixup {
1456 const struct alc_pincfg *pins;
1457 const struct hda_verb *verbs;
1458};
1459
1460static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001461 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001462 const struct alc_fixup *fix,
1463 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001464{
1465 const struct alc_pincfg *cfg;
1466
1467 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1468 if (!quirk)
1469 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001470 fix += quirk->value;
1471 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001472 if (pre_init && cfg) {
1473#ifdef CONFIG_SND_DEBUG_VERBOSE
1474 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1475 codec->chip_name, quirk->name);
1476#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001477 for (; cfg->nid; cfg++)
1478 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1479 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001480 if (!pre_init && fix->verbs) {
1481#ifdef CONFIG_SND_DEBUG_VERBOSE
1482 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1483 codec->chip_name, quirk->name);
1484#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001485 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001486 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001487}
1488
Kailang Yang274693f2009-12-03 10:07:50 +01001489static int alc_read_coef_idx(struct hda_codec *codec,
1490 unsigned int coef_idx)
1491{
1492 unsigned int val;
1493 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1494 coef_idx);
1495 val = snd_hda_codec_read(codec, 0x20, 0,
1496 AC_VERB_GET_PROC_COEF, 0);
1497 return val;
1498}
1499
Takashi Iwaif95474e2007-07-10 00:47:43 +02001500/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001501 * ALC888
1502 */
1503
1504/*
1505 * 2ch mode
1506 */
1507static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1508/* Mic-in jack as mic in */
1509 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1510 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1511/* Line-in jack as Line in */
1512 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1513 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1514/* Line-Out as Front */
1515 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1516 { } /* end */
1517};
1518
1519/*
1520 * 4ch mode
1521 */
1522static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1523/* Mic-in jack as mic in */
1524 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1525 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1526/* Line-in jack as Surround */
1527 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1528 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1529/* Line-Out as Front */
1530 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1531 { } /* end */
1532};
1533
1534/*
1535 * 6ch mode
1536 */
1537static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1538/* Mic-in jack as CLFE */
1539 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1540 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1541/* Line-in jack as Surround */
1542 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1543 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1544/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1545 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1546 { } /* end */
1547};
1548
1549/*
1550 * 8ch mode
1551 */
1552static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1553/* Mic-in jack as CLFE */
1554 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1555 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1556/* Line-in jack as Surround */
1557 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1558 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1559/* Line-Out as Side */
1560 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1561 { } /* end */
1562};
1563
1564static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1565 { 2, alc888_4ST_ch2_intel_init },
1566 { 4, alc888_4ST_ch4_intel_init },
1567 { 6, alc888_4ST_ch6_intel_init },
1568 { 8, alc888_4ST_ch8_intel_init },
1569};
1570
1571/*
1572 * ALC888 Fujitsu Siemens Amillo xa3530
1573 */
1574
1575static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1576/* Front Mic: set to PIN_IN (empty by default) */
1577 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1578/* Connect Internal HP to Front */
1579 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1580 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1581 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1582/* Connect Bass HP to Front */
1583 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1584 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1586/* Connect Line-Out side jack (SPDIF) to Side */
1587 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1588 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1589 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1590/* Connect Mic jack to CLFE */
1591 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1592 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1593 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1594/* Connect Line-in jack to Surround */
1595 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1596 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1597 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1598/* Connect HP out jack to Front */
1599 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1600 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1601 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1602/* Enable unsolicited event for HP jack and Line-out jack */
1603 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1604 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1605 {}
1606};
1607
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001608static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001609{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001610 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001611 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001612 hda_nid_t nid;
1613 int i;
1614
1615 spec->jack_present = 0;
1616 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1617 nid = spec->autocfg.hp_pins[i];
1618 if (!nid)
1619 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001620 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001621 spec->jack_present = 1;
1622 break;
1623 }
1624 }
1625
1626 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001627 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001628 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1629 nid = spec->autocfg.speaker_pins[i];
1630 if (!nid)
1631 break;
1632 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1633 HDA_AMP_MUTE, mute);
1634 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001635}
1636
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001637static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1638 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001639{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001640 if (codec->vendor_id == 0x10ec0880)
1641 res >>= 28;
1642 else
1643 res >>= 26;
1644 if (res == ALC880_HP_EVENT)
1645 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001646}
1647
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001648static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001649{
1650 struct alc_spec *spec = codec->spec;
1651
1652 spec->autocfg.hp_pins[0] = 0x15;
1653 spec->autocfg.speaker_pins[0] = 0x14;
1654 spec->autocfg.speaker_pins[1] = 0x16;
1655 spec->autocfg.speaker_pins[2] = 0x17;
1656 spec->autocfg.speaker_pins[3] = 0x19;
1657 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001658}
1659
1660static void alc889_intel_init_hook(struct hda_codec *codec)
1661{
1662 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001663 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001664}
1665
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001666static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001667{
1668 struct alc_spec *spec = codec->spec;
1669
1670 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1671 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1672 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1673 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001674}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001675
1676/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001677 * ALC888 Acer Aspire 4930G model
1678 */
1679
1680static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1681/* Front Mic: set to PIN_IN (empty by default) */
1682 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1683/* Unselect Front Mic by default in input mixer 3 */
1684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001685/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001686 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1687/* Connect Internal HP to front */
1688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1691/* Connect HP out to front */
1692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1695 { }
1696};
1697
Hector Martin3b315d72009-06-02 10:54:19 +02001698/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001699 * ALC888 Acer Aspire 6530G model
1700 */
1701
1702static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001703/* Route to built-in subwoofer as well as speakers */
1704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1706 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1707 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001708/* Bias voltage on for external mic port */
1709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001710/* Front Mic: set to PIN_IN (empty by default) */
1711 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1712/* Unselect Front Mic by default in input mixer 3 */
1713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001714/* Enable unsolicited event for HP jack */
1715 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1716/* Enable speaker output */
1717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001719 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720/* Enable headphone output */
1721 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1722 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001724 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001725 { }
1726};
1727
1728/*
Hector Martin018df412009-06-04 00:13:40 +02001729 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001730 */
1731
Hector Martin018df412009-06-04 00:13:40 +02001732static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001733/* Front Mic: set to PIN_IN (empty by default) */
1734 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1735/* Unselect Front Mic by default in input mixer 3 */
1736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1737/* Enable unsolicited event for HP jack */
1738 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1739/* Connect Internal Front to Front */
1740 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1741 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1742 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1743/* Connect Internal Rear to Rear */
1744 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1745 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1747/* Connect Internal CLFE to CLFE */
1748 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1749 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1750 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1751/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001752 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001753 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1754 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1755/* Enable all DACs */
1756/* DAC DISABLE/MUTE 1? */
1757/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1758 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1759 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1760/* DAC DISABLE/MUTE 2? */
1761/* some bit here disables the other DACs. Init=0x4900 */
1762 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1763 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001764/* DMIC fix
1765 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1766 * which makes the stereo useless. However, either the mic or the ALC889
1767 * makes the signal become a difference/sum signal instead of standard
1768 * stereo, which is annoying. So instead we flip this bit which makes the
1769 * codec replicate the sum signal to both channels, turning it into a
1770 * normal mono mic.
1771 */
1772/* DMIC_CONTROL? Init value = 0x0001 */
1773 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1774 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001775 { }
1776};
1777
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001778static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001779 /* Front mic only available on one ADC */
1780 {
1781 .num_items = 4,
1782 .items = {
1783 { "Mic", 0x0 },
1784 { "Line", 0x2 },
1785 { "CD", 0x4 },
1786 { "Front Mic", 0xb },
1787 },
1788 },
1789 {
1790 .num_items = 3,
1791 .items = {
1792 { "Mic", 0x0 },
1793 { "Line", 0x2 },
1794 { "CD", 0x4 },
1795 },
1796 }
1797};
1798
Tony Vroond2fd4b02009-06-21 00:40:10 +01001799static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1800 /* Interal mic only available on one ADC */
1801 {
Tony Vroon684a8842009-06-26 09:27:50 +01001802 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001803 .items = {
1804 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001805 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001806 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001807 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001808 { "Int Mic", 0xb },
1809 },
1810 },
1811 {
Tony Vroon684a8842009-06-26 09:27:50 +01001812 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001813 .items = {
1814 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001815 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001816 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001817 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001818 },
1819 }
1820};
1821
Hector Martin018df412009-06-04 00:13:40 +02001822static struct hda_input_mux alc889_capture_sources[3] = {
1823 /* Digital mic only available on first "ADC" */
1824 {
1825 .num_items = 5,
1826 .items = {
1827 { "Mic", 0x0 },
1828 { "Line", 0x2 },
1829 { "CD", 0x4 },
1830 { "Front Mic", 0xb },
1831 { "Input Mix", 0xa },
1832 },
1833 },
1834 {
1835 .num_items = 4,
1836 .items = {
1837 { "Mic", 0x0 },
1838 { "Line", 0x2 },
1839 { "CD", 0x4 },
1840 { "Input Mix", 0xa },
1841 },
1842 },
1843 {
1844 .num_items = 4,
1845 .items = {
1846 { "Mic", 0x0 },
1847 { "Line", 0x2 },
1848 { "CD", 0x4 },
1849 { "Input Mix", 0xa },
1850 },
1851 }
1852};
1853
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001854static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001855 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1856 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1857 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1858 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1859 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1860 HDA_OUTPUT),
1861 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1862 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1863 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1864 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1865 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1866 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1867 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1868 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1869 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1871 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001873 { } /* end */
1874};
1875
Hector Martin556eea92009-12-20 22:51:23 +01001876static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1877 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1878 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1879 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1880 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1881 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1882 HDA_OUTPUT),
1883 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1884 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1885 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1886 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1887 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1889 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1891 { } /* end */
1892};
1893
1894
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001895static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001896{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001897 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001898
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001899 spec->autocfg.hp_pins[0] = 0x15;
1900 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001901 spec->autocfg.speaker_pins[1] = 0x16;
1902 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001903}
1904
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001905static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001906{
1907 struct alc_spec *spec = codec->spec;
1908
1909 spec->autocfg.hp_pins[0] = 0x15;
1910 spec->autocfg.speaker_pins[0] = 0x14;
1911 spec->autocfg.speaker_pins[1] = 0x16;
1912 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001913}
1914
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001915static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001916{
1917 struct alc_spec *spec = codec->spec;
1918
1919 spec->autocfg.hp_pins[0] = 0x15;
1920 spec->autocfg.speaker_pins[0] = 0x14;
1921 spec->autocfg.speaker_pins[1] = 0x16;
1922 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001923}
1924
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001925/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001926 * ALC880 3-stack model
1927 *
1928 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001929 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1930 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001931 */
1932
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001933static hda_nid_t alc880_dac_nids[4] = {
1934 /* front, rear, clfe, rear_surr */
1935 0x02, 0x05, 0x04, 0x03
1936};
1937
1938static hda_nid_t alc880_adc_nids[3] = {
1939 /* ADC0-2 */
1940 0x07, 0x08, 0x09,
1941};
1942
1943/* The datasheet says the node 0x07 is connected from inputs,
1944 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001945 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001946 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001947static hda_nid_t alc880_adc_nids_alt[2] = {
1948 /* ADC1-2 */
1949 0x08, 0x09,
1950};
1951
1952#define ALC880_DIGOUT_NID 0x06
1953#define ALC880_DIGIN_NID 0x0a
1954
1955static struct hda_input_mux alc880_capture_source = {
1956 .num_items = 4,
1957 .items = {
1958 { "Mic", 0x0 },
1959 { "Front Mic", 0x3 },
1960 { "Line", 0x2 },
1961 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001963};
1964
1965/* channel source setting (2/6 channel selection for 3-stack) */
1966/* 2ch mode */
1967static struct hda_verb alc880_threestack_ch2_init[] = {
1968 /* set line-in to input, mute it */
1969 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1970 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1971 /* set mic-in to input vref 80%, mute it */
1972 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1973 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001974 { } /* end */
1975};
1976
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001977/* 6ch mode */
1978static struct hda_verb alc880_threestack_ch6_init[] = {
1979 /* set line-in to output, unmute it */
1980 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1981 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1982 /* set mic-in to output, unmute it */
1983 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1984 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1985 { } /* end */
1986};
1987
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001988static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001989 { 2, alc880_threestack_ch2_init },
1990 { 6, alc880_threestack_ch6_init },
1991};
1992
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001993static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001994 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001995 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001996 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001997 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001998 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1999 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002000 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2001 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2003 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2004 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2005 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2008 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2009 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002011 {
2012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2013 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002014 .info = alc_ch_mode_info,
2015 .get = alc_ch_mode_get,
2016 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002017 },
2018 { } /* end */
2019};
2020
2021/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002022static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2023 struct snd_ctl_elem_info *uinfo)
2024{
2025 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2026 struct alc_spec *spec = codec->spec;
2027 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002028
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002029 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002030 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2031 HDA_INPUT);
2032 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002033 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002034 return err;
2035}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002037static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2038 unsigned int size, unsigned int __user *tlv)
2039{
2040 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2041 struct alc_spec *spec = codec->spec;
2042 int err;
2043
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002044 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002045 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2046 HDA_INPUT);
2047 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002048 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002049 return err;
2050}
2051
2052typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2053 struct snd_ctl_elem_value *ucontrol);
2054
2055static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2056 struct snd_ctl_elem_value *ucontrol,
2057 getput_call_t func)
2058{
2059 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2060 struct alc_spec *spec = codec->spec;
2061 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2062 int err;
2063
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002064 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002065 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2066 3, 0, HDA_INPUT);
2067 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002068 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002069 return err;
2070}
2071
2072static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2073 struct snd_ctl_elem_value *ucontrol)
2074{
2075 return alc_cap_getput_caller(kcontrol, ucontrol,
2076 snd_hda_mixer_amp_volume_get);
2077}
2078
2079static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2080 struct snd_ctl_elem_value *ucontrol)
2081{
2082 return alc_cap_getput_caller(kcontrol, ucontrol,
2083 snd_hda_mixer_amp_volume_put);
2084}
2085
2086/* capture mixer elements */
2087#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2088
2089static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2090 struct snd_ctl_elem_value *ucontrol)
2091{
2092 return alc_cap_getput_caller(kcontrol, ucontrol,
2093 snd_hda_mixer_amp_switch_get);
2094}
2095
2096static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2097 struct snd_ctl_elem_value *ucontrol)
2098{
2099 return alc_cap_getput_caller(kcontrol, ucontrol,
2100 snd_hda_mixer_amp_switch_put);
2101}
2102
Takashi Iwaia23b6882009-03-23 15:21:36 +01002103#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002104 { \
2105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2106 .name = "Capture Switch", \
2107 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2108 .count = num, \
2109 .info = alc_cap_sw_info, \
2110 .get = alc_cap_sw_get, \
2111 .put = alc_cap_sw_put, \
2112 }, \
2113 { \
2114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2115 .name = "Capture Volume", \
2116 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2117 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2118 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2119 .count = num, \
2120 .info = alc_cap_vol_info, \
2121 .get = alc_cap_vol_get, \
2122 .put = alc_cap_vol_put, \
2123 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002124 }
2125
2126#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002127 { \
2128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2129 /* .name = "Capture Source", */ \
2130 .name = "Input Source", \
2131 .count = num, \
2132 .info = alc_mux_enum_info, \
2133 .get = alc_mux_enum_get, \
2134 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002135 }
2136
2137#define DEFINE_CAPMIX(num) \
2138static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2139 _DEFINE_CAPMIX(num), \
2140 _DEFINE_CAPSRC(num), \
2141 { } /* end */ \
2142}
2143
2144#define DEFINE_CAPMIX_NOSRC(num) \
2145static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2146 _DEFINE_CAPMIX(num), \
2147 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002148}
2149
2150/* up to three ADCs */
2151DEFINE_CAPMIX(1);
2152DEFINE_CAPMIX(2);
2153DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002154DEFINE_CAPMIX_NOSRC(1);
2155DEFINE_CAPMIX_NOSRC(2);
2156DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002157
2158/*
2159 * ALC880 5-stack model
2160 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002161 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2162 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002163 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2164 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2165 */
2166
2167/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002168static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002170 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171 { } /* end */
2172};
2173
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002174/* channel source setting (6/8 channel selection for 5-stack) */
2175/* 6ch mode */
2176static struct hda_verb alc880_fivestack_ch6_init[] = {
2177 /* set line-in to input, mute it */
2178 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2179 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002180 { } /* end */
2181};
2182
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183/* 8ch mode */
2184static struct hda_verb alc880_fivestack_ch8_init[] = {
2185 /* set line-in to output, unmute it */
2186 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2187 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2188 { } /* end */
2189};
2190
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002191static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002192 { 6, alc880_fivestack_ch6_init },
2193 { 8, alc880_fivestack_ch8_init },
2194};
2195
2196
2197/*
2198 * ALC880 6-stack model
2199 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002200 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2201 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002202 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2203 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2204 */
2205
2206static hda_nid_t alc880_6st_dac_nids[4] = {
2207 /* front, rear, clfe, rear_surr */
2208 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002209};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210
2211static struct hda_input_mux alc880_6stack_capture_source = {
2212 .num_items = 4,
2213 .items = {
2214 { "Mic", 0x0 },
2215 { "Front Mic", 0x1 },
2216 { "Line", 0x2 },
2217 { "CD", 0x4 },
2218 },
2219};
2220
2221/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002222static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223 { 8, NULL },
2224};
2225
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002226static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002228 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002229 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002230 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002231 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2232 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002233 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2234 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002235 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002236 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002237 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2238 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2239 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2240 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2243 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002245 {
2246 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2247 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002248 .info = alc_ch_mode_info,
2249 .get = alc_ch_mode_get,
2250 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002251 },
2252 { } /* end */
2253};
2254
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255
2256/*
2257 * ALC880 W810 model
2258 *
2259 * W810 has rear IO for:
2260 * Front (DAC 02)
2261 * Surround (DAC 03)
2262 * Center/LFE (DAC 04)
2263 * Digital out (06)
2264 *
2265 * The system also has a pair of internal speakers, and a headphone jack.
2266 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002267 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002268 * There is a variable resistor to control the speaker or headphone
2269 * volume. This is a hardware-only device without a software API.
2270 *
2271 * Plugging headphones in will disable the internal speakers. This is
2272 * implemented in hardware, not via the driver using jack sense. In
2273 * a similar fashion, plugging into the rear socket marked "front" will
2274 * disable both the speakers and headphones.
2275 *
2276 * For input, there's a microphone jack, and an "audio in" jack.
2277 * These may not do anything useful with this driver yet, because I
2278 * haven't setup any initialization verbs for these yet...
2279 */
2280
2281static hda_nid_t alc880_w810_dac_nids[3] = {
2282 /* front, rear/surround, clfe */
2283 0x02, 0x03, 0x04
2284};
2285
2286/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002287static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002288 { 6, NULL }
2289};
2290
2291/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002292static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002293 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002294 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002295 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002296 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002297 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2298 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002299 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2300 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002301 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2302 { } /* end */
2303};
2304
2305
2306/*
2307 * Z710V model
2308 *
2309 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002310 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2311 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002312 */
2313
2314static hda_nid_t alc880_z71v_dac_nids[1] = {
2315 0x02
2316};
2317#define ALC880_Z71V_HP_DAC 0x03
2318
2319/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002320static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002321 { 2, NULL }
2322};
2323
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002324static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002325 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002326 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002327 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002328 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002329 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2330 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2333 { } /* end */
2334};
2335
2336
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002337/*
2338 * ALC880 F1734 model
2339 *
2340 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2341 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2342 */
2343
2344static hda_nid_t alc880_f1734_dac_nids[1] = {
2345 0x03
2346};
2347#define ALC880_F1734_HP_DAC 0x02
2348
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002349static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002350 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002351 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002352 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2353 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002356 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2357 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002358 { } /* end */
2359};
2360
Takashi Iwai937b4162008-02-11 14:52:36 +01002361static struct hda_input_mux alc880_f1734_capture_source = {
2362 .num_items = 2,
2363 .items = {
2364 { "Mic", 0x1 },
2365 { "CD", 0x4 },
2366 },
2367};
2368
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002369
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002370/*
2371 * ALC880 ASUS model
2372 *
2373 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2374 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2375 * Mic = 0x18, Line = 0x1a
2376 */
2377
2378#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2379#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2380
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002381static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002382 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002383 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002384 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002385 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002386 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2387 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002388 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2389 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002390 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2391 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2392 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2393 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002396 {
2397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2398 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002399 .info = alc_ch_mode_info,
2400 .get = alc_ch_mode_get,
2401 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002402 },
2403 { } /* end */
2404};
2405
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002406/*
2407 * ALC880 ASUS W1V model
2408 *
2409 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2410 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2411 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2412 */
2413
2414/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002415static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002416 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2417 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002418 { } /* end */
2419};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002420
Kailang Yangdf694da2005-12-05 19:42:22 +01002421/* TCL S700 */
2422static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2423 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2424 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2427 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2430 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2431 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002432 { } /* end */
2433};
2434
Kailang Yangccc656c2006-10-17 12:32:26 +02002435/* Uniwill */
2436static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002437 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2438 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2439 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2440 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002441 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2442 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2443 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2444 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2447 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2448 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2450 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2451 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2452 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002453 {
2454 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2455 .name = "Channel Mode",
2456 .info = alc_ch_mode_info,
2457 .get = alc_ch_mode_get,
2458 .put = alc_ch_mode_put,
2459 },
2460 { } /* end */
2461};
2462
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002463static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2464 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2465 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2466 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2467 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2468 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2469 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2470 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2471 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2472 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2473 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2474 { } /* end */
2475};
2476
Kailang Yangccc656c2006-10-17 12:32:26 +02002477static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002478 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2479 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2480 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2481 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002482 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2483 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2484 { } /* end */
2485};
2486
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002488 * virtual master controls
2489 */
2490
2491/*
2492 * slave controls for virtual master
2493 */
2494static const char *alc_slave_vols[] = {
2495 "Front Playback Volume",
2496 "Surround Playback Volume",
2497 "Center Playback Volume",
2498 "LFE Playback Volume",
2499 "Side Playback Volume",
2500 "Headphone Playback Volume",
2501 "Speaker Playback Volume",
2502 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002503 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002504 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002505 NULL,
2506};
2507
2508static const char *alc_slave_sws[] = {
2509 "Front Playback Switch",
2510 "Surround Playback Switch",
2511 "Center Playback Switch",
2512 "LFE Playback Switch",
2513 "Side Playback Switch",
2514 "Headphone Playback Switch",
2515 "Speaker Playback Switch",
2516 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002517 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002518 "Line-Out Playback Switch",
2519 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002520 NULL,
2521};
2522
2523/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002524 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002526
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002527#define NID_MAPPING (-1)
2528
2529#define SUBDEV_SPEAKER_ (0 << 6)
2530#define SUBDEV_HP_ (1 << 6)
2531#define SUBDEV_LINE_ (2 << 6)
2532#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2533#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2534#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2535
Takashi Iwai603c4012008-07-30 15:01:44 +02002536static void alc_free_kctls(struct hda_codec *codec);
2537
Takashi Iwai67d634c2009-11-16 15:35:59 +01002538#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002539/* additional beep mixers; the actual parameters are overwritten at build */
2540static struct snd_kcontrol_new alc_beep_mixer[] = {
2541 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002542 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002543 { } /* end */
2544};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002545#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002546
Linus Torvalds1da177e2005-04-16 15:20:36 -07002547static int alc_build_controls(struct hda_codec *codec)
2548{
2549 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002550 struct snd_kcontrol *kctl;
2551 struct snd_kcontrol_new *knew;
2552 int i, j, err;
2553 unsigned int u;
2554 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555
2556 for (i = 0; i < spec->num_mixers; i++) {
2557 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2558 if (err < 0)
2559 return err;
2560 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002561 if (spec->cap_mixer) {
2562 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2563 if (err < 0)
2564 return err;
2565 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002566 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002567 err = snd_hda_create_spdif_out_ctls(codec,
2568 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569 if (err < 0)
2570 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002571 if (!spec->no_analog) {
2572 err = snd_hda_create_spdif_share_sw(codec,
2573 &spec->multiout);
2574 if (err < 0)
2575 return err;
2576 spec->multiout.share_spdif = 1;
2577 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002578 }
2579 if (spec->dig_in_nid) {
2580 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2581 if (err < 0)
2582 return err;
2583 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002584
Takashi Iwai67d634c2009-11-16 15:35:59 +01002585#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002586 /* create beep controls if needed */
2587 if (spec->beep_amp) {
2588 struct snd_kcontrol_new *knew;
2589 for (knew = alc_beep_mixer; knew->name; knew++) {
2590 struct snd_kcontrol *kctl;
2591 kctl = snd_ctl_new1(knew, codec);
2592 if (!kctl)
2593 return -ENOMEM;
2594 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002595 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002596 if (err < 0)
2597 return err;
2598 }
2599 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002600#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002601
Takashi Iwai2134ea42008-01-10 16:53:55 +01002602 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002603 if (!spec->no_analog &&
2604 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002605 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002606 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002607 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002608 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002609 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002610 if (err < 0)
2611 return err;
2612 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002613 if (!spec->no_analog &&
2614 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002615 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2616 NULL, alc_slave_sws);
2617 if (err < 0)
2618 return err;
2619 }
2620
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002621 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002622 if (spec->capsrc_nids || spec->adc_nids) {
2623 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2624 if (!kctl)
2625 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2626 for (i = 0; kctl && i < kctl->count; i++) {
2627 hda_nid_t *nids = spec->capsrc_nids;
2628 if (!nids)
2629 nids = spec->adc_nids;
2630 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2631 if (err < 0)
2632 return err;
2633 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002634 }
2635 if (spec->cap_mixer) {
2636 const char *kname = kctl ? kctl->id.name : NULL;
2637 for (knew = spec->cap_mixer; knew->name; knew++) {
2638 if (kname && strcmp(knew->name, kname) == 0)
2639 continue;
2640 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2641 for (i = 0; kctl && i < kctl->count; i++) {
2642 err = snd_hda_add_nid(codec, kctl, i,
2643 spec->adc_nids[i]);
2644 if (err < 0)
2645 return err;
2646 }
2647 }
2648 }
2649
2650 /* other nid->control mapping */
2651 for (i = 0; i < spec->num_mixers; i++) {
2652 for (knew = spec->mixers[i]; knew->name; knew++) {
2653 if (knew->iface != NID_MAPPING)
2654 continue;
2655 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2656 if (kctl == NULL)
2657 continue;
2658 u = knew->subdevice;
2659 for (j = 0; j < 4; j++, u >>= 8) {
2660 nid = u & 0x3f;
2661 if (nid == 0)
2662 continue;
2663 switch (u & 0xc0) {
2664 case SUBDEV_SPEAKER_:
2665 nid = spec->autocfg.speaker_pins[nid];
2666 break;
2667 case SUBDEV_LINE_:
2668 nid = spec->autocfg.line_out_pins[nid];
2669 break;
2670 case SUBDEV_HP_:
2671 nid = spec->autocfg.hp_pins[nid];
2672 break;
2673 default:
2674 continue;
2675 }
2676 err = snd_hda_add_nid(codec, kctl, 0, nid);
2677 if (err < 0)
2678 return err;
2679 }
2680 u = knew->private_value;
2681 for (j = 0; j < 4; j++, u >>= 8) {
2682 nid = u & 0xff;
2683 if (nid == 0)
2684 continue;
2685 err = snd_hda_add_nid(codec, kctl, 0, nid);
2686 if (err < 0)
2687 return err;
2688 }
2689 }
2690 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002691
2692 alc_free_kctls(codec); /* no longer needed */
2693
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694 return 0;
2695}
2696
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002697
Linus Torvalds1da177e2005-04-16 15:20:36 -07002698/*
2699 * initialize the codec volumes, etc
2700 */
2701
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702/*
2703 * generic initialization of ADC, input mixers and output mixers
2704 */
2705static struct hda_verb alc880_volume_init_verbs[] = {
2706 /*
2707 * Unmute ADC0-2 and set the default input to mic-in
2708 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002709 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002711 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002713 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002714 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002716 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2717 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002718 * Note: PASD motherboards uses the Line In 2 as the input for front
2719 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002720 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002721 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002729
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730 /*
2731 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002732 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002733 /* set vol=0 to output mixers */
2734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2737 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2738 /* set up input amps for analog loopback */
2739 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002746 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2747 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002748
2749 { }
2750};
2751
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002752/*
2753 * 3-stack pin configuration:
2754 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2755 */
2756static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2757 /*
2758 * preset connection lists of input pins
2759 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2760 */
2761 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2762 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2763 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2764
2765 /*
2766 * Set pin mode and muting
2767 */
2768 /* set front pin widgets 0x14 for output */
2769 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2770 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2771 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2772 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2773 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2774 /* Mic2 (as headphone out) for HP output */
2775 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2777 /* Line In pin widget for input */
2778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2780 /* Line2 (as front mic) pin widget for input and vref at 80% */
2781 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2782 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2783 /* CD pin widget for input */
2784 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2785
2786 { }
2787};
2788
2789/*
2790 * 5-stack pin configuration:
2791 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2792 * line-in/side = 0x1a, f-mic = 0x1b
2793 */
2794static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2795 /*
2796 * preset connection lists of input pins
2797 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2798 */
2799 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2800 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2801
2802 /*
2803 * Set pin mode and muting
2804 */
2805 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2808 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2809 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002810 /* unmute pins for output (no gain on this amp) */
2811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2813 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2814 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2815
Linus Torvalds1da177e2005-04-16 15:20:36 -07002816 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002817 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002818 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2819 /* Mic2 (as headphone out) for HP output */
2820 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002821 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002822 /* Line In pin widget for input */
2823 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2824 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2825 /* Line2 (as front mic) pin widget for input and vref at 80% */
2826 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2827 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2828 /* CD pin widget for input */
2829 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002830
2831 { }
2832};
2833
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002834/*
2835 * W810 pin configuration:
2836 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2837 */
2838static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002839 /* hphone/speaker input selector: front DAC */
2840 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2841
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002842 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2843 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2846 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2847 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848
2849 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002850 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002851
Linus Torvalds1da177e2005-04-16 15:20:36 -07002852 { }
2853};
2854
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002855/*
2856 * Z71V pin configuration:
2857 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2858 */
2859static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002864
Takashi Iwai16ded522005-06-10 19:58:24 +02002865 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002866 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002868 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002869
2870 { }
2871};
2872
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002873/*
2874 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002875 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2876 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002877 */
2878static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2879 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2880
Takashi Iwai16ded522005-06-10 19:58:24 +02002881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002885 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002887 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002888 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2889
Takashi Iwai16ded522005-06-10 19:58:24 +02002890 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002891 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002892 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002894 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002896 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002897 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002898 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002899
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002900 { }
2901};
Takashi Iwai16ded522005-06-10 19:58:24 +02002902
Kailang Yangccc656c2006-10-17 12:32:26 +02002903/*
2904 * Uniwill pin configuration:
2905 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2906 * line = 0x1a
2907 */
2908static struct hda_verb alc880_uniwill_init_verbs[] = {
2909 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2910
2911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2913 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2916 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2918 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2925
2926 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2928 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2929 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2930 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2931 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2932 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2933 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2934 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2935
2936 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2937 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2938
2939 { }
2940};
2941
2942/*
2943* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002944* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002945 */
2946static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2947 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2948
2949 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2950 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2951 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2952 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2953 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2954 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2957 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2958 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2959 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2960 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2961
2962 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2963 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2964 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2965 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2966 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2967 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2968
2969 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2970 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2971
2972 { }
2973};
2974
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002975static struct hda_verb alc880_beep_init_verbs[] = {
2976 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2977 { }
2978};
2979
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002980/* auto-toggle front mic */
2981static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2982{
2983 unsigned int present;
2984 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002985
Wu Fengguang864f92b2009-11-18 12:38:02 +08002986 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002987 bits = present ? HDA_AMP_MUTE : 0;
2988 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002989}
2990
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002991static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002992{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002993 struct alc_spec *spec = codec->spec;
2994
2995 spec->autocfg.hp_pins[0] = 0x14;
2996 spec->autocfg.speaker_pins[0] = 0x15;
2997 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002998}
2999
3000static void alc880_uniwill_init_hook(struct hda_codec *codec)
3001{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003002 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003003 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003004}
3005
3006static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3007 unsigned int res)
3008{
3009 /* Looks like the unsol event is incompatible with the standard
3010 * definition. 4bit tag is placed at 28 bit!
3011 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003012 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003013 case ALC880_MIC_EVENT:
3014 alc880_uniwill_mic_automute(codec);
3015 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003016 default:
3017 alc_automute_amp_unsol_event(codec, res);
3018 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003019 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003020}
3021
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003022static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003023{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003024 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003025
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003026 spec->autocfg.hp_pins[0] = 0x14;
3027 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003028}
3029
3030static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3031{
3032 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003033
Kailang Yangccc656c2006-10-17 12:32:26 +02003034 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003035 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3036 present &= HDA_AMP_VOLMASK;
3037 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3038 HDA_AMP_VOLMASK, present);
3039 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3040 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003041}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003042
Kailang Yangccc656c2006-10-17 12:32:26 +02003043static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3044 unsigned int res)
3045{
3046 /* Looks like the unsol event is incompatible with the standard
3047 * definition. 4bit tag is placed at 28 bit!
3048 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003049 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003050 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003051 else
3052 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003053}
3054
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003055/*
3056 * F1734 pin configuration:
3057 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3058 */
3059static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003060 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003061 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3062 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3063 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3064 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3065
3066 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3067 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3068 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3070
3071 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3072 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003073 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3075 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3076 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3077 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3078 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3079 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003080
Takashi Iwai937b4162008-02-11 14:52:36 +01003081 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3082 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3083
Takashi Iwai16ded522005-06-10 19:58:24 +02003084 { }
3085};
3086
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003087/*
3088 * ASUS pin configuration:
3089 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3090 */
3091static struct hda_verb alc880_pin_asus_init_verbs[] = {
3092 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3093 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3094 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3095 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3096
3097 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3098 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3099 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3100 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3101 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3102 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3103 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3105
3106 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3107 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3108 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3109 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3110 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3111 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3112 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3113 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3114 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003115
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116 { }
3117};
3118
3119/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003120#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3121#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003122#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003123
Kailang Yangdf694da2005-12-05 19:42:22 +01003124/* Clevo m520g init */
3125static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3126 /* headphone output */
3127 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3128 /* line-out */
3129 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3130 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3131 /* Line-in */
3132 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3133 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3134 /* CD */
3135 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3136 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3137 /* Mic1 (rear panel) */
3138 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3139 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3140 /* Mic2 (front panel) */
3141 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3142 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3143 /* headphone */
3144 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3145 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3146 /* change to EAPD mode */
3147 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3148 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3149
3150 { }
3151};
3152
3153static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003154 /* change to EAPD mode */
3155 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3156 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3157
Kailang Yangdf694da2005-12-05 19:42:22 +01003158 /* Headphone output */
3159 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3160 /* Front output*/
3161 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3162 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3163
3164 /* Line In pin widget for input */
3165 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3166 /* CD pin widget for input */
3167 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3168 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3170
3171 /* change to EAPD mode */
3172 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3173 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3174
3175 { }
3176};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177
3178/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003179 * LG m1 express dual
3180 *
3181 * Pin assignment:
3182 * Rear Line-In/Out (blue): 0x14
3183 * Build-in Mic-In: 0x15
3184 * Speaker-out: 0x17
3185 * HP-Out (green): 0x1b
3186 * Mic-In/Out (red): 0x19
3187 * SPDIF-Out: 0x1e
3188 */
3189
3190/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3191static hda_nid_t alc880_lg_dac_nids[3] = {
3192 0x05, 0x02, 0x03
3193};
3194
3195/* seems analog CD is not working */
3196static struct hda_input_mux alc880_lg_capture_source = {
3197 .num_items = 3,
3198 .items = {
3199 { "Mic", 0x1 },
3200 { "Line", 0x5 },
3201 { "Internal Mic", 0x6 },
3202 },
3203};
3204
3205/* 2,4,6 channel modes */
3206static struct hda_verb alc880_lg_ch2_init[] = {
3207 /* set line-in and mic-in to input */
3208 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3209 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3210 { }
3211};
3212
3213static struct hda_verb alc880_lg_ch4_init[] = {
3214 /* set line-in to out and mic-in to input */
3215 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3216 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3217 { }
3218};
3219
3220static struct hda_verb alc880_lg_ch6_init[] = {
3221 /* set line-in and mic-in to output */
3222 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3223 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3224 { }
3225};
3226
3227static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3228 { 2, alc880_lg_ch2_init },
3229 { 4, alc880_lg_ch4_init },
3230 { 6, alc880_lg_ch6_init },
3231};
3232
3233static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003234 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3235 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003236 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3237 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3238 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3239 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3240 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3241 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3244 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3245 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3246 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3247 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3248 {
3249 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3250 .name = "Channel Mode",
3251 .info = alc_ch_mode_info,
3252 .get = alc_ch_mode_get,
3253 .put = alc_ch_mode_put,
3254 },
3255 { } /* end */
3256};
3257
3258static struct hda_verb alc880_lg_init_verbs[] = {
3259 /* set capture source to mic-in */
3260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3261 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3262 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3263 /* mute all amp mixer inputs */
3264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003267 /* line-in to input */
3268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3270 /* built-in mic */
3271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3272 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3273 /* speaker-out */
3274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3276 /* mic-in to input */
3277 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3278 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3279 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3280 /* HP-out */
3281 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3284 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003285 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003286 { }
3287};
3288
3289/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003290static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003291{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003292 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003293
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003294 spec->autocfg.hp_pins[0] = 0x1b;
3295 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003296}
3297
3298/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003299 * LG LW20
3300 *
3301 * Pin assignment:
3302 * Speaker-out: 0x14
3303 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003304 * Built-in Mic-In: 0x19
3305 * Line-In: 0x1b
3306 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003307 * SPDIF-Out: 0x1e
3308 */
3309
Takashi Iwaid6815182006-03-23 16:06:23 +01003310static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003311 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003312 .items = {
3313 { "Mic", 0x0 },
3314 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003315 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003316 },
3317};
3318
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003319#define alc880_lg_lw_modes alc880_threestack_modes
3320
Takashi Iwaid6815182006-03-23 16:06:23 +01003321static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003322 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3323 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3324 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3325 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3326 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3327 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3328 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3329 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3330 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3331 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003332 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3333 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3334 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3335 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003336 {
3337 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3338 .name = "Channel Mode",
3339 .info = alc_ch_mode_info,
3340 .get = alc_ch_mode_get,
3341 .put = alc_ch_mode_put,
3342 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003343 { } /* end */
3344};
3345
3346static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003347 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3348 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3349 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3350
Takashi Iwaid6815182006-03-23 16:06:23 +01003351 /* set capture source to mic-in */
3352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3353 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3354 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003355 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003356 /* speaker-out */
3357 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3358 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3359 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003360 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3361 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3362 /* mic-in to input */
3363 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3364 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3365 /* built-in mic */
3366 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3367 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3368 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003369 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003370 { }
3371};
3372
3373/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003374static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003375{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003376 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003377
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003378 spec->autocfg.hp_pins[0] = 0x1b;
3379 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003380}
3381
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003382static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3383 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3384 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3385 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3386 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3387 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3388 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3389 { } /* end */
3390};
3391
3392static struct hda_input_mux alc880_medion_rim_capture_source = {
3393 .num_items = 2,
3394 .items = {
3395 { "Mic", 0x0 },
3396 { "Internal Mic", 0x1 },
3397 },
3398};
3399
3400static struct hda_verb alc880_medion_rim_init_verbs[] = {
3401 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3402
3403 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3404 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3405
3406 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3407 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3408 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3409 /* Mic2 (as headphone out) for HP output */
3410 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3411 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3412 /* Internal Speaker */
3413 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3414 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3415
3416 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3417 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3418
3419 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3420 { }
3421};
3422
3423/* toggle speaker-output according to the hp-jack state */
3424static void alc880_medion_rim_automute(struct hda_codec *codec)
3425{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003426 struct alc_spec *spec = codec->spec;
3427 alc_automute_amp(codec);
3428 /* toggle EAPD */
3429 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003430 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3431 else
3432 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3433}
3434
3435static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3436 unsigned int res)
3437{
3438 /* Looks like the unsol event is incompatible with the standard
3439 * definition. 4bit tag is placed at 28 bit!
3440 */
3441 if ((res >> 28) == ALC880_HP_EVENT)
3442 alc880_medion_rim_automute(codec);
3443}
3444
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003445static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003446{
3447 struct alc_spec *spec = codec->spec;
3448
3449 spec->autocfg.hp_pins[0] = 0x14;
3450 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003451}
3452
Takashi Iwaicb53c622007-08-10 17:21:45 +02003453#ifdef CONFIG_SND_HDA_POWER_SAVE
3454static struct hda_amp_list alc880_loopbacks[] = {
3455 { 0x0b, HDA_INPUT, 0 },
3456 { 0x0b, HDA_INPUT, 1 },
3457 { 0x0b, HDA_INPUT, 2 },
3458 { 0x0b, HDA_INPUT, 3 },
3459 { 0x0b, HDA_INPUT, 4 },
3460 { } /* end */
3461};
3462
3463static struct hda_amp_list alc880_lg_loopbacks[] = {
3464 { 0x0b, HDA_INPUT, 1 },
3465 { 0x0b, HDA_INPUT, 6 },
3466 { 0x0b, HDA_INPUT, 7 },
3467 { } /* end */
3468};
3469#endif
3470
Takashi Iwaid6815182006-03-23 16:06:23 +01003471/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003472 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003473 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003474
Linus Torvalds1da177e2005-04-16 15:20:36 -07003475static int alc_init(struct hda_codec *codec)
3476{
3477 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003478 unsigned int i;
3479
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003480 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003481 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003482
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003483 for (i = 0; i < spec->num_init_verbs; i++)
3484 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003485
3486 if (spec->init_hook)
3487 spec->init_hook(codec);
3488
Takashi Iwaiad358792010-03-30 18:00:59 +02003489#ifdef CONFIG_SND_HDA_POWER_SAVE
3490 if (codec->patch_ops.check_power_status)
3491 codec->patch_ops.check_power_status(codec, 0x01);
3492#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003493 return 0;
3494}
3495
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003496static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3497{
3498 struct alc_spec *spec = codec->spec;
3499
3500 if (spec->unsol_event)
3501 spec->unsol_event(codec, res);
3502}
3503
Takashi Iwaicb53c622007-08-10 17:21:45 +02003504#ifdef CONFIG_SND_HDA_POWER_SAVE
3505static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3506{
3507 struct alc_spec *spec = codec->spec;
3508 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3509}
3510#endif
3511
Linus Torvalds1da177e2005-04-16 15:20:36 -07003512/*
3513 * Analog playback callbacks
3514 */
3515static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3516 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003517 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003518{
3519 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003520 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3521 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003522}
3523
3524static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3525 struct hda_codec *codec,
3526 unsigned int stream_tag,
3527 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003528 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003529{
3530 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003531 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3532 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003533}
3534
3535static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3536 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003537 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003538{
3539 struct alc_spec *spec = codec->spec;
3540 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3541}
3542
3543/*
3544 * Digital out
3545 */
3546static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3547 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003548 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003549{
3550 struct alc_spec *spec = codec->spec;
3551 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3552}
3553
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003554static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3555 struct hda_codec *codec,
3556 unsigned int stream_tag,
3557 unsigned int format,
3558 struct snd_pcm_substream *substream)
3559{
3560 struct alc_spec *spec = codec->spec;
3561 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3562 stream_tag, format, substream);
3563}
3564
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003565static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3566 struct hda_codec *codec,
3567 struct snd_pcm_substream *substream)
3568{
3569 struct alc_spec *spec = codec->spec;
3570 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3571}
3572
Linus Torvalds1da177e2005-04-16 15:20:36 -07003573static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3574 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003575 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003576{
3577 struct alc_spec *spec = codec->spec;
3578 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3579}
3580
3581/*
3582 * Analog capture
3583 */
Takashi Iwai63300792008-01-24 15:31:36 +01003584static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003585 struct hda_codec *codec,
3586 unsigned int stream_tag,
3587 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003588 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003589{
3590 struct alc_spec *spec = codec->spec;
3591
Takashi Iwai63300792008-01-24 15:31:36 +01003592 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003593 stream_tag, 0, format);
3594 return 0;
3595}
3596
Takashi Iwai63300792008-01-24 15:31:36 +01003597static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003598 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003599 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003600{
3601 struct alc_spec *spec = codec->spec;
3602
Takashi Iwai888afa12008-03-18 09:57:50 +01003603 snd_hda_codec_cleanup_stream(codec,
3604 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003605 return 0;
3606}
3607
3608
3609/*
3610 */
3611static struct hda_pcm_stream alc880_pcm_analog_playback = {
3612 .substreams = 1,
3613 .channels_min = 2,
3614 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003615 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003616 .ops = {
3617 .open = alc880_playback_pcm_open,
3618 .prepare = alc880_playback_pcm_prepare,
3619 .cleanup = alc880_playback_pcm_cleanup
3620 },
3621};
3622
3623static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003624 .substreams = 1,
3625 .channels_min = 2,
3626 .channels_max = 2,
3627 /* NID is set in alc_build_pcms */
3628};
3629
3630static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3631 .substreams = 1,
3632 .channels_min = 2,
3633 .channels_max = 2,
3634 /* NID is set in alc_build_pcms */
3635};
3636
3637static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3638 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003639 .channels_min = 2,
3640 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003641 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003642 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003643 .prepare = alc880_alt_capture_pcm_prepare,
3644 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003645 },
3646};
3647
3648static struct hda_pcm_stream alc880_pcm_digital_playback = {
3649 .substreams = 1,
3650 .channels_min = 2,
3651 .channels_max = 2,
3652 /* NID is set in alc_build_pcms */
3653 .ops = {
3654 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003655 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003656 .prepare = alc880_dig_playback_pcm_prepare,
3657 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003658 },
3659};
3660
3661static struct hda_pcm_stream alc880_pcm_digital_capture = {
3662 .substreams = 1,
3663 .channels_min = 2,
3664 .channels_max = 2,
3665 /* NID is set in alc_build_pcms */
3666};
3667
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003668/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003669static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003670 .substreams = 0,
3671 .channels_min = 0,
3672 .channels_max = 0,
3673};
3674
Linus Torvalds1da177e2005-04-16 15:20:36 -07003675static int alc_build_pcms(struct hda_codec *codec)
3676{
3677 struct alc_spec *spec = codec->spec;
3678 struct hda_pcm *info = spec->pcm_rec;
3679 int i;
3680
3681 codec->num_pcms = 1;
3682 codec->pcm_info = info;
3683
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003684 if (spec->no_analog)
3685 goto skip_analog;
3686
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003687 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3688 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003689 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003690
Takashi Iwai4a471b72005-12-07 13:56:29 +01003691 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003692 if (snd_BUG_ON(!spec->multiout.dac_nids))
3693 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003694 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3695 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3696 }
3697 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003698 if (snd_BUG_ON(!spec->adc_nids))
3699 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003700 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3701 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3702 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003703
Takashi Iwai4a471b72005-12-07 13:56:29 +01003704 if (spec->channel_mode) {
3705 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3706 for (i = 0; i < spec->num_channel_mode; i++) {
3707 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3708 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3709 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003710 }
3711 }
3712
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003713 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003714 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003715 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003716 snprintf(spec->stream_name_digital,
3717 sizeof(spec->stream_name_digital),
3718 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003719 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003720 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003721 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003722 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003723 if (spec->dig_out_type)
3724 info->pcm_type = spec->dig_out_type;
3725 else
3726 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003727 if (spec->multiout.dig_out_nid &&
3728 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003729 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3730 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3731 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003732 if (spec->dig_in_nid &&
3733 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003734 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3735 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3736 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003737 /* FIXME: do we need this for all Realtek codec models? */
3738 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003739 }
3740
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003741 if (spec->no_analog)
3742 return 0;
3743
Takashi Iwaie08a0072006-09-07 17:52:14 +02003744 /* If the use of more than one ADC is requested for the current
3745 * model, configure a second analog capture-only PCM.
3746 */
3747 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003748 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3749 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003750 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003751 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003752 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003753 if (spec->alt_dac_nid) {
3754 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3755 *spec->stream_analog_alt_playback;
3756 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3757 spec->alt_dac_nid;
3758 } else {
3759 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3760 alc_pcm_null_stream;
3761 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3762 }
3763 if (spec->num_adc_nids > 1) {
3764 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3765 *spec->stream_analog_alt_capture;
3766 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3767 spec->adc_nids[1];
3768 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3769 spec->num_adc_nids - 1;
3770 } else {
3771 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3772 alc_pcm_null_stream;
3773 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003774 }
3775 }
3776
Linus Torvalds1da177e2005-04-16 15:20:36 -07003777 return 0;
3778}
3779
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003780static inline void alc_shutup(struct hda_codec *codec)
3781{
3782 snd_hda_shutup_pins(codec);
3783}
3784
Takashi Iwai603c4012008-07-30 15:01:44 +02003785static void alc_free_kctls(struct hda_codec *codec)
3786{
3787 struct alc_spec *spec = codec->spec;
3788
3789 if (spec->kctls.list) {
3790 struct snd_kcontrol_new *kctl = spec->kctls.list;
3791 int i;
3792 for (i = 0; i < spec->kctls.used; i++)
3793 kfree(kctl[i].name);
3794 }
3795 snd_array_free(&spec->kctls);
3796}
3797
Linus Torvalds1da177e2005-04-16 15:20:36 -07003798static void alc_free(struct hda_codec *codec)
3799{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003800 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003801
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003802 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003803 return;
3804
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003805 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003806 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003807 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003808 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003809}
3810
Hector Martinf5de24b2009-12-20 22:51:31 +01003811#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003812static void alc_power_eapd(struct hda_codec *codec)
3813{
3814 /* We currently only handle front, HP */
3815 switch (codec->vendor_id) {
3816 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003817 set_eapd(codec, 0x0f, 0);
3818 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003819 break;
3820 case 0x10ec0262:
3821 case 0x10ec0267:
3822 case 0x10ec0268:
3823 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003824 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003825 case 0x10ec0272:
3826 case 0x10ec0660:
3827 case 0x10ec0662:
3828 case 0x10ec0663:
3829 case 0x10ec0862:
3830 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003831 set_eapd(codec, 0x14, 0);
3832 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003833 break;
3834 }
3835}
3836
Hector Martinf5de24b2009-12-20 22:51:31 +01003837static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3838{
3839 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003840 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003841 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003842 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003843 return 0;
3844}
3845#endif
3846
Takashi Iwaie044c392008-10-27 16:56:24 +01003847#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003848static int alc_resume(struct hda_codec *codec)
3849{
Takashi Iwaie044c392008-10-27 16:56:24 +01003850 codec->patch_ops.init(codec);
3851 snd_hda_codec_resume_amp(codec);
3852 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02003853#ifdef CONFIG_SND_HDA_POWER_SAVE
3854 if (codec->patch_ops.check_power_status)
3855 codec->patch_ops.check_power_status(codec, 0x01);
3856#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003857 return 0;
3858}
Takashi Iwaie044c392008-10-27 16:56:24 +01003859#endif
3860
Linus Torvalds1da177e2005-04-16 15:20:36 -07003861/*
3862 */
3863static struct hda_codec_ops alc_patch_ops = {
3864 .build_controls = alc_build_controls,
3865 .build_pcms = alc_build_pcms,
3866 .init = alc_init,
3867 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003868 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003869#ifdef SND_HDA_NEEDS_RESUME
3870 .resume = alc_resume,
3871#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003872#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003873 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003874 .check_power_status = alc_check_power_status,
3875#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003876 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003877};
3878
Kailang Yangc027ddc2010-03-19 11:33:06 +01003879/* replace the codec chip_name with the given string */
3880static int alc_codec_rename(struct hda_codec *codec, const char *name)
3881{
3882 kfree(codec->chip_name);
3883 codec->chip_name = kstrdup(name, GFP_KERNEL);
3884 if (!codec->chip_name) {
3885 alc_free(codec);
3886 return -ENOMEM;
3887 }
3888 return 0;
3889}
3890
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003891/*
3892 * Test configuration for debugging
3893 *
3894 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3895 * enum controls.
3896 */
3897#ifdef CONFIG_SND_DEBUG
3898static hda_nid_t alc880_test_dac_nids[4] = {
3899 0x02, 0x03, 0x04, 0x05
3900};
3901
3902static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003903 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003904 .items = {
3905 { "In-1", 0x0 },
3906 { "In-2", 0x1 },
3907 { "In-3", 0x2 },
3908 { "In-4", 0x3 },
3909 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003910 { "Front", 0x5 },
3911 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003912 },
3913};
3914
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003915static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003916 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003917 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003918 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003919 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003920};
3921
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003922static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3923 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003924{
3925 static char *texts[] = {
3926 "N/A", "Line Out", "HP Out",
3927 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3928 };
3929 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3930 uinfo->count = 1;
3931 uinfo->value.enumerated.items = 8;
3932 if (uinfo->value.enumerated.item >= 8)
3933 uinfo->value.enumerated.item = 7;
3934 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3935 return 0;
3936}
3937
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003938static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3939 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003940{
3941 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3942 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3943 unsigned int pin_ctl, item = 0;
3944
3945 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3946 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3947 if (pin_ctl & AC_PINCTL_OUT_EN) {
3948 if (pin_ctl & AC_PINCTL_HP_EN)
3949 item = 2;
3950 else
3951 item = 1;
3952 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3953 switch (pin_ctl & AC_PINCTL_VREFEN) {
3954 case AC_PINCTL_VREF_HIZ: item = 3; break;
3955 case AC_PINCTL_VREF_50: item = 4; break;
3956 case AC_PINCTL_VREF_GRD: item = 5; break;
3957 case AC_PINCTL_VREF_80: item = 6; break;
3958 case AC_PINCTL_VREF_100: item = 7; break;
3959 }
3960 }
3961 ucontrol->value.enumerated.item[0] = item;
3962 return 0;
3963}
3964
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003965static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3966 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003967{
3968 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3969 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3970 static unsigned int ctls[] = {
3971 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3972 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3973 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3974 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3975 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3976 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3977 };
3978 unsigned int old_ctl, new_ctl;
3979
3980 old_ctl = snd_hda_codec_read(codec, nid, 0,
3981 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3982 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3983 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003984 int val;
3985 snd_hda_codec_write_cache(codec, nid, 0,
3986 AC_VERB_SET_PIN_WIDGET_CONTROL,
3987 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003988 val = ucontrol->value.enumerated.item[0] >= 3 ?
3989 HDA_AMP_MUTE : 0;
3990 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3991 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003992 return 1;
3993 }
3994 return 0;
3995}
3996
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003997static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3998 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003999{
4000 static char *texts[] = {
4001 "Front", "Surround", "CLFE", "Side"
4002 };
4003 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4004 uinfo->count = 1;
4005 uinfo->value.enumerated.items = 4;
4006 if (uinfo->value.enumerated.item >= 4)
4007 uinfo->value.enumerated.item = 3;
4008 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4009 return 0;
4010}
4011
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004012static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4013 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004014{
4015 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4016 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4017 unsigned int sel;
4018
4019 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4020 ucontrol->value.enumerated.item[0] = sel & 3;
4021 return 0;
4022}
4023
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004024static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4025 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004026{
4027 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4028 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4029 unsigned int sel;
4030
4031 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4032 if (ucontrol->value.enumerated.item[0] != sel) {
4033 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004034 snd_hda_codec_write_cache(codec, nid, 0,
4035 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004036 return 1;
4037 }
4038 return 0;
4039}
4040
4041#define PIN_CTL_TEST(xname,nid) { \
4042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4043 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004044 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004045 .info = alc_test_pin_ctl_info, \
4046 .get = alc_test_pin_ctl_get, \
4047 .put = alc_test_pin_ctl_put, \
4048 .private_value = nid \
4049 }
4050
4051#define PIN_SRC_TEST(xname,nid) { \
4052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4053 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004054 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004055 .info = alc_test_pin_src_info, \
4056 .get = alc_test_pin_src_get, \
4057 .put = alc_test_pin_src_put, \
4058 .private_value = nid \
4059 }
4060
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004061static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004062 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4063 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4064 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4065 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004066 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4067 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4068 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4069 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004070 PIN_CTL_TEST("Front Pin Mode", 0x14),
4071 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4072 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4073 PIN_CTL_TEST("Side Pin Mode", 0x17),
4074 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4075 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4076 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4077 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4078 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4079 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4080 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4081 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4082 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4083 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4084 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4085 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4086 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4087 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4088 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4089 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4090 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4091 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004092 {
4093 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4094 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004095 .info = alc_ch_mode_info,
4096 .get = alc_ch_mode_get,
4097 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004098 },
4099 { } /* end */
4100};
4101
4102static struct hda_verb alc880_test_init_verbs[] = {
4103 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4106 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4108 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4110 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4111 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004112 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4114 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4115 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4116 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004117 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4120 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4121 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004122 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004123 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4124 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4125 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4126 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004127 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004128 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004130 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4131 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4132 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004133 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4135 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4137 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004138 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004140 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004141 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004142 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004143 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004144 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004145 /* Analog input/passthru */
4146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004151 { }
4152};
4153#endif
4154
Linus Torvalds1da177e2005-04-16 15:20:36 -07004155/*
4156 */
4157
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004158static const char *alc880_models[ALC880_MODEL_LAST] = {
4159 [ALC880_3ST] = "3stack",
4160 [ALC880_TCL_S700] = "tcl",
4161 [ALC880_3ST_DIG] = "3stack-digout",
4162 [ALC880_CLEVO] = "clevo",
4163 [ALC880_5ST] = "5stack",
4164 [ALC880_5ST_DIG] = "5stack-digout",
4165 [ALC880_W810] = "w810",
4166 [ALC880_Z71V] = "z71v",
4167 [ALC880_6ST] = "6stack",
4168 [ALC880_6ST_DIG] = "6stack-digout",
4169 [ALC880_ASUS] = "asus",
4170 [ALC880_ASUS_W1V] = "asus-w1v",
4171 [ALC880_ASUS_DIG] = "asus-dig",
4172 [ALC880_ASUS_DIG2] = "asus-dig2",
4173 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004174 [ALC880_UNIWILL_P53] = "uniwill-p53",
4175 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004176 [ALC880_F1734] = "F1734",
4177 [ALC880_LG] = "lg",
4178 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004179 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004180#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004181 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004182#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004183 [ALC880_AUTO] = "auto",
4184};
4185
4186static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004187 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004188 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4189 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4190 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4191 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4192 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4193 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4194 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4195 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004196 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4197 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004198 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4199 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4200 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4201 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4202 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4203 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4204 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4205 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4206 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4207 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004208 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004209 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4210 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4211 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004212 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004213 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004214 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4215 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004216 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4217 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004218 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4219 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4220 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4221 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004222 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4223 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004224 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004225 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004226 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004227 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004228 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4229 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004230 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004231 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004232 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004233 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004234 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004235 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004236 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004237 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004238 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004239 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4240 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004241 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004242 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4243 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4244 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4245 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004246 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4247 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004248 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004249 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004250 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4251 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004252 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4253 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4254 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004255 /* default Intel */
4256 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004257 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4258 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004259 {}
4260};
4261
Takashi Iwai16ded522005-06-10 19:58:24 +02004262/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004263 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004264 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004265static struct alc_config_preset alc880_presets[] = {
4266 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004268 .init_verbs = { alc880_volume_init_verbs,
4269 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004270 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004271 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004272 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4273 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004274 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004275 .input_mux = &alc880_capture_source,
4276 },
4277 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004279 .init_verbs = { alc880_volume_init_verbs,
4280 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004281 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004282 .dac_nids = alc880_dac_nids,
4283 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004284 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4285 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004286 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004287 .input_mux = &alc880_capture_source,
4288 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004289 [ALC880_TCL_S700] = {
4290 .mixers = { alc880_tcl_s700_mixer },
4291 .init_verbs = { alc880_volume_init_verbs,
4292 alc880_pin_tcl_S700_init_verbs,
4293 alc880_gpio2_init_verbs },
4294 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4295 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004296 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4297 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004298 .hp_nid = 0x03,
4299 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4300 .channel_mode = alc880_2_jack_modes,
4301 .input_mux = &alc880_capture_source,
4302 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004303 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004304 .mixers = { alc880_three_stack_mixer,
4305 alc880_five_stack_mixer},
4306 .init_verbs = { alc880_volume_init_verbs,
4307 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004308 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4309 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004310 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4311 .channel_mode = alc880_fivestack_modes,
4312 .input_mux = &alc880_capture_source,
4313 },
4314 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004315 .mixers = { alc880_three_stack_mixer,
4316 alc880_five_stack_mixer },
4317 .init_verbs = { alc880_volume_init_verbs,
4318 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004319 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4320 .dac_nids = alc880_dac_nids,
4321 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004322 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4323 .channel_mode = alc880_fivestack_modes,
4324 .input_mux = &alc880_capture_source,
4325 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004326 [ALC880_6ST] = {
4327 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004328 .init_verbs = { alc880_volume_init_verbs,
4329 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004330 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4331 .dac_nids = alc880_6st_dac_nids,
4332 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4333 .channel_mode = alc880_sixstack_modes,
4334 .input_mux = &alc880_6stack_capture_source,
4335 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004336 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004337 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004338 .init_verbs = { alc880_volume_init_verbs,
4339 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004340 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4341 .dac_nids = alc880_6st_dac_nids,
4342 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004343 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4344 .channel_mode = alc880_sixstack_modes,
4345 .input_mux = &alc880_6stack_capture_source,
4346 },
4347 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004349 .init_verbs = { alc880_volume_init_verbs,
4350 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004351 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004352 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4353 .dac_nids = alc880_w810_dac_nids,
4354 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004355 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4356 .channel_mode = alc880_w810_modes,
4357 .input_mux = &alc880_capture_source,
4358 },
4359 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004360 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004361 .init_verbs = { alc880_volume_init_verbs,
4362 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004363 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4364 .dac_nids = alc880_z71v_dac_nids,
4365 .dig_out_nid = ALC880_DIGOUT_NID,
4366 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004367 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4368 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004369 .input_mux = &alc880_capture_source,
4370 },
4371 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004372 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004373 .init_verbs = { alc880_volume_init_verbs,
4374 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004375 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4376 .dac_nids = alc880_f1734_dac_nids,
4377 .hp_nid = 0x02,
4378 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4379 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004380 .input_mux = &alc880_f1734_capture_source,
4381 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004382 .setup = alc880_uniwill_p53_setup,
4383 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004384 },
4385 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004386 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004387 .init_verbs = { alc880_volume_init_verbs,
4388 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004389 alc880_gpio1_init_verbs },
4390 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4391 .dac_nids = alc880_asus_dac_nids,
4392 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4393 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004394 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004395 .input_mux = &alc880_capture_source,
4396 },
4397 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004398 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004399 .init_verbs = { alc880_volume_init_verbs,
4400 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401 alc880_gpio1_init_verbs },
4402 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4403 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004404 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004405 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4406 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004407 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004408 .input_mux = &alc880_capture_source,
4409 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004410 [ALC880_ASUS_DIG2] = {
4411 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004412 .init_verbs = { alc880_volume_init_verbs,
4413 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004414 alc880_gpio2_init_verbs }, /* use GPIO2 */
4415 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4416 .dac_nids = alc880_asus_dac_nids,
4417 .dig_out_nid = ALC880_DIGOUT_NID,
4418 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4419 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004420 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004421 .input_mux = &alc880_capture_source,
4422 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004423 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004424 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004425 .init_verbs = { alc880_volume_init_verbs,
4426 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004427 alc880_gpio1_init_verbs },
4428 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4429 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004430 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004431 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4432 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004433 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004434 .input_mux = &alc880_capture_source,
4435 },
4436 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004437 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004438 .init_verbs = { alc880_volume_init_verbs,
4439 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004440 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4441 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004442 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004443 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4444 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004445 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004446 .input_mux = &alc880_capture_source,
4447 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004448 [ALC880_UNIWILL] = {
4449 .mixers = { alc880_uniwill_mixer },
4450 .init_verbs = { alc880_volume_init_verbs,
4451 alc880_uniwill_init_verbs },
4452 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4453 .dac_nids = alc880_asus_dac_nids,
4454 .dig_out_nid = ALC880_DIGOUT_NID,
4455 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4456 .channel_mode = alc880_threestack_modes,
4457 .need_dac_fix = 1,
4458 .input_mux = &alc880_capture_source,
4459 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004460 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004461 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004462 },
4463 [ALC880_UNIWILL_P53] = {
4464 .mixers = { alc880_uniwill_p53_mixer },
4465 .init_verbs = { alc880_volume_init_verbs,
4466 alc880_uniwill_p53_init_verbs },
4467 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4468 .dac_nids = alc880_asus_dac_nids,
4469 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004470 .channel_mode = alc880_threestack_modes,
4471 .input_mux = &alc880_capture_source,
4472 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004473 .setup = alc880_uniwill_p53_setup,
4474 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004475 },
4476 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004477 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004478 .init_verbs = { alc880_volume_init_verbs,
4479 alc880_uniwill_p53_init_verbs,
4480 alc880_beep_init_verbs },
4481 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4482 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004483 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004484 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4485 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004486 .input_mux = &alc880_capture_source,
4487 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004488 .setup = alc880_uniwill_p53_setup,
4489 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004490 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004491 [ALC880_CLEVO] = {
4492 .mixers = { alc880_three_stack_mixer },
4493 .init_verbs = { alc880_volume_init_verbs,
4494 alc880_pin_clevo_init_verbs },
4495 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4496 .dac_nids = alc880_dac_nids,
4497 .hp_nid = 0x03,
4498 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4499 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004500 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004501 .input_mux = &alc880_capture_source,
4502 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004503 [ALC880_LG] = {
4504 .mixers = { alc880_lg_mixer },
4505 .init_verbs = { alc880_volume_init_verbs,
4506 alc880_lg_init_verbs },
4507 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4508 .dac_nids = alc880_lg_dac_nids,
4509 .dig_out_nid = ALC880_DIGOUT_NID,
4510 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4511 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004512 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004513 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004514 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004515 .setup = alc880_lg_setup,
4516 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004517#ifdef CONFIG_SND_HDA_POWER_SAVE
4518 .loopbacks = alc880_lg_loopbacks,
4519#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004520 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004521 [ALC880_LG_LW] = {
4522 .mixers = { alc880_lg_lw_mixer },
4523 .init_verbs = { alc880_volume_init_verbs,
4524 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004525 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004526 .dac_nids = alc880_dac_nids,
4527 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004528 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4529 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004530 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004531 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004532 .setup = alc880_lg_lw_setup,
4533 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004534 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004535 [ALC880_MEDION_RIM] = {
4536 .mixers = { alc880_medion_rim_mixer },
4537 .init_verbs = { alc880_volume_init_verbs,
4538 alc880_medion_rim_init_verbs,
4539 alc_gpio2_init_verbs },
4540 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4541 .dac_nids = alc880_dac_nids,
4542 .dig_out_nid = ALC880_DIGOUT_NID,
4543 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4544 .channel_mode = alc880_2_jack_modes,
4545 .input_mux = &alc880_medion_rim_capture_source,
4546 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004547 .setup = alc880_medion_rim_setup,
4548 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004549 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004550#ifdef CONFIG_SND_DEBUG
4551 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004552 .mixers = { alc880_test_mixer },
4553 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004554 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4555 .dac_nids = alc880_test_dac_nids,
4556 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004557 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4558 .channel_mode = alc880_test_modes,
4559 .input_mux = &alc880_test_capture_source,
4560 },
4561#endif
4562};
4563
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004564/*
4565 * Automatic parse of I/O pins from the BIOS configuration
4566 */
4567
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004568enum {
4569 ALC_CTL_WIDGET_VOL,
4570 ALC_CTL_WIDGET_MUTE,
4571 ALC_CTL_BIND_MUTE,
4572};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004573static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004574 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4575 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004576 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004577};
4578
4579/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004580static int add_control(struct alc_spec *spec, int type, const char *name,
4581 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004582{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004583 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584
Takashi Iwai603c4012008-07-30 15:01:44 +02004585 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4586 knew = snd_array_new(&spec->kctls);
4587 if (!knew)
4588 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004589 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004590 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004591 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004592 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004593 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004594 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004595 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004596 return 0;
4597}
4598
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004599static int add_control_with_pfx(struct alc_spec *spec, int type,
4600 const char *pfx, const char *dir,
4601 const char *sfx, unsigned long val)
4602{
4603 char name[32];
4604 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4605 return add_control(spec, type, name, val);
4606}
4607
4608#define add_pb_vol_ctrl(spec, type, pfx, val) \
4609 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4610#define add_pb_sw_ctrl(spec, type, pfx, val) \
4611 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4612
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4614#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4615#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4616#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004617#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4618#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4619#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4620#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4621#define ALC880_PIN_CD_NID 0x1c
4622
4623/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004624static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4625 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004626{
4627 hda_nid_t nid;
4628 int assigned[4];
4629 int i, j;
4630
4631 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004632 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633
4634 /* check the pins hardwired to audio widget */
4635 for (i = 0; i < cfg->line_outs; i++) {
4636 nid = cfg->line_out_pins[i];
4637 if (alc880_is_fixed_pin(nid)) {
4638 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004639 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004640 assigned[idx] = 1;
4641 }
4642 }
4643 /* left pins can be connect to any audio widget */
4644 for (i = 0; i < cfg->line_outs; i++) {
4645 nid = cfg->line_out_pins[i];
4646 if (alc880_is_fixed_pin(nid))
4647 continue;
4648 /* search for an empty channel */
4649 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004650 if (!assigned[j]) {
4651 spec->multiout.dac_nids[i] =
4652 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004653 assigned[j] = 1;
4654 break;
4655 }
4656 }
4657 }
4658 spec->multiout.num_dacs = cfg->line_outs;
4659 return 0;
4660}
4661
4662/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004663static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4664 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004665{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004666 static const char *chname[4] = {
4667 "Front", "Surround", NULL /*CLFE*/, "Side"
4668 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004669 hda_nid_t nid;
4670 int i, err;
4671
4672 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004673 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004674 continue;
4675 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4676 if (i == 2) {
4677 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004678 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4679 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004680 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4681 HDA_OUTPUT));
4682 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004683 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004684 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4685 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004686 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4687 HDA_OUTPUT));
4688 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004689 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004690 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4691 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004692 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4693 HDA_INPUT));
4694 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004695 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004696 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4697 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004698 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4699 HDA_INPUT));
4700 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004701 return err;
4702 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004703 const char *pfx;
4704 if (cfg->line_outs == 1 &&
4705 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4706 pfx = "Speaker";
4707 else
4708 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004709 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004710 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4711 HDA_OUTPUT));
4712 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004713 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004714 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004715 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4716 HDA_INPUT));
4717 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004718 return err;
4719 }
4720 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004721 return 0;
4722}
4723
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004724/* add playback controls for speaker and HP outputs */
4725static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4726 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004727{
4728 hda_nid_t nid;
4729 int err;
4730
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004731 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004732 return 0;
4733
4734 if (alc880_is_fixed_pin(pin)) {
4735 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004736 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004737 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004738 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004739 else
4740 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004741 /* control HP volume/switch on the output mixer amp */
4742 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004743 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004744 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4745 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004746 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004747 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004748 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4749 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004750 return err;
4751 } else if (alc880_is_multi_pin(pin)) {
4752 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004753 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004754 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004755 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4756 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757 return err;
4758 }
4759 return 0;
4760}
4761
4762/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004763static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4764 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004765 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004766{
Kailang Yangdf694da2005-12-05 19:42:22 +01004767 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004768
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004769 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004770 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4771 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004772 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004773 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004774 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4775 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004776 return err;
4777 return 0;
4778}
4779
Takashi Iwai05f5f472009-08-25 13:10:18 +02004780static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004781{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004782 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4783 return (pincap & AC_PINCAP_IN) != 0;
4784}
4785
4786/* create playback/capture controls for input pins */
4787static int alc_auto_create_input_ctls(struct hda_codec *codec,
4788 const struct auto_pin_cfg *cfg,
4789 hda_nid_t mixer,
4790 hda_nid_t cap1, hda_nid_t cap2)
4791{
4792 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004793 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004794 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004795
4796 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004797 hda_nid_t pin;
4798
4799 pin = cfg->input_pins[i];
4800 if (!alc_is_input_pin(codec, pin))
4801 continue;
4802
4803 if (mixer) {
4804 idx = get_connection_index(codec, mixer, pin);
4805 if (idx >= 0) {
4806 err = new_analog_input(spec, pin,
4807 auto_pin_cfg_labels[i],
4808 idx, mixer);
4809 if (err < 0)
4810 return err;
4811 }
4812 }
4813
4814 if (!cap1)
4815 continue;
4816 idx = get_connection_index(codec, cap1, pin);
4817 if (idx < 0 && cap2)
4818 idx = get_connection_index(codec, cap2, pin);
4819 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004820 imux->items[imux->num_items].label =
4821 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004822 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004823 imux->num_items++;
4824 }
4825 }
4826 return 0;
4827}
4828
Takashi Iwai05f5f472009-08-25 13:10:18 +02004829static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4830 const struct auto_pin_cfg *cfg)
4831{
4832 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4833}
4834
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004835static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4836 unsigned int pin_type)
4837{
4838 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4839 pin_type);
4840 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004841 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4842 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004843}
4844
Kailang Yangdf694da2005-12-05 19:42:22 +01004845static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4846 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004847 int dac_idx)
4848{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004849 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004850 /* need the manual connection? */
4851 if (alc880_is_multi_pin(nid)) {
4852 struct alc_spec *spec = codec->spec;
4853 int idx = alc880_multi_pin_idx(nid);
4854 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4855 AC_VERB_SET_CONNECT_SEL,
4856 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4857 }
4858}
4859
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004860static int get_pin_type(int line_out_type)
4861{
4862 if (line_out_type == AUTO_PIN_HP_OUT)
4863 return PIN_HP;
4864 else
4865 return PIN_OUT;
4866}
4867
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004868static void alc880_auto_init_multi_out(struct hda_codec *codec)
4869{
4870 struct alc_spec *spec = codec->spec;
4871 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004872
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004873 for (i = 0; i < spec->autocfg.line_outs; i++) {
4874 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004875 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4876 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004877 }
4878}
4879
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004880static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004881{
4882 struct alc_spec *spec = codec->spec;
4883 hda_nid_t pin;
4884
Takashi Iwai82bc9552006-03-21 11:24:42 +01004885 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004886 if (pin) /* connect to front */
4887 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004888 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004889 if (pin) /* connect to front */
4890 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4891}
4892
4893static void alc880_auto_init_analog_input(struct hda_codec *codec)
4894{
4895 struct alc_spec *spec = codec->spec;
4896 int i;
4897
4898 for (i = 0; i < AUTO_PIN_LAST; i++) {
4899 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004900 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004901 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004902 if (nid != ALC880_PIN_CD_NID &&
4903 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004904 snd_hda_codec_write(codec, nid, 0,
4905 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004906 AMP_OUT_MUTE);
4907 }
4908 }
4909}
4910
Takashi Iwai7f311a42010-04-09 17:32:23 +02004911static void alc880_auto_init_input_src(struct hda_codec *codec)
4912{
4913 struct alc_spec *spec = codec->spec;
4914 int c;
4915
4916 for (c = 0; c < spec->num_adc_nids; c++) {
4917 unsigned int mux_idx;
4918 const struct hda_input_mux *imux;
4919 mux_idx = c >= spec->num_mux_defs ? 0 : c;
4920 imux = &spec->input_mux[mux_idx];
4921 if (!imux->num_items && mux_idx > 0)
4922 imux = &spec->input_mux[0];
4923 if (imux)
4924 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
4925 AC_VERB_SET_CONNECT_SEL,
4926 imux->items[0].index);
4927 }
4928}
4929
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004930/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004931/* return 1 if successful, 0 if the proper config is not found,
4932 * or a negative error code
4933 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004934static int alc880_parse_auto_config(struct hda_codec *codec)
4935{
4936 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004937 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004938 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004939
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004940 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4941 alc880_ignore);
4942 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004943 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004944 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004945 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004946
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004947 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4948 if (err < 0)
4949 return err;
4950 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4951 if (err < 0)
4952 return err;
4953 err = alc880_auto_create_extra_out(spec,
4954 spec->autocfg.speaker_pins[0],
4955 "Speaker");
4956 if (err < 0)
4957 return err;
4958 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4959 "Headphone");
4960 if (err < 0)
4961 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004962 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004963 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004964 return err;
4965
4966 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4967
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004968 /* check multiple SPDIF-out (for recent codecs) */
4969 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4970 hda_nid_t dig_nid;
4971 err = snd_hda_get_connections(codec,
4972 spec->autocfg.dig_out_pins[i],
4973 &dig_nid, 1);
4974 if (err < 0)
4975 continue;
4976 if (!i)
4977 spec->multiout.dig_out_nid = dig_nid;
4978 else {
4979 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004980 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004981 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004982 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004983 }
4984 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004985 if (spec->autocfg.dig_in_pin)
4986 spec->dig_in_nid = ALC880_DIGIN_NID;
4987
Takashi Iwai603c4012008-07-30 15:01:44 +02004988 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004989 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004990
Takashi Iwaid88897e2008-10-31 15:01:37 +01004991 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004992
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004993 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004994 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004995
Kailang Yang6227cdc2010-02-25 08:36:52 +01004996 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004997
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004998 return 1;
4999}
5000
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005001/* additional initialization for auto-configuration model */
5002static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005003{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005004 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005005 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005006 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005007 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005008 alc880_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005009 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005010 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005011}
5012
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005013/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5014 * one of two digital mic pins, e.g. on ALC272
5015 */
5016static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005017{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005018 struct alc_spec *spec = codec->spec;
5019 int i;
5020
5021 for (i = 0; i < spec->num_adc_nids; i++) {
5022 hda_nid_t cap = spec->capsrc_nids ?
5023 spec->capsrc_nids[i] : spec->adc_nids[i];
5024 int iidx, eidx;
5025
5026 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5027 if (iidx < 0)
5028 continue;
5029 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5030 if (eidx < 0)
5031 continue;
5032 spec->int_mic.mux_idx = iidx;
5033 spec->ext_mic.mux_idx = eidx;
5034 if (spec->capsrc_nids)
5035 spec->capsrc_nids += i;
5036 spec->adc_nids += i;
5037 spec->num_adc_nids = 1;
5038 return;
5039 }
5040 snd_printd(KERN_INFO "hda_codec: %s: "
5041 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5042 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5043 spec->auto_mic = 0; /* disable auto-mic to be sure */
5044}
5045
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005046/* choose the ADC/MUX containing the input pin and initialize the setup */
5047static void fixup_single_adc(struct hda_codec *codec)
5048{
5049 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01005050 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005051 int i;
5052
5053 /* search for the input pin; there must be only one */
5054 for (i = 0; i < AUTO_PIN_LAST; i++) {
5055 if (spec->autocfg.input_pins[i]) {
5056 pin = spec->autocfg.input_pins[i];
5057 break;
5058 }
5059 }
5060 if (!pin)
5061 return;
5062
5063 /* set the default connection to that pin */
5064 for (i = 0; i < spec->num_adc_nids; i++) {
5065 hda_nid_t cap = spec->capsrc_nids ?
5066 spec->capsrc_nids[i] : spec->adc_nids[i];
5067 int idx;
5068
5069 idx = get_connection_index(codec, cap, pin);
5070 if (idx < 0)
5071 continue;
5072 /* use only this ADC */
5073 if (spec->capsrc_nids)
5074 spec->capsrc_nids += i;
5075 spec->adc_nids += i;
5076 spec->num_adc_nids = 1;
5077 /* select or unmute this route */
5078 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5079 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5080 HDA_AMP_MUTE, 0);
5081 } else {
5082 snd_hda_codec_write_cache(codec, cap, 0,
5083 AC_VERB_SET_CONNECT_SEL, idx);
5084 }
5085 return;
5086 }
5087}
5088
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005089static void set_capture_mixer(struct hda_codec *codec)
5090{
5091 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005092 static struct snd_kcontrol_new *caps[2][3] = {
5093 { alc_capture_mixer_nosrc1,
5094 alc_capture_mixer_nosrc2,
5095 alc_capture_mixer_nosrc3 },
5096 { alc_capture_mixer1,
5097 alc_capture_mixer2,
5098 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005099 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005100 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005101 int mux = 0;
5102 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005103 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005104 else if (spec->input_mux) {
5105 if (spec->input_mux->num_items > 1)
5106 mux = 1;
5107 else if (spec->input_mux->num_items == 1)
5108 fixup_single_adc(codec);
5109 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01005110 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
5111 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005112}
5113
Takashi Iwai66946352010-03-29 17:21:45 +02005114/* fill adc_nids (and capsrc_nids) containing all active input pins */
5115static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5116 int num_nids)
5117{
5118 struct alc_spec *spec = codec->spec;
5119 int n;
5120 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5121
5122 for (n = 0; n < num_nids; n++) {
5123 hda_nid_t adc, cap;
5124 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5125 int nconns, i, j;
5126
5127 adc = nids[n];
5128 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5129 continue;
5130 cap = adc;
5131 nconns = snd_hda_get_connections(codec, cap, conn,
5132 ARRAY_SIZE(conn));
5133 if (nconns == 1) {
5134 cap = conn[0];
5135 nconns = snd_hda_get_connections(codec, cap, conn,
5136 ARRAY_SIZE(conn));
5137 }
5138 if (nconns <= 0)
5139 continue;
5140 if (!fallback_adc) {
5141 fallback_adc = adc;
5142 fallback_cap = cap;
5143 }
5144 for (i = 0; i < AUTO_PIN_LAST; i++) {
5145 hda_nid_t nid = spec->autocfg.input_pins[i];
5146 if (!nid)
5147 continue;
5148 for (j = 0; j < nconns; j++) {
5149 if (conn[j] == nid)
5150 break;
5151 }
5152 if (j >= nconns)
5153 break;
5154 }
5155 if (i >= AUTO_PIN_LAST) {
5156 int num_adcs = spec->num_adc_nids;
5157 spec->private_adc_nids[num_adcs] = adc;
5158 spec->private_capsrc_nids[num_adcs] = cap;
5159 spec->num_adc_nids++;
5160 spec->adc_nids = spec->private_adc_nids;
5161 if (adc != cap)
5162 spec->capsrc_nids = spec->private_capsrc_nids;
5163 }
5164 }
5165 if (!spec->num_adc_nids) {
5166 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005167 " using fallback 0x%x\n",
5168 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005169 spec->private_adc_nids[0] = fallback_adc;
5170 spec->adc_nids = spec->private_adc_nids;
5171 if (fallback_adc != fallback_cap) {
5172 spec->private_capsrc_nids[0] = fallback_cap;
5173 spec->capsrc_nids = spec->private_adc_nids;
5174 }
5175 }
5176}
5177
Takashi Iwai67d634c2009-11-16 15:35:59 +01005178#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005179#define set_beep_amp(spec, nid, idx, dir) \
5180 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01005181#else
5182#define set_beep_amp(spec, nid, idx, dir) /* NOP */
5183#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005184
5185/*
5186 * OK, here we have finally the patch for ALC880
5187 */
5188
Linus Torvalds1da177e2005-04-16 15:20:36 -07005189static int patch_alc880(struct hda_codec *codec)
5190{
5191 struct alc_spec *spec;
5192 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005193 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005194
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005195 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005196 if (spec == NULL)
5197 return -ENOMEM;
5198
5199 codec->spec = spec;
5200
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005201 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5202 alc880_models,
5203 alc880_cfg_tbl);
5204 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005205 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5206 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005207 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005208 }
5209
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005210 if (board_config == ALC880_AUTO) {
5211 /* automatic parse from the BIOS config */
5212 err = alc880_parse_auto_config(codec);
5213 if (err < 0) {
5214 alc_free(codec);
5215 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005216 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005217 printk(KERN_INFO
5218 "hda_codec: Cannot set up configuration "
5219 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005220 board_config = ALC880_3ST;
5221 }
5222 }
5223
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005224 err = snd_hda_attach_beep_device(codec, 0x1);
5225 if (err < 0) {
5226 alc_free(codec);
5227 return err;
5228 }
5229
Kailang Yangdf694da2005-12-05 19:42:22 +01005230 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005231 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005232
Linus Torvalds1da177e2005-04-16 15:20:36 -07005233 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5234 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005235 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005236
Linus Torvalds1da177e2005-04-16 15:20:36 -07005237 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5238 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5239
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005240 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005241 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005242 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005243 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005244 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005245 if (wcap != AC_WID_AUD_IN) {
5246 spec->adc_nids = alc880_adc_nids_alt;
5247 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005248 } else {
5249 spec->adc_nids = alc880_adc_nids;
5250 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005251 }
5252 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005253 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005254 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005255
Takashi Iwai2134ea42008-01-10 16:53:55 +01005256 spec->vmaster_nid = 0x0c;
5257
Linus Torvalds1da177e2005-04-16 15:20:36 -07005258 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005259 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005260 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005261#ifdef CONFIG_SND_HDA_POWER_SAVE
5262 if (!spec->loopback.amplist)
5263 spec->loopback.amplist = alc880_loopbacks;
5264#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005265
5266 return 0;
5267}
5268
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005269
Linus Torvalds1da177e2005-04-16 15:20:36 -07005270/*
5271 * ALC260 support
5272 */
5273
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005274static hda_nid_t alc260_dac_nids[1] = {
5275 /* front */
5276 0x02,
5277};
5278
5279static hda_nid_t alc260_adc_nids[1] = {
5280 /* ADC0 */
5281 0x04,
5282};
5283
Kailang Yangdf694da2005-12-05 19:42:22 +01005284static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005285 /* ADC1 */
5286 0x05,
5287};
5288
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005289/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5290 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5291 */
5292static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005293 /* ADC0, ADC1 */
5294 0x04, 0x05
5295};
5296
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005297#define ALC260_DIGOUT_NID 0x03
5298#define ALC260_DIGIN_NID 0x06
5299
5300static struct hda_input_mux alc260_capture_source = {
5301 .num_items = 4,
5302 .items = {
5303 { "Mic", 0x0 },
5304 { "Front Mic", 0x1 },
5305 { "Line", 0x2 },
5306 { "CD", 0x4 },
5307 },
5308};
5309
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005310/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005311 * headphone jack and the internal CD lines since these are the only pins at
5312 * which audio can appear. For flexibility, also allow the option of
5313 * recording the mixer output on the second ADC (ADC0 doesn't have a
5314 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005315 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005316static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5317 {
5318 .num_items = 3,
5319 .items = {
5320 { "Mic/Line", 0x0 },
5321 { "CD", 0x4 },
5322 { "Headphone", 0x2 },
5323 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005324 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005325 {
5326 .num_items = 4,
5327 .items = {
5328 { "Mic/Line", 0x0 },
5329 { "CD", 0x4 },
5330 { "Headphone", 0x2 },
5331 { "Mixer", 0x5 },
5332 },
5333 },
5334
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005335};
5336
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005337/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5338 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005339 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005340static struct hda_input_mux alc260_acer_capture_sources[2] = {
5341 {
5342 .num_items = 4,
5343 .items = {
5344 { "Mic", 0x0 },
5345 { "Line", 0x2 },
5346 { "CD", 0x4 },
5347 { "Headphone", 0x5 },
5348 },
5349 },
5350 {
5351 .num_items = 5,
5352 .items = {
5353 { "Mic", 0x0 },
5354 { "Line", 0x2 },
5355 { "CD", 0x4 },
5356 { "Headphone", 0x6 },
5357 { "Mixer", 0x5 },
5358 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005359 },
5360};
Michael Schwingencc959482009-02-22 18:58:45 +01005361
5362/* Maxdata Favorit 100XS */
5363static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5364 {
5365 .num_items = 2,
5366 .items = {
5367 { "Line/Mic", 0x0 },
5368 { "CD", 0x4 },
5369 },
5370 },
5371 {
5372 .num_items = 3,
5373 .items = {
5374 { "Line/Mic", 0x0 },
5375 { "CD", 0x4 },
5376 { "Mixer", 0x5 },
5377 },
5378 },
5379};
5380
Linus Torvalds1da177e2005-04-16 15:20:36 -07005381/*
5382 * This is just place-holder, so there's something for alc_build_pcms to look
5383 * at when it calculates the maximum number of channels. ALC260 has no mixer
5384 * element which allows changing the channel mode, so the verb list is
5385 * never used.
5386 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005387static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005388 { 2, NULL },
5389};
5390
Kailang Yangdf694da2005-12-05 19:42:22 +01005391
5392/* Mixer combinations
5393 *
5394 * basic: base_output + input + pc_beep + capture
5395 * HP: base_output + input + capture_alt
5396 * HP_3013: hp_3013 + input + capture
5397 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005398 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005399 */
5400
5401static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005402 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005403 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005404 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5405 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5406 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5407 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5408 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005409};
Kailang Yangdf694da2005-12-05 19:42:22 +01005410
5411static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005412 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5413 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5414 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5415 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5416 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5417 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5418 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5419 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005420 { } /* end */
5421};
5422
Takashi Iwaibec15c32008-01-28 18:16:30 +01005423/* update HP, line and mono out pins according to the master switch */
5424static void alc260_hp_master_update(struct hda_codec *codec,
5425 hda_nid_t hp, hda_nid_t line,
5426 hda_nid_t mono)
5427{
5428 struct alc_spec *spec = codec->spec;
5429 unsigned int val = spec->master_sw ? PIN_HP : 0;
5430 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005431 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005432 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005433 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005434 val);
5435 /* mono (speaker) depending on the HP jack sense */
5436 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005437 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005438 val);
5439}
5440
5441static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5442 struct snd_ctl_elem_value *ucontrol)
5443{
5444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5445 struct alc_spec *spec = codec->spec;
5446 *ucontrol->value.integer.value = spec->master_sw;
5447 return 0;
5448}
5449
5450static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5451 struct snd_ctl_elem_value *ucontrol)
5452{
5453 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5454 struct alc_spec *spec = codec->spec;
5455 int val = !!*ucontrol->value.integer.value;
5456 hda_nid_t hp, line, mono;
5457
5458 if (val == spec->master_sw)
5459 return 0;
5460 spec->master_sw = val;
5461 hp = (kcontrol->private_value >> 16) & 0xff;
5462 line = (kcontrol->private_value >> 8) & 0xff;
5463 mono = kcontrol->private_value & 0xff;
5464 alc260_hp_master_update(codec, hp, line, mono);
5465 return 1;
5466}
5467
5468static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5469 {
5470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5471 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005472 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005473 .info = snd_ctl_boolean_mono_info,
5474 .get = alc260_hp_master_sw_get,
5475 .put = alc260_hp_master_sw_put,
5476 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5477 },
5478 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5479 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5480 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5481 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5482 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5483 HDA_OUTPUT),
5484 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5485 { } /* end */
5486};
5487
5488static struct hda_verb alc260_hp_unsol_verbs[] = {
5489 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5490 {},
5491};
5492
5493static void alc260_hp_automute(struct hda_codec *codec)
5494{
5495 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005496
Wu Fengguang864f92b2009-11-18 12:38:02 +08005497 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005498 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5499}
5500
5501static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5502{
5503 if ((res >> 26) == ALC880_HP_EVENT)
5504 alc260_hp_automute(codec);
5505}
5506
Kailang Yangdf694da2005-12-05 19:42:22 +01005507static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005508 {
5509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5510 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005511 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005512 .info = snd_ctl_boolean_mono_info,
5513 .get = alc260_hp_master_sw_get,
5514 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005515 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005516 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005517 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5518 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5519 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5520 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5521 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005523 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5524 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005525 { } /* end */
5526};
5527
Kailang Yang3f878302008-08-26 13:02:23 +02005528static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5529 .ops = &snd_hda_bind_vol,
5530 .values = {
5531 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5532 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5533 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5534 0
5535 },
5536};
5537
5538static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5539 .ops = &snd_hda_bind_sw,
5540 .values = {
5541 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5542 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5543 0
5544 },
5545};
5546
5547static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5548 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5549 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5550 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5552 { } /* end */
5553};
5554
Takashi Iwaibec15c32008-01-28 18:16:30 +01005555static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5556 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5557 {},
5558};
5559
5560static void alc260_hp_3013_automute(struct hda_codec *codec)
5561{
5562 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005563
Wu Fengguang864f92b2009-11-18 12:38:02 +08005564 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005565 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005566}
5567
5568static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5569 unsigned int res)
5570{
5571 if ((res >> 26) == ALC880_HP_EVENT)
5572 alc260_hp_3013_automute(codec);
5573}
5574
Kailang Yang3f878302008-08-26 13:02:23 +02005575static void alc260_hp_3012_automute(struct hda_codec *codec)
5576{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005577 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005578
Kailang Yang3f878302008-08-26 13:02:23 +02005579 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5580 bits);
5581 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5582 bits);
5583 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5584 bits);
5585}
5586
5587static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5588 unsigned int res)
5589{
5590 if ((res >> 26) == ALC880_HP_EVENT)
5591 alc260_hp_3012_automute(codec);
5592}
5593
5594/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005595 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5596 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01005597static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005598 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005599 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005600 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005601 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5602 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5603 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5604 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005605 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005606 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5607 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005608 { } /* end */
5609};
5610
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005611/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5612 * versions of the ALC260 don't act on requests to enable mic bias from NID
5613 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5614 * datasheet doesn't mention this restriction. At this stage it's not clear
5615 * whether this behaviour is intentional or is a hardware bug in chip
5616 * revisions available in early 2006. Therefore for now allow the
5617 * "Headphone Jack Mode" control to span all choices, but if it turns out
5618 * that the lack of mic bias for this NID is intentional we could change the
5619 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5620 *
5621 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5622 * don't appear to make the mic bias available from the "line" jack, even
5623 * though the NID used for this jack (0x14) can supply it. The theory is
5624 * that perhaps Acer have included blocking capacitors between the ALC260
5625 * and the output jack. If this turns out to be the case for all such
5626 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5627 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005628 *
5629 * The C20x Tablet series have a mono internal speaker which is controlled
5630 * via the chip's Mono sum widget and pin complex, so include the necessary
5631 * controls for such models. On models without a "mono speaker" the control
5632 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005633 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005634static struct snd_kcontrol_new alc260_acer_mixer[] = {
5635 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5636 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005637 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005638 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005639 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005640 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005641 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005642 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5643 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5644 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5645 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5646 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5647 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5648 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5649 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005650 { } /* end */
5651};
5652
Michael Schwingencc959482009-02-22 18:58:45 +01005653/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5654 */
5655static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5656 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5657 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5658 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5659 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5660 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5661 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5662 { } /* end */
5663};
5664
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005665/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5666 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5667 */
5668static struct snd_kcontrol_new alc260_will_mixer[] = {
5669 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5670 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5672 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5673 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5674 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5675 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5676 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5677 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5678 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005679 { } /* end */
5680};
5681
5682/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5683 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5684 */
5685static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5686 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5687 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5689 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5690 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5691 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5692 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5693 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5694 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5695 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5696 { } /* end */
5697};
5698
Kailang Yangdf694da2005-12-05 19:42:22 +01005699/*
5700 * initialization verbs
5701 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005702static struct hda_verb alc260_init_verbs[] = {
5703 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005704 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005705 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005706 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005707 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005708 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005709 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005710 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005711 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005712 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005713 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005714 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005715 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005716 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005717 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005718 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005719 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005720 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5721 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005722 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005723 /* set connection select to line in (default select for this ADC) */
5724 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005725 /* mute capture amp left and right */
5726 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5727 /* set connection select to line in (default select for this ADC) */
5728 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005729 /* set vol=0 Line-Out mixer amp left and right */
5730 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5731 /* unmute pin widget amp left and right (no gain on this amp) */
5732 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5733 /* set vol=0 HP mixer amp left and right */
5734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5735 /* unmute pin widget amp left and right (no gain on this amp) */
5736 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5737 /* set vol=0 Mono mixer amp left and right */
5738 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5739 /* unmute pin widget amp left and right (no gain on this amp) */
5740 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5741 /* unmute LINE-2 out pin */
5742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005743 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5744 * Line In 2 = 0x03
5745 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005746 /* mute analog inputs */
5747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005752 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005753 /* mute Front out path */
5754 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5756 /* mute Headphone out path */
5757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5758 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5759 /* mute Mono out path */
5760 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5761 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005762 { }
5763};
5764
Takashi Iwai474167d2006-05-17 17:17:43 +02005765#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005766static struct hda_verb alc260_hp_init_verbs[] = {
5767 /* Headphone and output */
5768 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5769 /* mono output */
5770 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5771 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5772 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5773 /* Mic2 (front panel) pin widget for input and vref at 80% */
5774 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5775 /* Line In pin widget for input */
5776 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5777 /* Line-2 pin widget for output */
5778 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5779 /* CD pin widget for input */
5780 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5781 /* unmute amp left and right */
5782 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5783 /* set connection select to line in (default select for this ADC) */
5784 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5785 /* unmute Line-Out mixer amp left and right (volume = 0) */
5786 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5787 /* mute pin widget amp left and right (no gain on this amp) */
5788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5789 /* unmute HP mixer amp left and right (volume = 0) */
5790 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5791 /* mute pin widget amp left and right (no gain on this amp) */
5792 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005793 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5794 * Line In 2 = 0x03
5795 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005796 /* mute analog inputs */
5797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005802 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5803 /* Unmute Front out path */
5804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5805 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5806 /* Unmute Headphone out path */
5807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5808 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5809 /* Unmute Mono out path */
5810 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5811 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5812 { }
5813};
Takashi Iwai474167d2006-05-17 17:17:43 +02005814#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005815
5816static struct hda_verb alc260_hp_3013_init_verbs[] = {
5817 /* Line out and output */
5818 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5819 /* mono output */
5820 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5821 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5822 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5823 /* Mic2 (front panel) pin widget for input and vref at 80% */
5824 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5825 /* Line In pin widget for input */
5826 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5827 /* Headphone pin widget for output */
5828 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5829 /* CD pin widget for input */
5830 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5831 /* unmute amp left and right */
5832 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5833 /* set connection select to line in (default select for this ADC) */
5834 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5835 /* unmute Line-Out mixer amp left and right (volume = 0) */
5836 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5837 /* mute pin widget amp left and right (no gain on this amp) */
5838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5839 /* unmute HP mixer amp left and right (volume = 0) */
5840 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5841 /* mute pin widget amp left and right (no gain on this amp) */
5842 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005843 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5844 * Line In 2 = 0x03
5845 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005846 /* mute analog inputs */
5847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005852 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5853 /* Unmute Front out path */
5854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5855 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5856 /* Unmute Headphone out path */
5857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5859 /* Unmute Mono out path */
5860 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5861 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5862 { }
5863};
5864
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005865/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005866 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5867 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005868 */
5869static struct hda_verb alc260_fujitsu_init_verbs[] = {
5870 /* Disable all GPIOs */
5871 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5872 /* Internal speaker is connected to headphone pin */
5873 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5874 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005876 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5877 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5878 /* Ensure all other unused pins are disabled and muted. */
5879 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5880 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005881 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005882 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005883 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005884 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5885 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005887
Jonathan Woithef7ace402006-02-28 11:46:14 +01005888 /* Disable digital (SPDIF) pins */
5889 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5890 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005891
Kailang Yangea1fb292008-08-26 12:58:38 +02005892 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005893 * when acting as an output.
5894 */
5895 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5896
5897 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005898 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5903 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5905 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5906 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005907
Jonathan Woithef7ace402006-02-28 11:46:14 +01005908 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5909 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5910 /* Unmute Line1 pin widget output buffer since it starts as an output.
5911 * If the pin mode is changed by the user the pin mode control will
5912 * take care of enabling the pin's input/output buffers as needed.
5913 * Therefore there's no need to enable the input buffer at this
5914 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005915 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005917 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005918 * mixer ctrl)
5919 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005920 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005921
Jonathan Woithef7ace402006-02-28 11:46:14 +01005922 /* Mute capture amp left and right */
5923 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005924 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005925 * in (on mic1 pin)
5926 */
5927 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005928
Jonathan Woithef7ace402006-02-28 11:46:14 +01005929 /* Do the same for the second ADC: mute capture input amp and
5930 * set ADC connection to line in (on mic1 pin)
5931 */
5932 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005934
Jonathan Woithef7ace402006-02-28 11:46:14 +01005935 /* Mute all inputs to mixer widget (even unconnected ones) */
5936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005944
5945 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005946};
5947
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005948/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5949 * similar laptops (adapted from Fujitsu init verbs).
5950 */
5951static struct hda_verb alc260_acer_init_verbs[] = {
5952 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5953 * the headphone jack. Turn this on and rely on the standard mute
5954 * methods whenever the user wants to turn these outputs off.
5955 */
5956 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5957 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5958 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5959 /* Internal speaker/Headphone jack is connected to Line-out pin */
5960 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5961 /* Internal microphone/Mic jack is connected to Mic1 pin */
5962 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5963 /* Line In jack is connected to Line1 pin */
5964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005965 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5966 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005967 /* Ensure all other unused pins are disabled and muted. */
5968 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5969 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005970 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5971 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5974 /* Disable digital (SPDIF) pins */
5975 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5976 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5977
Kailang Yangea1fb292008-08-26 12:58:38 +02005978 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005979 * bus when acting as outputs.
5980 */
5981 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5982 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5983
5984 /* Start with output sum widgets muted and their output gains at min */
5985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5987 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5990 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5991 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5992 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5993 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5994
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005995 /* Unmute Line-out pin widget amp left and right
5996 * (no equiv mixer ctrl)
5997 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005998 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005999 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6000 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006001 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6002 * inputs. If the pin mode is changed by the user the pin mode control
6003 * will take care of enabling the pin's input/output buffers as needed.
6004 * Therefore there's no need to enable the input buffer at this
6005 * stage.
6006 */
6007 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6009
6010 /* Mute capture amp left and right */
6011 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6012 /* Set ADC connection select to match default mixer setting - mic
6013 * (on mic1 pin)
6014 */
6015 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6016
6017 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006018 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006019 */
6020 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006021 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006022
6023 /* Mute all inputs to mixer widget (even unconnected ones) */
6024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6032
6033 { }
6034};
6035
Michael Schwingencc959482009-02-22 18:58:45 +01006036/* Initialisation sequence for Maxdata Favorit 100XS
6037 * (adapted from Acer init verbs).
6038 */
6039static struct hda_verb alc260_favorit100_init_verbs[] = {
6040 /* GPIO 0 enables the output jack.
6041 * Turn this on and rely on the standard mute
6042 * methods whenever the user wants to turn these outputs off.
6043 */
6044 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6045 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6046 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6047 /* Line/Mic input jack is connected to Mic1 pin */
6048 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6049 /* Ensure all other unused pins are disabled and muted. */
6050 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6051 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6052 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6053 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6054 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6055 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6057 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6058 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6060 /* Disable digital (SPDIF) pins */
6061 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6062 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6063
6064 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6065 * bus when acting as outputs.
6066 */
6067 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6068 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6069
6070 /* Start with output sum widgets muted and their output gains at min */
6071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6073 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6075 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6077 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6078 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6079 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6080
6081 /* Unmute Line-out pin widget amp left and right
6082 * (no equiv mixer ctrl)
6083 */
6084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6085 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6086 * inputs. If the pin mode is changed by the user the pin mode control
6087 * will take care of enabling the pin's input/output buffers as needed.
6088 * Therefore there's no need to enable the input buffer at this
6089 * stage.
6090 */
6091 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6092
6093 /* Mute capture amp left and right */
6094 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6095 /* Set ADC connection select to match default mixer setting - mic
6096 * (on mic1 pin)
6097 */
6098 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6099
6100 /* Do similar with the second ADC: mute capture input amp and
6101 * set ADC connection to mic to match ALSA's default state.
6102 */
6103 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6104 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6105
6106 /* Mute all inputs to mixer widget (even unconnected ones) */
6107 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6115
6116 { }
6117};
6118
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006119static struct hda_verb alc260_will_verbs[] = {
6120 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6121 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6122 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6123 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6124 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6125 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6126 {}
6127};
6128
6129static struct hda_verb alc260_replacer_672v_verbs[] = {
6130 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6131 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6132 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6133
6134 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6135 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6136 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6137
6138 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6139 {}
6140};
6141
6142/* toggle speaker-output according to the hp-jack state */
6143static void alc260_replacer_672v_automute(struct hda_codec *codec)
6144{
6145 unsigned int present;
6146
6147 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006148 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006149 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006150 snd_hda_codec_write_cache(codec, 0x01, 0,
6151 AC_VERB_SET_GPIO_DATA, 1);
6152 snd_hda_codec_write_cache(codec, 0x0f, 0,
6153 AC_VERB_SET_PIN_WIDGET_CONTROL,
6154 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006155 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006156 snd_hda_codec_write_cache(codec, 0x01, 0,
6157 AC_VERB_SET_GPIO_DATA, 0);
6158 snd_hda_codec_write_cache(codec, 0x0f, 0,
6159 AC_VERB_SET_PIN_WIDGET_CONTROL,
6160 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006161 }
6162}
6163
6164static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6165 unsigned int res)
6166{
6167 if ((res >> 26) == ALC880_HP_EVENT)
6168 alc260_replacer_672v_automute(codec);
6169}
6170
Kailang Yang3f878302008-08-26 13:02:23 +02006171static struct hda_verb alc260_hp_dc7600_verbs[] = {
6172 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6173 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6174 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6175 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6176 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6177 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6178 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6179 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6180 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6181 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6182 {}
6183};
6184
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006185/* Test configuration for debugging, modelled after the ALC880 test
6186 * configuration.
6187 */
6188#ifdef CONFIG_SND_DEBUG
6189static hda_nid_t alc260_test_dac_nids[1] = {
6190 0x02,
6191};
6192static hda_nid_t alc260_test_adc_nids[2] = {
6193 0x04, 0x05,
6194};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006195/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006196 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006197 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006198 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006199static struct hda_input_mux alc260_test_capture_sources[2] = {
6200 {
6201 .num_items = 7,
6202 .items = {
6203 { "MIC1 pin", 0x0 },
6204 { "MIC2 pin", 0x1 },
6205 { "LINE1 pin", 0x2 },
6206 { "LINE2 pin", 0x3 },
6207 { "CD pin", 0x4 },
6208 { "LINE-OUT pin", 0x5 },
6209 { "HP-OUT pin", 0x6 },
6210 },
6211 },
6212 {
6213 .num_items = 8,
6214 .items = {
6215 { "MIC1 pin", 0x0 },
6216 { "MIC2 pin", 0x1 },
6217 { "LINE1 pin", 0x2 },
6218 { "LINE2 pin", 0x3 },
6219 { "CD pin", 0x4 },
6220 { "Mixer", 0x5 },
6221 { "LINE-OUT pin", 0x6 },
6222 { "HP-OUT pin", 0x7 },
6223 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006224 },
6225};
6226static struct snd_kcontrol_new alc260_test_mixer[] = {
6227 /* Output driver widgets */
6228 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6229 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6230 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6231 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6232 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6233 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6234
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006235 /* Modes for retasking pin widgets
6236 * Note: the ALC260 doesn't seem to act on requests to enable mic
6237 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6238 * mention this restriction. At this stage it's not clear whether
6239 * this behaviour is intentional or is a hardware bug in chip
6240 * revisions available at least up until early 2006. Therefore for
6241 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6242 * choices, but if it turns out that the lack of mic bias for these
6243 * NIDs is intentional we could change their modes from
6244 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6245 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006246 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6247 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6248 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6249 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6250 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6251 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6252
6253 /* Loopback mixer controls */
6254 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6255 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6256 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6257 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6258 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6259 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6260 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6261 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6262 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6263 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006264 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6265 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6266 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6267 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006268
6269 /* Controls for GPIO pins, assuming they are configured as outputs */
6270 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6271 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6272 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6273 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6274
Jonathan Woithe92621f12006-02-28 11:47:47 +01006275 /* Switches to allow the digital IO pins to be enabled. The datasheet
6276 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006277 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006278 */
6279 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6280 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6281
Jonathan Woithef8225f62008-01-08 12:16:54 +01006282 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6283 * this output to turn on an external amplifier.
6284 */
6285 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6286 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6287
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006288 { } /* end */
6289};
6290static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006291 /* Enable all GPIOs as outputs with an initial value of 0 */
6292 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6293 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6294 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6295
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006296 /* Enable retasking pins as output, initially without power amp */
6297 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6298 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6300 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6301 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6302 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6303
Jonathan Woithe92621f12006-02-28 11:47:47 +01006304 /* Disable digital (SPDIF) pins initially, but users can enable
6305 * them via a mixer switch. In the case of SPDIF-out, this initverb
6306 * payload also sets the generation to 0, output to be in "consumer"
6307 * PCM format, copyright asserted, no pre-emphasis and no validity
6308 * control.
6309 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006310 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6311 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6312
Kailang Yangea1fb292008-08-26 12:58:38 +02006313 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006314 * OUT1 sum bus when acting as an output.
6315 */
6316 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6317 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6318 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6319 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6320
6321 /* Start with output sum widgets muted and their output gains at min */
6322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6323 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6324 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6325 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6326 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6327 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6328 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6329 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6330 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6331
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006332 /* Unmute retasking pin widget output buffers since the default
6333 * state appears to be output. As the pin mode is changed by the
6334 * user the pin mode control will take care of enabling the pin's
6335 * input/output buffers as needed.
6336 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006337 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6340 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6341 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6342 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6343 /* Also unmute the mono-out pin widget */
6344 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6345
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006346 /* Mute capture amp left and right */
6347 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006348 /* Set ADC connection select to match default mixer setting (mic1
6349 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006350 */
6351 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6352
6353 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006354 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006355 */
6356 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6357 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6358
6359 /* Mute all inputs to mixer widget (even unconnected ones) */
6360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6367 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6368
6369 { }
6370};
6371#endif
6372
Takashi Iwai63300792008-01-24 15:31:36 +01006373#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6374#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006375
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006376#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6377#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6378
Kailang Yangdf694da2005-12-05 19:42:22 +01006379/*
6380 * for BIOS auto-configuration
6381 */
6382
6383static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006384 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006385{
6386 hda_nid_t nid_vol;
6387 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006388 int err;
6389
6390 if (nid >= 0x0f && nid < 0x11) {
6391 nid_vol = nid - 0x7;
6392 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6393 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6394 } else if (nid == 0x11) {
6395 nid_vol = nid - 0x7;
6396 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6397 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6398 } else if (nid >= 0x12 && nid <= 0x15) {
6399 nid_vol = 0x08;
6400 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6401 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6402 } else
6403 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006404
Takashi Iwai863b4512008-10-21 17:01:47 +02006405 if (!(*vol_bits & (1 << nid_vol))) {
6406 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006407 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006408 if (err < 0)
6409 return err;
6410 *vol_bits |= (1 << nid_vol);
6411 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006412 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006413 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006414 return err;
6415 return 1;
6416}
6417
6418/* add playback controls from the parsed DAC table */
6419static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6420 const struct auto_pin_cfg *cfg)
6421{
6422 hda_nid_t nid;
6423 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006424 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006425
6426 spec->multiout.num_dacs = 1;
6427 spec->multiout.dac_nids = spec->private_dac_nids;
6428 spec->multiout.dac_nids[0] = 0x02;
6429
6430 nid = cfg->line_out_pins[0];
6431 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006432 const char *pfx;
6433 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6434 pfx = "Master";
6435 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6436 pfx = "Speaker";
6437 else
6438 pfx = "Front";
6439 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006440 if (err < 0)
6441 return err;
6442 }
6443
Takashi Iwai82bc9552006-03-21 11:24:42 +01006444 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006445 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006446 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006447 if (err < 0)
6448 return err;
6449 }
6450
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006451 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006452 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006453 err = alc260_add_playback_controls(spec, nid, "Headphone",
6454 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006455 if (err < 0)
6456 return err;
6457 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006458 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006459}
6460
6461/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006462static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006463 const struct auto_pin_cfg *cfg)
6464{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006465 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006466}
6467
6468static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6469 hda_nid_t nid, int pin_type,
6470 int sel_idx)
6471{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006472 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006473 /* need the manual connection? */
6474 if (nid >= 0x12) {
6475 int idx = nid - 0x12;
6476 snd_hda_codec_write(codec, idx + 0x0b, 0,
6477 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006478 }
6479}
6480
6481static void alc260_auto_init_multi_out(struct hda_codec *codec)
6482{
6483 struct alc_spec *spec = codec->spec;
6484 hda_nid_t nid;
6485
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006486 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006487 if (nid) {
6488 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6489 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6490 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006491
Takashi Iwai82bc9552006-03-21 11:24:42 +01006492 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006493 if (nid)
6494 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6495
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006496 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006497 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006498 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006499}
Kailang Yangdf694da2005-12-05 19:42:22 +01006500
6501#define ALC260_PIN_CD_NID 0x16
6502static void alc260_auto_init_analog_input(struct hda_codec *codec)
6503{
6504 struct alc_spec *spec = codec->spec;
6505 int i;
6506
6507 for (i = 0; i < AUTO_PIN_LAST; i++) {
6508 hda_nid_t nid = spec->autocfg.input_pins[i];
6509 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006510 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006511 if (nid != ALC260_PIN_CD_NID &&
6512 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006513 snd_hda_codec_write(codec, nid, 0,
6514 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006515 AMP_OUT_MUTE);
6516 }
6517 }
6518}
6519
Takashi Iwai7f311a42010-04-09 17:32:23 +02006520#define alc260_auto_init_input_src alc880_auto_init_input_src
6521
Kailang Yangdf694da2005-12-05 19:42:22 +01006522/*
6523 * generic initialization of ADC, input mixers and output mixers
6524 */
6525static struct hda_verb alc260_volume_init_verbs[] = {
6526 /*
6527 * Unmute ADC0-1 and set the default input to mic-in
6528 */
6529 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6530 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6531 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6532 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006533
Kailang Yangdf694da2005-12-05 19:42:22 +01006534 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6535 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006536 * Note: PASD motherboards uses the Line In 2 as the input for
6537 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006538 */
6539 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006540 /* mute analog inputs */
6541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006546
6547 /*
6548 * Set up output mixers (0x08 - 0x0a)
6549 */
6550 /* set vol=0 to output mixers */
6551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6552 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6553 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6554 /* set up input amps for analog loopback */
6555 /* Amp Indices: DAC = 0, mixer = 1 */
6556 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6557 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6559 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6560 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6561 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006562
Kailang Yangdf694da2005-12-05 19:42:22 +01006563 { }
6564};
6565
6566static int alc260_parse_auto_config(struct hda_codec *codec)
6567{
6568 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006569 int err;
6570 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6571
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006572 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6573 alc260_ignore);
6574 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006575 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006576 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6577 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006578 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006579 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006580 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006581 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006582 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006583 return err;
6584
6585 spec->multiout.max_channels = 2;
6586
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006587 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006588 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006589 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006590 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006591
Takashi Iwaid88897e2008-10-31 15:01:37 +01006592 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006593
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006594 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006595 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006596
Kailang Yang6227cdc2010-02-25 08:36:52 +01006597 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006598
Kailang Yangdf694da2005-12-05 19:42:22 +01006599 return 1;
6600}
6601
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006602/* additional initialization for auto-configuration model */
6603static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006604{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006605 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006606 alc260_auto_init_multi_out(codec);
6607 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006608 alc260_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006609 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006610 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006611}
6612
Takashi Iwaicb53c622007-08-10 17:21:45 +02006613#ifdef CONFIG_SND_HDA_POWER_SAVE
6614static struct hda_amp_list alc260_loopbacks[] = {
6615 { 0x07, HDA_INPUT, 0 },
6616 { 0x07, HDA_INPUT, 1 },
6617 { 0x07, HDA_INPUT, 2 },
6618 { 0x07, HDA_INPUT, 3 },
6619 { 0x07, HDA_INPUT, 4 },
6620 { } /* end */
6621};
6622#endif
6623
Kailang Yangdf694da2005-12-05 19:42:22 +01006624/*
6625 * ALC260 configurations
6626 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006627static const char *alc260_models[ALC260_MODEL_LAST] = {
6628 [ALC260_BASIC] = "basic",
6629 [ALC260_HP] = "hp",
6630 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006631 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006632 [ALC260_FUJITSU_S702X] = "fujitsu",
6633 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006634 [ALC260_WILL] = "will",
6635 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006636 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006637#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006638 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006639#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006640 [ALC260_AUTO] = "auto",
6641};
6642
6643static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006644 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006645 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006646 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006647 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006648 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006649 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006650 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006651 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006652 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006653 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6654 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6655 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6656 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6657 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6658 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6659 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6660 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6661 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006662 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006663 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006664 {}
6665};
6666
Kailang Yangdf694da2005-12-05 19:42:22 +01006667static struct alc_config_preset alc260_presets[] = {
6668 [ALC260_BASIC] = {
6669 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006670 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006671 .init_verbs = { alc260_init_verbs },
6672 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6673 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006674 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006675 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006676 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6677 .channel_mode = alc260_modes,
6678 .input_mux = &alc260_capture_source,
6679 },
6680 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006681 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006682 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006683 .init_verbs = { alc260_init_verbs,
6684 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006685 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6686 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006687 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6688 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006689 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6690 .channel_mode = alc260_modes,
6691 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006692 .unsol_event = alc260_hp_unsol_event,
6693 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006694 },
Kailang Yang3f878302008-08-26 13:02:23 +02006695 [ALC260_HP_DC7600] = {
6696 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006697 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006698 .init_verbs = { alc260_init_verbs,
6699 alc260_hp_dc7600_verbs },
6700 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6701 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006702 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6703 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006704 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6705 .channel_mode = alc260_modes,
6706 .input_mux = &alc260_capture_source,
6707 .unsol_event = alc260_hp_3012_unsol_event,
6708 .init_hook = alc260_hp_3012_automute,
6709 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006710 [ALC260_HP_3013] = {
6711 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006712 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006713 .init_verbs = { alc260_hp_3013_init_verbs,
6714 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006715 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6716 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006717 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6718 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006719 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6720 .channel_mode = alc260_modes,
6721 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006722 .unsol_event = alc260_hp_3013_unsol_event,
6723 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006724 },
6725 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006726 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006727 .init_verbs = { alc260_fujitsu_init_verbs },
6728 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6729 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006730 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6731 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006732 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6733 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006734 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6735 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006736 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006737 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006738 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006739 .init_verbs = { alc260_acer_init_verbs },
6740 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6741 .dac_nids = alc260_dac_nids,
6742 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6743 .adc_nids = alc260_dual_adc_nids,
6744 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6745 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006746 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6747 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006748 },
Michael Schwingencc959482009-02-22 18:58:45 +01006749 [ALC260_FAVORIT100] = {
6750 .mixers = { alc260_favorit100_mixer },
6751 .init_verbs = { alc260_favorit100_init_verbs },
6752 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6753 .dac_nids = alc260_dac_nids,
6754 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6755 .adc_nids = alc260_dual_adc_nids,
6756 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6757 .channel_mode = alc260_modes,
6758 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6759 .input_mux = alc260_favorit100_capture_sources,
6760 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006761 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006762 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006763 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6764 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6765 .dac_nids = alc260_dac_nids,
6766 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6767 .adc_nids = alc260_adc_nids,
6768 .dig_out_nid = ALC260_DIGOUT_NID,
6769 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6770 .channel_mode = alc260_modes,
6771 .input_mux = &alc260_capture_source,
6772 },
6773 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006774 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006775 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6776 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6777 .dac_nids = alc260_dac_nids,
6778 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6779 .adc_nids = alc260_adc_nids,
6780 .dig_out_nid = ALC260_DIGOUT_NID,
6781 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6782 .channel_mode = alc260_modes,
6783 .input_mux = &alc260_capture_source,
6784 .unsol_event = alc260_replacer_672v_unsol_event,
6785 .init_hook = alc260_replacer_672v_automute,
6786 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006787#ifdef CONFIG_SND_DEBUG
6788 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006789 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006790 .init_verbs = { alc260_test_init_verbs },
6791 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6792 .dac_nids = alc260_test_dac_nids,
6793 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6794 .adc_nids = alc260_test_adc_nids,
6795 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6796 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006797 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6798 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006799 },
6800#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006801};
6802
Linus Torvalds1da177e2005-04-16 15:20:36 -07006803static int patch_alc260(struct hda_codec *codec)
6804{
6805 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006806 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006807
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006808 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006809 if (spec == NULL)
6810 return -ENOMEM;
6811
6812 codec->spec = spec;
6813
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006814 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6815 alc260_models,
6816 alc260_cfg_tbl);
6817 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006818 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006819 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006820 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006821 }
6822
Kailang Yangdf694da2005-12-05 19:42:22 +01006823 if (board_config == ALC260_AUTO) {
6824 /* automatic parse from the BIOS config */
6825 err = alc260_parse_auto_config(codec);
6826 if (err < 0) {
6827 alc_free(codec);
6828 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006829 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006830 printk(KERN_INFO
6831 "hda_codec: Cannot set up configuration "
6832 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006833 board_config = ALC260_BASIC;
6834 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006835 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006836
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006837 err = snd_hda_attach_beep_device(codec, 0x1);
6838 if (err < 0) {
6839 alc_free(codec);
6840 return err;
6841 }
6842
Kailang Yangdf694da2005-12-05 19:42:22 +01006843 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006844 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006845
Linus Torvalds1da177e2005-04-16 15:20:36 -07006846 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6847 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6848
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006849 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6850 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6851
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006852 if (!spec->adc_nids && spec->input_mux) {
6853 /* check whether NID 0x04 is valid */
6854 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006855 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006856 /* get type */
6857 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6858 spec->adc_nids = alc260_adc_nids_alt;
6859 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6860 } else {
6861 spec->adc_nids = alc260_adc_nids;
6862 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6863 }
6864 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006865 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006866 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006867
Takashi Iwai2134ea42008-01-10 16:53:55 +01006868 spec->vmaster_nid = 0x08;
6869
Linus Torvalds1da177e2005-04-16 15:20:36 -07006870 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006871 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006872 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006873#ifdef CONFIG_SND_HDA_POWER_SAVE
6874 if (!spec->loopback.amplist)
6875 spec->loopback.amplist = alc260_loopbacks;
6876#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006877
6878 return 0;
6879}
6880
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006881
Linus Torvalds1da177e2005-04-16 15:20:36 -07006882/*
Takashi Iwai49535502009-06-30 15:28:30 +02006883 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006884 *
6885 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6886 * configuration. Each pin widget can choose any input DACs and a mixer.
6887 * Each ADC is connected from a mixer of all inputs. This makes possible
6888 * 6-channel independent captures.
6889 *
6890 * In addition, an independent DAC for the multi-playback (not used in this
6891 * driver yet).
6892 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006893#define ALC882_DIGOUT_NID 0x06
6894#define ALC882_DIGIN_NID 0x0a
Takashi Iwai49535502009-06-30 15:28:30 +02006895#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6896#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6897#define ALC1200_DIGOUT_NID 0x10
6898
Linus Torvalds1da177e2005-04-16 15:20:36 -07006899
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006900static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006901 { 8, NULL }
6902};
6903
Takashi Iwai49535502009-06-30 15:28:30 +02006904/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006905static hda_nid_t alc882_dac_nids[4] = {
6906 /* front, rear, clfe, rear_surr */
6907 0x02, 0x03, 0x04, 0x05
6908};
Takashi Iwai49535502009-06-30 15:28:30 +02006909#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006910
Takashi Iwai49535502009-06-30 15:28:30 +02006911/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006912#define alc882_adc_nids alc880_adc_nids
6913#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai49535502009-06-30 15:28:30 +02006914#define alc883_adc_nids alc882_adc_nids_alt
6915static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6916static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6917#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006918
Takashi Iwaie1406342008-02-11 18:32:32 +01006919static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6920static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai49535502009-06-30 15:28:30 +02006921#define alc883_capsrc_nids alc882_capsrc_nids_alt
6922static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6923#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006924
Linus Torvalds1da177e2005-04-16 15:20:36 -07006925/* input MUX */
6926/* FIXME: should be a matrix-type input source selection */
6927
6928static struct hda_input_mux alc882_capture_source = {
6929 .num_items = 4,
6930 .items = {
6931 { "Mic", 0x0 },
6932 { "Front Mic", 0x1 },
6933 { "Line", 0x2 },
6934 { "CD", 0x4 },
6935 },
6936};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006937
Takashi Iwai49535502009-06-30 15:28:30 +02006938#define alc883_capture_source alc882_capture_source
6939
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006940static struct hda_input_mux alc889_capture_source = {
6941 .num_items = 3,
6942 .items = {
6943 { "Front Mic", 0x0 },
6944 { "Mic", 0x3 },
6945 { "Line", 0x2 },
6946 },
6947};
6948
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006949static struct hda_input_mux mb5_capture_source = {
6950 .num_items = 3,
6951 .items = {
6952 { "Mic", 0x1 },
6953 { "Line", 0x2 },
6954 { "CD", 0x4 },
6955 },
6956};
6957
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006958static struct hda_input_mux macmini3_capture_source = {
6959 .num_items = 2,
6960 .items = {
6961 { "Line", 0x2 },
6962 { "CD", 0x4 },
6963 },
6964};
6965
Takashi Iwai49535502009-06-30 15:28:30 +02006966static struct hda_input_mux alc883_3stack_6ch_intel = {
6967 .num_items = 4,
6968 .items = {
6969 { "Mic", 0x1 },
6970 { "Front Mic", 0x0 },
6971 { "Line", 0x2 },
6972 { "CD", 0x4 },
6973 },
6974};
6975
6976static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6977 .num_items = 2,
6978 .items = {
6979 { "Mic", 0x1 },
6980 { "Line", 0x2 },
6981 },
6982};
6983
6984static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6985 .num_items = 4,
6986 .items = {
6987 { "Mic", 0x0 },
6988 { "iMic", 0x1 },
6989 { "Line", 0x2 },
6990 { "CD", 0x4 },
6991 },
6992};
6993
6994static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6995 .num_items = 2,
6996 .items = {
6997 { "Mic", 0x0 },
6998 { "Int Mic", 0x1 },
6999 },
7000};
7001
7002static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7003 .num_items = 3,
7004 .items = {
7005 { "Mic", 0x0 },
7006 { "Front Mic", 0x1 },
7007 { "Line", 0x4 },
7008 },
7009};
7010
7011static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7012 .num_items = 2,
7013 .items = {
7014 { "Mic", 0x0 },
7015 { "Line", 0x2 },
7016 },
7017};
7018
7019static struct hda_input_mux alc889A_mb31_capture_source = {
7020 .num_items = 2,
7021 .items = {
7022 { "Mic", 0x0 },
7023 /* Front Mic (0x01) unused */
7024 { "Line", 0x2 },
7025 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007026 /* CD (0x04) unused? */
Takashi Iwai49535502009-06-30 15:28:30 +02007027 },
7028};
7029
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007030static struct hda_input_mux alc889A_imac91_capture_source = {
7031 .num_items = 2,
7032 .items = {
7033 { "Mic", 0x01 },
7034 { "Line", 0x2 }, /* Not sure! */
7035 },
7036};
7037
Takashi Iwai49535502009-06-30 15:28:30 +02007038/*
7039 * 2ch mode
7040 */
7041static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7042 { 2, NULL }
7043};
7044
Kailang Yangdf694da2005-12-05 19:42:22 +01007045/*
Kailang Yang272a5272007-05-14 11:00:38 +02007046 * 2ch mode
7047 */
7048static struct hda_verb alc882_3ST_ch2_init[] = {
7049 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7050 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7051 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7052 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7053 { } /* end */
7054};
7055
7056/*
Takashi Iwai49535502009-06-30 15:28:30 +02007057 * 4ch mode
7058 */
7059static struct hda_verb alc882_3ST_ch4_init[] = {
7060 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7061 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7062 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7063 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7064 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7065 { } /* end */
7066};
7067
7068/*
Kailang Yang272a5272007-05-14 11:00:38 +02007069 * 6ch mode
7070 */
7071static struct hda_verb alc882_3ST_ch6_init[] = {
7072 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7073 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7074 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7075 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7076 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7077 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7078 { } /* end */
7079};
7080
Takashi Iwai49535502009-06-30 15:28:30 +02007081static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007082 { 2, alc882_3ST_ch2_init },
Takashi Iwai49535502009-06-30 15:28:30 +02007083 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007084 { 6, alc882_3ST_ch6_init },
7085};
7086
Takashi Iwai49535502009-06-30 15:28:30 +02007087#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7088
Kailang Yang272a5272007-05-14 11:00:38 +02007089/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307090 * 2ch mode
7091 */
7092static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7093 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7094 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7095 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7096 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7097 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7098 { } /* end */
7099};
7100
7101/*
7102 * 4ch mode
7103 */
7104static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7105 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7106 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7107 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7108 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7109 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7110 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7111 { } /* end */
7112};
7113
7114/*
7115 * 6ch mode
7116 */
7117static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7118 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7119 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7120 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7121 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7122 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7123 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7124 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7125 { } /* end */
7126};
7127
7128static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7129 { 2, alc883_3ST_ch2_clevo_init },
7130 { 4, alc883_3ST_ch4_clevo_init },
7131 { 6, alc883_3ST_ch6_clevo_init },
7132};
7133
7134
7135/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007136 * 6ch mode
7137 */
7138static struct hda_verb alc882_sixstack_ch6_init[] = {
7139 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7140 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7141 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7142 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7143 { } /* end */
7144};
7145
7146/*
7147 * 8ch mode
7148 */
7149static struct hda_verb alc882_sixstack_ch8_init[] = {
7150 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7151 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7152 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7153 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7154 { } /* end */
7155};
7156
7157static struct hda_channel_mode alc882_sixstack_modes[2] = {
7158 { 6, alc882_sixstack_ch6_init },
7159 { 8, alc882_sixstack_ch8_init },
7160};
7161
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007162
7163/* Macbook Air 2,1 */
7164
7165static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7166 { 2, NULL },
7167};
7168
Takashi Iwai87350ad2007-08-16 18:19:38 +02007169/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007170 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007171 */
7172
7173/*
7174 * 2ch mode
7175 */
7176static struct hda_verb alc885_mbp_ch2_init[] = {
7177 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7178 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7179 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7180 { } /* end */
7181};
7182
7183/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007184 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007185 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007186static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007187 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7188 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7189 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7190 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7191 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7192 { } /* end */
7193};
7194
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007195static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007196 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007197 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007198};
7199
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007200/*
7201 * 2ch
7202 * Speakers/Woofer/HP = Front
7203 * LineIn = Input
7204 */
7205static struct hda_verb alc885_mb5_ch2_init[] = {
7206 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7207 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7208 { } /* end */
7209};
7210
7211/*
7212 * 6ch mode
7213 * Speakers/HP = Front
7214 * Woofer = LFE
7215 * LineIn = Surround
7216 */
7217static struct hda_verb alc885_mb5_ch6_init[] = {
7218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7221 { } /* end */
7222};
7223
7224static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7225 { 2, alc885_mb5_ch2_init },
7226 { 6, alc885_mb5_ch6_init },
7227};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007228
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007229#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai49535502009-06-30 15:28:30 +02007230
7231/*
7232 * 2ch mode
7233 */
7234static struct hda_verb alc883_4ST_ch2_init[] = {
7235 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7236 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7237 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7238 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7239 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7240 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7241 { } /* end */
7242};
7243
7244/*
7245 * 4ch mode
7246 */
7247static struct hda_verb alc883_4ST_ch4_init[] = {
7248 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7249 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7250 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7251 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7252 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7253 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7254 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7255 { } /* end */
7256};
7257
7258/*
7259 * 6ch mode
7260 */
7261static struct hda_verb alc883_4ST_ch6_init[] = {
7262 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7263 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7264 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7265 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7266 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7267 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7268 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7269 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7270 { } /* end */
7271};
7272
7273/*
7274 * 8ch mode
7275 */
7276static struct hda_verb alc883_4ST_ch8_init[] = {
7277 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7278 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7279 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7280 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7281 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7282 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7283 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7284 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7285 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7286 { } /* end */
7287};
7288
7289static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7290 { 2, alc883_4ST_ch2_init },
7291 { 4, alc883_4ST_ch4_init },
7292 { 6, alc883_4ST_ch6_init },
7293 { 8, alc883_4ST_ch8_init },
7294};
7295
7296
7297/*
7298 * 2ch mode
7299 */
7300static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7301 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7302 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7303 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7304 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7305 { } /* end */
7306};
7307
7308/*
7309 * 4ch mode
7310 */
7311static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7312 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7313 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7314 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7315 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7316 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7317 { } /* end */
7318};
7319
7320/*
7321 * 6ch mode
7322 */
7323static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7324 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7325 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7326 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7327 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7328 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7329 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7330 { } /* end */
7331};
7332
7333static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7334 { 2, alc883_3ST_ch2_intel_init },
7335 { 4, alc883_3ST_ch4_intel_init },
7336 { 6, alc883_3ST_ch6_intel_init },
7337};
7338
7339/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007340 * 2ch mode
7341 */
7342static struct hda_verb alc889_ch2_intel_init[] = {
7343 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7344 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7345 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7346 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7347 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7348 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7349 { } /* end */
7350};
7351
7352/*
Takashi Iwai49535502009-06-30 15:28:30 +02007353 * 6ch mode
7354 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007355static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007356 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7357 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7358 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7359 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7360 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007361 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7362 { } /* end */
7363};
7364
7365/*
7366 * 8ch mode
7367 */
7368static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007369 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7370 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7371 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7372 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7373 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007374 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7375 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007376 { } /* end */
7377};
7378
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007379static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7380 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007381 { 6, alc889_ch6_intel_init },
7382 { 8, alc889_ch8_intel_init },
7383};
7384
7385/*
7386 * 6ch mode
7387 */
Takashi Iwai49535502009-06-30 15:28:30 +02007388static struct hda_verb alc883_sixstack_ch6_init[] = {
7389 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7390 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7391 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7392 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7393 { } /* end */
7394};
7395
7396/*
7397 * 8ch mode
7398 */
7399static struct hda_verb alc883_sixstack_ch8_init[] = {
7400 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7401 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7402 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7403 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7404 { } /* end */
7405};
7406
7407static struct hda_channel_mode alc883_sixstack_modes[2] = {
7408 { 6, alc883_sixstack_ch6_init },
7409 { 8, alc883_sixstack_ch8_init },
7410};
7411
7412
Linus Torvalds1da177e2005-04-16 15:20:36 -07007413/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7414 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7415 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01007416static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007417 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007418 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007419 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007420 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007421 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7422 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007423 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7424 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007425 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007426 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7430 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7431 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007433 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7435 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007436 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007437 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007438 { } /* end */
7439};
7440
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007441/* Macbook Air 2,1 same control for HP and internal Speaker */
7442
7443static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7444 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7445 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7446 { }
7447};
7448
7449
Takashi Iwai87350ad2007-08-16 18:19:38 +02007450static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007451 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7452 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7453 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7454 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7455 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007456 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7457 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7459 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007460 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7462 { } /* end */
7463};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007464
7465static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007466 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7467 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7468 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7469 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7470 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7471 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307472 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7473 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7475 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7477 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7478 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7479 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7480 { } /* end */
7481};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007482
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007483static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7484 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7485 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7486 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7487 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7488 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7489 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7490 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7491 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7493 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7494 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7495 { } /* end */
7496};
7497
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007498static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007499 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7500 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007501 { } /* end */
7502};
7503
7504
Kailang Yangbdd148a2007-05-08 15:19:08 +02007505static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7506 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7507 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7508 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7509 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7510 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7511 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7513 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7514 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007515 { } /* end */
7516};
7517
Kailang Yang272a5272007-05-14 11:00:38 +02007518static struct snd_kcontrol_new alc882_targa_mixer[] = {
7519 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7520 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7521 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7522 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7523 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7524 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7525 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7526 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7527 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007528 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007529 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7530 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007531 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007532 { } /* end */
7533};
7534
7535/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7536 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7537 */
7538static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7539 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7540 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7542 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7543 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7544 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7545 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7546 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7547 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7548 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007551 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007552 { } /* end */
7553};
7554
Takashi Iwai914759b2007-09-06 14:52:04 +02007555static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7556 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7557 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7559 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7560 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7561 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7562 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7564 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7565 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007566 { } /* end */
7567};
7568
Kailang Yangdf694da2005-12-05 19:42:22 +01007569static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7570 {
7571 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7572 .name = "Channel Mode",
7573 .info = alc_ch_mode_info,
7574 .get = alc_ch_mode_get,
7575 .put = alc_ch_mode_put,
7576 },
7577 { } /* end */
7578};
7579
Takashi Iwai49535502009-06-30 15:28:30 +02007580static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007581 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007584 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007587 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7589 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007590 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007591 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007593
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007594 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007596 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007597 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007598 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007600 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007602 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007603 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007604 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007605 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007606 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007607 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007609 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007610 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7613 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7616 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007617 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7619 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7622 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007623 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007624 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007625
7626 /* FIXME: use matrix-type input source selection */
7627 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007628 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007629 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007630 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007631 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007632 /* ADC2: mute amp left and right */
7633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007634 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007635 /* ADC3: mute amp left and right */
7636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007637 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007638
7639 { }
7640};
7641
Takashi Iwai49535502009-06-30 15:28:30 +02007642static struct hda_verb alc882_adc1_init_verbs[] = {
7643 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7644 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7645 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7646 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7647 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7648 /* ADC1: mute amp left and right */
7649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7650 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7651 { }
7652};
7653
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007654static struct hda_verb alc882_eapd_verbs[] = {
7655 /* change to EAPD mode */
7656 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007657 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007658 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007659};
7660
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007661static struct hda_verb alc889_eapd_verbs[] = {
7662 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7663 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7664 { }
7665};
7666
Wu Fengguang6732bd02009-07-30 09:19:14 +02007667static struct hda_verb alc_hp15_unsol_verbs[] = {
7668 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7669 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7670 {}
7671};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007672
7673static struct hda_verb alc885_init_verbs[] = {
7674 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007677 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007678 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007680 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007683 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7685 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007686
7687 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7690 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7691 /* Front Pin: output 0 (0x0c) */
7692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7694 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7695 /* Rear Pin: output 1 (0x0d) */
7696 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7697 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7698 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7699 /* CLFE Pin: output 2 (0x0e) */
7700 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7701 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7702 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7703 /* Side Pin: output 3 (0x0f) */
7704 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7705 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7706 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7707 /* Mic (rear) pin: input vref at 80% */
7708 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7709 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7710 /* Front Mic pin: input vref at 80% */
7711 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7712 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7713 /* Line In pin: input */
7714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7716
7717 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7718 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007720 /* Input mixer2 */
7721 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007722 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007723 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007724 /* ADC2: mute amp left and right */
7725 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7726 /* ADC3: mute amp left and right */
7727 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7728
7729 { }
7730};
7731
7732static struct hda_verb alc885_init_input_verbs[] = {
7733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7736 { }
7737};
7738
7739
7740/* Unmute Selector 24h and set the default input to front mic */
7741static struct hda_verb alc889_init_input_verbs[] = {
7742 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7743 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7744 { }
7745};
7746
7747
Takashi Iwai49535502009-06-30 15:28:30 +02007748#define alc883_init_verbs alc882_base_init_verbs
7749
Tobin Davis9102cd12006-12-15 10:02:12 +01007750/* Mac Pro test */
7751static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7752 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7753 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7754 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7755 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7756 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007757 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007758 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7759 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007760 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007761 { } /* end */
7762};
7763
7764static struct hda_verb alc882_macpro_init_verbs[] = {
7765 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7769 /* Front Pin: output 0 (0x0c) */
7770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7772 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7773 /* Front Mic pin: input vref at 80% */
7774 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7775 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7776 /* Speaker: output */
7777 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7779 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7780 /* Headphone output (output 0 - 0x0c) */
7781 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7782 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7783 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7784
7785 /* FIXME: use matrix-type input source selection */
7786 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7787 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7792 /* Input mixer2 */
7793 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7794 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7797 /* Input mixer3 */
7798 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7799 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7802 /* ADC1: mute amp left and right */
7803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7804 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7805 /* ADC2: mute amp left and right */
7806 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7807 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7808 /* ADC3: mute amp left and right */
7809 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7810 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7811
7812 { }
7813};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007814
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007815/* Macbook 5,1 */
7816static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007817 /* DACs */
7818 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7819 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7820 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7821 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007822 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7824 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7825 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007826 /* Surround mixer */
7827 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7828 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7830 /* LFE mixer */
7831 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7832 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7834 /* HP mixer */
7835 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7836 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7837 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7838 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007841 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7842 /* LFE Pin (0x0e) */
7843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7844 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7845 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7846 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007847 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7848 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007849 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307850 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007851 /* Front Mic pin: input vref at 80% */
7852 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7854 /* Line In pin */
7855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7857
7858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7862 { }
7863};
7864
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007865/* Macmini 3,1 */
7866static struct hda_verb alc885_macmini3_init_verbs[] = {
7867 /* DACs */
7868 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7869 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7870 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7871 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7872 /* Front mixer */
7873 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7874 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7875 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7876 /* Surround mixer */
7877 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7878 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7879 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7880 /* LFE mixer */
7881 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7882 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7884 /* HP mixer */
7885 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7886 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7887 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7888 /* Front Pin (0x0c) */
7889 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7891 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7892 /* LFE Pin (0x0e) */
7893 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7894 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7895 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7896 /* HP Pin (0x0f) */
7897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7898 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7899 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7900 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7901 /* Line In pin */
7902 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7903 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7904
7905 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7906 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7907 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7908 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7909 { }
7910};
7911
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007912
7913static struct hda_verb alc885_mba21_init_verbs[] = {
7914 /*Internal and HP Speaker Mixer*/
7915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7918 /*Internal Speaker Pin (0x0c)*/
7919 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7920 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7921 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7922 /* HP Pin: output 0 (0x0e) */
7923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7925 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7926 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7927 /* Line in (is hp when jack connected)*/
7928 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7929 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7930
7931 { }
7932 };
7933
7934
Takashi Iwai87350ad2007-08-16 18:19:38 +02007935/* Macbook Pro rev3 */
7936static struct hda_verb alc885_mbp3_init_verbs[] = {
7937 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7938 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7939 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7941 /* Rear mixer */
7942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007945 /* HP mixer */
7946 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7947 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7948 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007949 /* Front Pin: output 0 (0x0c) */
7950 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7951 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7952 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007953 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7956 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007957 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7958 /* Mic (rear) pin: input vref at 80% */
7959 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7960 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7961 /* Front Mic pin: input vref at 80% */
7962 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7963 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7964 /* Line In pin: use output 1 when in LineOut mode */
7965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7966 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7967 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7968
7969 /* FIXME: use matrix-type input source selection */
7970 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7971 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7972 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7974 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7975 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7976 /* Input mixer2 */
7977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7979 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7980 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7981 /* Input mixer3 */
7982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7985 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7986 /* ADC1: mute amp left and right */
7987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7988 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7989 /* ADC2: mute amp left and right */
7990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7991 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7992 /* ADC3: mute amp left and right */
7993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7994 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7995
7996 { }
7997};
7998
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007999/* iMac 9,1 */
8000static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008001 /* Internal Speaker Pin (0x0c) */
8002 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8003 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8004 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8005 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8006 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8007 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8008 /* HP Pin: Rear */
8009 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8011 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8012 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8013 /* Line in Rear */
8014 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8015 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8016 /* Front Mic pin: input vref at 80% */
8017 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8018 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008019 /* Rear mixer */
8020 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8022 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008023 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8024 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8027 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8031 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008032 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8034 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8035 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8036 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008037 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008042 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008043 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8044 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008045 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008046 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8047 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008048 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008049 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8050 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008051 { }
8052};
8053
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008054/* iMac 24 mixer. */
8055static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8056 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8057 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8058 { } /* end */
8059};
8060
8061/* iMac 24 init verbs. */
8062static struct hda_verb alc885_imac24_init_verbs[] = {
8063 /* Internal speakers: output 0 (0x0c) */
8064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8066 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8067 /* Internal speakers: output 0 (0x0c) */
8068 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8069 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8070 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8071 /* Headphone: output 0 (0x0c) */
8072 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8073 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8074 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8076 /* Front Mic: input vref at 80% */
8077 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8078 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8079 { }
8080};
8081
8082/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008083static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008084{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008085 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008086
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008087 spec->autocfg.hp_pins[0] = 0x14;
8088 spec->autocfg.speaker_pins[0] = 0x18;
8089 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008090}
8091
Takashi Iwai9d54f082010-02-22 08:34:40 +01008092#define alc885_mb5_setup alc885_imac24_setup
8093#define alc885_macmini3_setup alc885_imac24_setup
8094
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008095/* Macbook Air 2,1 */
8096static void alc885_mba21_setup(struct hda_codec *codec)
8097{
8098 struct alc_spec *spec = codec->spec;
8099
8100 spec->autocfg.hp_pins[0] = 0x14;
8101 spec->autocfg.speaker_pins[0] = 0x18;
8102}
8103
8104
8105
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008106static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008107{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008108 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008109
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008110 spec->autocfg.hp_pins[0] = 0x15;
8111 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008112}
8113
Takashi Iwai9d54f082010-02-22 08:34:40 +01008114static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308115{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008116 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308117
Takashi Iwai9d54f082010-02-22 08:34:40 +01008118 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008119 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008120 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008121}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008122
Kailang Yang272a5272007-05-14 11:00:38 +02008123static struct hda_verb alc882_targa_verbs[] = {
8124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8126
8127 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8128 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008129
Kailang Yang272a5272007-05-14 11:00:38 +02008130 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8131 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8132 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8133
8134 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008135 { } /* end */
8136};
8137
8138/* toggle speaker-output according to the hp-jack state */
8139static void alc882_targa_automute(struct hda_codec *codec)
8140{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008141 struct alc_spec *spec = codec->spec;
8142 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008143 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008144 spec->jack_present ? 1 : 3);
8145}
8146
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008147static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008148{
8149 struct alc_spec *spec = codec->spec;
8150
8151 spec->autocfg.hp_pins[0] = 0x14;
8152 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008153}
8154
8155static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8156{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008157 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008158 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008159}
8160
8161static struct hda_verb alc882_asus_a7j_verbs[] = {
8162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8164
8165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8166 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008168
Kailang Yang272a5272007-05-14 11:00:38 +02008169 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8170 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8171 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8172
8173 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8174 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8175 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8176 { } /* end */
8177};
8178
Takashi Iwai914759b2007-09-06 14:52:04 +02008179static struct hda_verb alc882_asus_a7m_verbs[] = {
8180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8182
8183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8184 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8185 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008186
Takashi Iwai914759b2007-09-06 14:52:04 +02008187 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8188 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8189 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8190
8191 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8192 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8193 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8194 { } /* end */
8195};
8196
Tobin Davis9102cd12006-12-15 10:02:12 +01008197static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8198{
8199 unsigned int gpiostate, gpiomask, gpiodir;
8200
8201 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8202 AC_VERB_GET_GPIO_DATA, 0);
8203
8204 if (!muted)
8205 gpiostate |= (1 << pin);
8206 else
8207 gpiostate &= ~(1 << pin);
8208
8209 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8210 AC_VERB_GET_GPIO_MASK, 0);
8211 gpiomask |= (1 << pin);
8212
8213 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8214 AC_VERB_GET_GPIO_DIRECTION, 0);
8215 gpiodir |= (1 << pin);
8216
8217
8218 snd_hda_codec_write(codec, codec->afg, 0,
8219 AC_VERB_SET_GPIO_MASK, gpiomask);
8220 snd_hda_codec_write(codec, codec->afg, 0,
8221 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8222
8223 msleep(1);
8224
8225 snd_hda_codec_write(codec, codec->afg, 0,
8226 AC_VERB_SET_GPIO_DATA, gpiostate);
8227}
8228
Takashi Iwai7debbe52007-08-16 15:01:03 +02008229/* set up GPIO at initialization */
8230static void alc885_macpro_init_hook(struct hda_codec *codec)
8231{
8232 alc882_gpio_mute(codec, 0, 0);
8233 alc882_gpio_mute(codec, 1, 0);
8234}
8235
8236/* set up GPIO and update auto-muting at initialization */
8237static void alc885_imac24_init_hook(struct hda_codec *codec)
8238{
8239 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008240 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008241}
8242
Kailang Yangdf694da2005-12-05 19:42:22 +01008243/*
8244 * generic initialization of ADC, input mixers and output mixers
8245 */
Takashi Iwai49535502009-06-30 15:28:30 +02008246static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008247 /*
8248 * Unmute ADC0-2 and set the default input to mic-in
8249 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008250 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8251 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8253 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8254
Kailang Yangdf694da2005-12-05 19:42:22 +01008255 /*
8256 * Set up output mixers (0x0c - 0x0f)
8257 */
8258 /* set vol=0 to output mixers */
8259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8260 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8262 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8263 /* set up input amps for analog loopback */
8264 /* Amp Indices: DAC = 0, mixer = 1 */
8265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8267 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8268 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8269 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8270 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8271 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8272 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8273 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8274 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8275
8276 /* FIXME: use matrix-type input source selection */
8277 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008278 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008280 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008281 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008282 { }
8283};
8284
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008285/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8286static struct hda_verb alc889A_mb31_ch2_init[] = {
8287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8288 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8289 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8290 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8291 { } /* end */
8292};
8293
8294/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8295static struct hda_verb alc889A_mb31_ch4_init[] = {
8296 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8297 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8298 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8299 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8300 { } /* end */
8301};
8302
8303/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8304static struct hda_verb alc889A_mb31_ch5_init[] = {
8305 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8307 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8309 { } /* end */
8310};
8311
8312/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8313static struct hda_verb alc889A_mb31_ch6_init[] = {
8314 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8315 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8316 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8317 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8318 { } /* end */
8319};
8320
8321static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8322 { 2, alc889A_mb31_ch2_init },
8323 { 4, alc889A_mb31_ch4_init },
8324 { 5, alc889A_mb31_ch5_init },
8325 { 6, alc889A_mb31_ch6_init },
8326};
8327
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008328static struct hda_verb alc883_medion_eapd_verbs[] = {
8329 /* eanable EAPD on medion laptop */
8330 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8331 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8332 { }
8333};
8334
Takashi Iwai49535502009-06-30 15:28:30 +02008335#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008336
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008337static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8338 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8339 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8340 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8341 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8342 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8343 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8344 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8345 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8346 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8348 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8349 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8350 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008351 { } /* end */
8352};
8353
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008354static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008355 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8356 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8357 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8358 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8360 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8362 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8363 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8364 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008365 { } /* end */
8366};
8367
Jiang zhefb97dc62008-03-06 11:07:11 +01008368static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8369 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8370 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8371 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8372 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8374 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8376 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8377 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8378 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008379 { } /* end */
8380};
8381
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008382static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8383 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8384 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8386 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8387 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8388 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8389 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8390 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008391 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8393 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008394 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008395 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008396 { } /* end */
8397};
8398
8399static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8400 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8401 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8402 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8403 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8404 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8405 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8406 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8407 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8408 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8409 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8410 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8411 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8412 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008414 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008415 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8416 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008417 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008418 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008419 { } /* end */
8420};
8421
Jiang zhe17bba1b2008-06-04 12:11:07 +02008422static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8423 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8424 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8425 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8426 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8427 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8428 HDA_OUTPUT),
8429 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8430 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8431 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8433 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8434 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8435 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8436 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8438 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8439 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8440 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8441 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8442 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008443 { } /* end */
8444};
8445
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008446static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8447 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8448 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8449 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8450 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8451 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8452 HDA_OUTPUT),
8453 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8454 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8455 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8456 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8457 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8459 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8460 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8462 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8464 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8465 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8466 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8467 { } /* end */
8468};
8469
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008470static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008471 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008472 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008473 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008474 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008475 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8476 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008477 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8478 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8480 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8481 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8482 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8483 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008485 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8487 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008488 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008489 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008490 { } /* end */
8491};
8492
Sasha Alexandrc2592492009-06-16 14:52:54 -04008493static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008494 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008495 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008496 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008497 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008498 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8499 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8500 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8501 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8502 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8503 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8504 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8505 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8506 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8507 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008509 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008510 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008511 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008512};
Kailang Yangccc656c2006-10-17 12:32:26 +02008513
Sasha Alexandrc2592492009-06-16 14:52:54 -04008514static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008515 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008516 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008518 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008519 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8520 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008522 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008523 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008524 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8525 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8526 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008527 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008528};
Kailang Yangccc656c2006-10-17 12:32:26 +02008529
Takashi Iwaib99dba32009-09-17 18:23:00 +02008530static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8531 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8532 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8533 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8534 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8535 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8536 { } /* end */
8537};
8538
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008539static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8541 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008542 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8543 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8546 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8547 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008548 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008549};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008550
Kailang Yang272a5272007-05-14 11:00:38 +02008551static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8552 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8553 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8555 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8556 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8559 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8560 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008561 { } /* end */
8562};
8563
8564static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8565 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8566 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8567 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8568 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8569 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8571 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8572 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8573 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008574 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008575};
Kailang Yang272a5272007-05-14 11:00:38 +02008576
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008577static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8578 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8579 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8580 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8581 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8582 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8583 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8584 { } /* end */
8585};
8586
8587static struct hda_verb alc883_medion_wim2160_verbs[] = {
8588 /* Unmute front mixer */
8589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8591
8592 /* Set speaker pin to front mixer */
8593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8594
8595 /* Init headphone pin */
8596 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8597 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8598 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8599 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8600
8601 { } /* end */
8602};
8603
8604/* toggle speaker-output according to the hp-jack state */
8605static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8606{
8607 struct alc_spec *spec = codec->spec;
8608
8609 spec->autocfg.hp_pins[0] = 0x1a;
8610 spec->autocfg.speaker_pins[0] = 0x15;
8611}
8612
Tobin Davis2880a862007-08-07 11:50:26 +02008613static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008614 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8615 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008617 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8618 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8620 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008622 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008623};
Tobin Davis2880a862007-08-07 11:50:26 +02008624
Tony Vroond2fd4b02009-06-21 00:40:10 +01008625static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8626 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008627 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008628 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8629 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008630 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8631 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8633 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8634 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8635 { } /* end */
8636};
8637
Kailang Yange2757d52008-08-26 13:17:46 +02008638static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8639 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8640 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8641 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8642 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8643 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8644 0x0d, 1, 0x0, HDA_OUTPUT),
8645 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8646 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8647 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8648 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8649 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008650 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8651 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8652 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8653 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8655 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8657 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8658 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8659 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008660 { } /* end */
8661};
8662
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008663static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8664 /* Output mixers */
8665 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8666 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8667 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8668 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8669 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8670 HDA_OUTPUT),
8671 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8672 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8673 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8674 /* Output switches */
8675 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8676 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8677 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8678 /* Boost mixers */
8679 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8680 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8681 /* Input mixers */
8682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8684 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8685 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8686 { } /* end */
8687};
8688
Guido Günther3e1647c2009-06-05 00:47:26 +02008689static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8690 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8691 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8692 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8694 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8695 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8696 { } /* end */
8697};
8698
Kailang Yange2757d52008-08-26 13:17:46 +02008699static struct hda_bind_ctls alc883_bind_cap_vol = {
8700 .ops = &snd_hda_bind_vol,
8701 .values = {
8702 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8703 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8704 0
8705 },
8706};
8707
8708static struct hda_bind_ctls alc883_bind_cap_switch = {
8709 .ops = &snd_hda_bind_sw,
8710 .values = {
8711 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8712 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8713 0
8714 },
8715};
8716
8717static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8718 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8719 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8720 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8721 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8722 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8724 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008726 { } /* end */
8727};
8728
8729static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008730 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8731 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8732 {
8733 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8734 /* .name = "Capture Source", */
8735 .name = "Input Source",
8736 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008737 .info = alc_mux_enum_info,
8738 .get = alc_mux_enum_get,
8739 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008740 },
8741 { } /* end */
8742};
8743
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008744static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8745 {
8746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8747 .name = "Channel Mode",
8748 .info = alc_ch_mode_info,
8749 .get = alc_ch_mode_get,
8750 .put = alc_ch_mode_put,
8751 },
8752 { } /* end */
8753};
8754
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008755/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008756static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008757{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008758 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008759
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008760 spec->autocfg.hp_pins[0] = 0x15;
8761 spec->autocfg.speaker_pins[0] = 0x14;
8762 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008763}
8764
8765/* auto-toggle front mic */
8766/*
8767static void alc883_mitac_mic_automute(struct hda_codec *codec)
8768{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008769 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008770
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008771 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8772}
8773*/
8774
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008775static struct hda_verb alc883_mitac_verbs[] = {
8776 /* HP */
8777 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8778 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8779 /* Subwoofer */
8780 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8781 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8782
8783 /* enable unsolicited event */
8784 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8785 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8786
8787 { } /* end */
8788};
8789
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308790static struct hda_verb alc883_clevo_m540r_verbs[] = {
8791 /* HP */
8792 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8793 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8794 /* Int speaker */
8795 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8796
8797 /* enable unsolicited event */
8798 /*
8799 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8800 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8801 */
8802
8803 { } /* end */
8804};
8805
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008806static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008807 /* HP */
8808 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8810 /* Int speaker */
8811 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8812 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8813
8814 /* enable unsolicited event */
8815 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008816 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008817
8818 { } /* end */
8819};
8820
Jiang zhefb97dc62008-03-06 11:07:11 +01008821static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8822 /* HP */
8823 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8824 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8825 /* Subwoofer */
8826 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8828
8829 /* enable unsolicited event */
8830 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8831
8832 { } /* end */
8833};
8834
Sasha Alexandrc2592492009-06-16 14:52:54 -04008835static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8838
8839 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008841
David Heidelberger64a8be72009-06-08 16:15:18 +02008842/* Connect Line-Out side jack (SPDIF) to Side */
8843 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8844 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8845 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8846/* Connect Mic jack to CLFE */
8847 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8848 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8849 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8850/* Connect Line-in jack to Surround */
8851 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8853 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8854/* Connect HP out jack to Front */
8855 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8856 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8857 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008858
8859 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008860
8861 { } /* end */
8862};
8863
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008864static struct hda_verb alc883_lenovo_101e_verbs[] = {
8865 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8866 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8867 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8868 { } /* end */
8869};
8870
Kailang Yang272a5272007-05-14 11:00:38 +02008871static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8872 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8874 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8876 { } /* end */
8877};
8878
8879static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8880 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8883 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8884 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8885 { } /* end */
8886};
8887
Kailang Yang189609a2007-08-20 11:31:23 +02008888static struct hda_verb alc883_haier_w66_verbs[] = {
8889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8891
8892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8893
8894 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8895 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8896 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8897 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8898 { } /* end */
8899};
8900
Kailang Yange2757d52008-08-26 13:17:46 +02008901static struct hda_verb alc888_lenovo_sky_verbs[] = {
8902 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8904 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8905 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8908 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8909 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8910 { } /* end */
8911};
8912
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008913static struct hda_verb alc888_6st_dell_verbs[] = {
8914 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8915 { }
8916};
8917
Guido Günther3e1647c2009-06-05 00:47:26 +02008918static struct hda_verb alc883_vaiott_verbs[] = {
8919 /* HP */
8920 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8922
8923 /* enable unsolicited event */
8924 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8925
8926 { } /* end */
8927};
8928
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008929static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008930{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008931 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008932
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008933 spec->autocfg.hp_pins[0] = 0x1b;
8934 spec->autocfg.speaker_pins[0] = 0x14;
8935 spec->autocfg.speaker_pins[1] = 0x16;
8936 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008937}
8938
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008939static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008940 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008941 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8942 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008943 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008944 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008945};
8946
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008947/*
8948 * 2ch mode
8949 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008950static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008951 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8952 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8953 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8954 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008955 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008956};
8957
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008958/*
8959 * 4ch mode
8960 */
8961static struct hda_verb alc888_3st_hp_4ch_init[] = {
8962 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8963 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8964 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8965 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8966 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8967 { } /* end */
8968};
8969
8970/*
8971 * 6ch mode
8972 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008973static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008974 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8975 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008976 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008977 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8978 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008979 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8980 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008981};
8982
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008983static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008984 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008985 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008986 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008987};
8988
Kailang Yang272a5272007-05-14 11:00:38 +02008989/* toggle front-jack and RCA according to the hp-jack state */
8990static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8991{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008992 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008993
Takashi Iwai47fd8302007-08-10 17:11:07 +02008994 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8995 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8996 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8997 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008998}
8999
9000/* toggle RCA according to the front-jack state */
9001static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9002{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009003 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009004
Takashi Iwai47fd8302007-08-10 17:11:07 +02009005 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9006 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009007}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009008
Kailang Yang272a5272007-05-14 11:00:38 +02009009static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9010 unsigned int res)
9011{
9012 if ((res >> 26) == ALC880_HP_EVENT)
9013 alc888_lenovo_ms7195_front_automute(codec);
9014 if ((res >> 26) == ALC880_FRONT_EVENT)
9015 alc888_lenovo_ms7195_rca_automute(codec);
9016}
9017
9018static struct hda_verb alc883_medion_md2_verbs[] = {
9019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9021
9022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9023
9024 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9025 { } /* end */
9026};
9027
9028/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009029static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009030{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009031 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009032
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009033 spec->autocfg.hp_pins[0] = 0x14;
9034 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009035}
9036
Kailang Yangccc656c2006-10-17 12:32:26 +02009037/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009038#define alc883_targa_init_hook alc882_targa_init_hook
9039#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009040
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009041static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9042{
9043 unsigned int present;
9044
Takashi Iwaid56757a2009-11-18 08:00:14 +01009045 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009046 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9047 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9048}
9049
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009050static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009051{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009052 struct alc_spec *spec = codec->spec;
9053
9054 spec->autocfg.hp_pins[0] = 0x15;
9055 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009056}
9057
9058static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9059{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009060 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009061 alc883_clevo_m720_mic_automute(codec);
9062}
9063
9064static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009065 unsigned int res)
9066{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009067 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009068 case ALC880_MIC_EVENT:
9069 alc883_clevo_m720_mic_automute(codec);
9070 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009071 default:
9072 alc_automute_amp_unsol_event(codec, res);
9073 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009074 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009075}
9076
Jiang zhefb97dc62008-03-06 11:07:11 +01009077/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009078static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009079{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009080 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009081
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009082 spec->autocfg.hp_pins[0] = 0x14;
9083 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009084}
9085
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009086static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009087{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009088 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009089
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009090 spec->autocfg.hp_pins[0] = 0x1b;
9091 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009092}
9093
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009094static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9095{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009096 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009097
Takashi Iwai47fd8302007-08-10 17:11:07 +02009098 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9099 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009100}
9101
9102static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9103{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009104 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009105
Takashi Iwai47fd8302007-08-10 17:11:07 +02009106 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9107 HDA_AMP_MUTE, bits);
9108 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9109 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009110}
9111
9112static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9113 unsigned int res)
9114{
9115 if ((res >> 26) == ALC880_HP_EVENT)
9116 alc883_lenovo_101e_all_automute(codec);
9117 if ((res >> 26) == ALC880_FRONT_EVENT)
9118 alc883_lenovo_101e_ispeaker_automute(codec);
9119}
9120
Takashi Iwai676a9b52007-08-16 15:23:35 +02009121/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009122static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009123{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009124 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009125
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009126 spec->autocfg.hp_pins[0] = 0x14;
9127 spec->autocfg.speaker_pins[0] = 0x15;
9128 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009129}
9130
Kailang Yangd1a991a2007-08-15 16:21:59 +02009131static struct hda_verb alc883_acer_eapd_verbs[] = {
9132 /* HP Pin: output 0 (0x0c) */
9133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9135 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9136 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9138 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009139 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009140 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9141 /* eanable EAPD on medion laptop */
9142 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9143 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009144 /* enable unsolicited event */
9145 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009146 { }
9147};
9148
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009149static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9150 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9151 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9152 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9153 { } /* end */
9154};
9155
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009156static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009157{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009158 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009159
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009160 spec->autocfg.hp_pins[0] = 0x1b;
9161 spec->autocfg.speaker_pins[0] = 0x14;
9162 spec->autocfg.speaker_pins[1] = 0x15;
9163 spec->autocfg.speaker_pins[2] = 0x16;
9164 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009165}
9166
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009167static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009168{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009169 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009170
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009171 spec->autocfg.hp_pins[0] = 0x1b;
9172 spec->autocfg.speaker_pins[0] = 0x14;
9173 spec->autocfg.speaker_pins[1] = 0x15;
9174 spec->autocfg.speaker_pins[2] = 0x16;
9175 spec->autocfg.speaker_pins[3] = 0x17;
9176 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009177}
9178
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009179static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009180{
9181 struct alc_spec *spec = codec->spec;
9182
9183 spec->autocfg.hp_pins[0] = 0x15;
9184 spec->autocfg.speaker_pins[0] = 0x14;
9185 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009186}
9187
Kailang Yange2757d52008-08-26 13:17:46 +02009188static struct hda_verb alc888_asus_m90v_verbs[] = {
9189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9192 /* enable unsolicited event */
9193 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9194 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9195 { } /* end */
9196};
9197
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009198static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009199{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009200 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009201
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009202 spec->autocfg.hp_pins[0] = 0x1b;
9203 spec->autocfg.speaker_pins[0] = 0x14;
9204 spec->autocfg.speaker_pins[1] = 0x15;
9205 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009206 spec->ext_mic.pin = 0x18;
9207 spec->int_mic.pin = 0x19;
9208 spec->ext_mic.mux_idx = 0;
9209 spec->int_mic.mux_idx = 1;
9210 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009211}
9212
9213static struct hda_verb alc888_asus_eee1601_verbs[] = {
9214 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9215 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9218 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9219 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9220 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9221 /* enable unsolicited event */
9222 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9223 { } /* end */
9224};
9225
Kailang Yange2757d52008-08-26 13:17:46 +02009226static void alc883_eee1601_inithook(struct hda_codec *codec)
9227{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009228 struct alc_spec *spec = codec->spec;
9229
9230 spec->autocfg.hp_pins[0] = 0x14;
9231 spec->autocfg.speaker_pins[0] = 0x1b;
9232 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009233}
9234
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009235static struct hda_verb alc889A_mb31_verbs[] = {
9236 /* Init rear pin (used as headphone output) */
9237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9239 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9240 /* Init line pin (used as output in 4ch and 6ch mode) */
9241 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9242 /* Init line 2 pin (used as headphone out by default) */
9243 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9244 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9245 { } /* end */
9246};
9247
9248/* Mute speakers according to the headphone jack state */
9249static void alc889A_mb31_automute(struct hda_codec *codec)
9250{
9251 unsigned int present;
9252
9253 /* Mute only in 2ch or 4ch mode */
9254 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9255 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009256 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009257 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9258 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9259 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9260 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9261 }
9262}
9263
9264static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9265{
9266 if ((res >> 26) == ALC880_HP_EVENT)
9267 alc889A_mb31_automute(codec);
9268}
9269
Takashi Iwai49535502009-06-30 15:28:30 +02009270
Takashi Iwaicb53c622007-08-10 17:21:45 +02009271#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai49535502009-06-30 15:28:30 +02009272#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009273#endif
9274
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009275/* pcm configuration: identical with ALC880 */
Takashi Iwai49535502009-06-30 15:28:30 +02009276#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9277#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9278#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9279#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9280
9281static hda_nid_t alc883_slave_dig_outs[] = {
9282 ALC1200_DIGOUT_NID, 0,
9283};
9284
9285static hda_nid_t alc1200_slave_dig_outs[] = {
9286 ALC883_DIGOUT_NID, 0,
9287};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009288
9289/*
9290 * configuration and preset
9291 */
Takashi Iwai49535502009-06-30 15:28:30 +02009292static const char *alc882_models[ALC882_MODEL_LAST] = {
9293 [ALC882_3ST_DIG] = "3stack-dig",
9294 [ALC882_6ST_DIG] = "6stack-dig",
9295 [ALC882_ARIMA] = "arima",
9296 [ALC882_W2JC] = "w2jc",
9297 [ALC882_TARGA] = "targa",
9298 [ALC882_ASUS_A7J] = "asus-a7j",
9299 [ALC882_ASUS_A7M] = "asus-a7m",
9300 [ALC885_MACPRO] = "macpro",
9301 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009302 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009303 [ALC885_MBA21] = "mba21",
Takashi Iwai49535502009-06-30 15:28:30 +02009304 [ALC885_MBP3] = "mbp3",
9305 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009306 [ALC885_IMAC91] = "imac91",
Takashi Iwai49535502009-06-30 15:28:30 +02009307 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009308 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9309 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai49535502009-06-30 15:28:30 +02009310 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009311 [ALC883_TARGA_DIG] = "targa-dig",
9312 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009313 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009314 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009315 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009316 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009317 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009318 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009319 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009320 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009321 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009322 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009323 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009324 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009325 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9326 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009327 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009328 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009329 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009330 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009331 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309332 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009333 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009334 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009335 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009336 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009337 [ALC889A_INTEL] = "intel-alc889a",
9338 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009339 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009340 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009341 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai49535502009-06-30 15:28:30 +02009342 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009343};
9344
Takashi Iwai49535502009-06-30 15:28:30 +02009345static struct snd_pci_quirk alc882_cfg_tbl[] = {
9346 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9347
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009348 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009349 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009350 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009351 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9352 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009353 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009354 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9355 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009356 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009357 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009358 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9359 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009360 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9361 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai49535502009-06-30 15:28:30 +02009362 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9363 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009364 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009365 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009366 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009367 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009368 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9369 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009370 /* default Acer -- disabled as it causes more problems.
9371 * model=auto should work fine now
9372 */
9373 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai49535502009-06-30 15:28:30 +02009374
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009375 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai49535502009-06-30 15:28:30 +02009376
Tobin Davisfebe3372007-06-12 11:27:46 +02009377 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009378 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9379 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009380 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009381 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009382 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai49535502009-06-30 15:28:30 +02009383
9384 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9385 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9386 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009387 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai49535502009-06-30 15:28:30 +02009388 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9389 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9390 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009391 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009392 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009393 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009394 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai49535502009-06-30 15:28:30 +02009395
9396 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009397 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009398 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009399 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009400 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9401 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009402 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009403 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02009404 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9405
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009406 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9407 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9408 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009409 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009410 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai49535502009-06-30 15:28:30 +02009411 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009412 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009413 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009414 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9415 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9416 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9417 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9418 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9419 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009420 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009421 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9422 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9423 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009424 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009425 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009426 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9427 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009428 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009429 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009430 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009431 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009432 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009433 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009434 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009435 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009436 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009437
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009438 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009439 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009440 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9441 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309442 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009443 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009444 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02009445 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009446 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009447 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009448 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009449 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009450 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009451 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009452 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009453 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9454 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009455 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009456 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009457 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009458 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009459 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai49535502009-06-30 15:28:30 +02009460
Jiang zhe17bba1b2008-06-04 12:11:07 +02009461 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9462 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009463 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009464 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9465 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9466 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009467 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009468
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009469 {}
9470};
9471
Takashi Iwai49535502009-06-30 15:28:30 +02009472/* codec SSID table for Intel Mac */
9473static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9474 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9475 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9476 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9477 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9478 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9479 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9480 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009481 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009482 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009483 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009484 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai49535502009-06-30 15:28:30 +02009485 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9486 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9487 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009488 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai49535502009-06-30 15:28:30 +02009489 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009490 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9491 * so apparently no perfect solution yet
Takashi Iwai49535502009-06-30 15:28:30 +02009492 */
9493 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009494 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009495 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai49535502009-06-30 15:28:30 +02009496 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009497};
9498
Takashi Iwai49535502009-06-30 15:28:30 +02009499static struct alc_config_preset alc882_presets[] = {
9500 [ALC882_3ST_DIG] = {
9501 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009502 .init_verbs = { alc882_base_init_verbs,
9503 alc882_adc1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009504 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9505 .dac_nids = alc882_dac_nids,
9506 .dig_out_nid = ALC882_DIGOUT_NID,
9507 .dig_in_nid = ALC882_DIGIN_NID,
9508 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9509 .channel_mode = alc882_ch_modes,
9510 .need_dac_fix = 1,
9511 .input_mux = &alc882_capture_source,
9512 },
9513 [ALC882_6ST_DIG] = {
9514 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009515 .init_verbs = { alc882_base_init_verbs,
9516 alc882_adc1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009517 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9518 .dac_nids = alc882_dac_nids,
9519 .dig_out_nid = ALC882_DIGOUT_NID,
9520 .dig_in_nid = ALC882_DIGIN_NID,
9521 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9522 .channel_mode = alc882_sixstack_modes,
9523 .input_mux = &alc882_capture_source,
9524 },
9525 [ALC882_ARIMA] = {
9526 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009527 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9528 alc882_eapd_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009529 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9530 .dac_nids = alc882_dac_nids,
9531 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9532 .channel_mode = alc882_sixstack_modes,
9533 .input_mux = &alc882_capture_source,
9534 },
9535 [ALC882_W2JC] = {
9536 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009537 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9538 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009539 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9540 .dac_nids = alc882_dac_nids,
9541 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9542 .channel_mode = alc880_threestack_modes,
9543 .need_dac_fix = 1,
9544 .input_mux = &alc882_capture_source,
9545 .dig_out_nid = ALC882_DIGOUT_NID,
9546 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009547 [ALC885_MBA21] = {
9548 .mixers = { alc885_mba21_mixer },
9549 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9550 .num_dacs = 2,
9551 .dac_nids = alc882_dac_nids,
9552 .channel_mode = alc885_mba21_ch_modes,
9553 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9554 .input_mux = &alc882_capture_source,
9555 .unsol_event = alc_automute_amp_unsol_event,
9556 .setup = alc885_mba21_setup,
9557 .init_hook = alc_automute_amp,
9558 },
Takashi Iwai49535502009-06-30 15:28:30 +02009559 [ALC885_MBP3] = {
9560 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9561 .init_verbs = { alc885_mbp3_init_verbs,
9562 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009563 .num_dacs = 2,
Takashi Iwai49535502009-06-30 15:28:30 +02009564 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009565 .hp_nid = 0x04,
9566 .channel_mode = alc885_mbp_4ch_modes,
9567 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai49535502009-06-30 15:28:30 +02009568 .input_mux = &alc882_capture_source,
9569 .dig_out_nid = ALC882_DIGOUT_NID,
9570 .dig_in_nid = ALC882_DIGIN_NID,
9571 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009572 .setup = alc885_mbp3_setup,
9573 .init_hook = alc_automute_amp,
Takashi Iwai49535502009-06-30 15:28:30 +02009574 },
9575 [ALC885_MB5] = {
9576 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9577 .init_verbs = { alc885_mb5_init_verbs,
9578 alc880_gpio1_init_verbs },
9579 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9580 .dac_nids = alc882_dac_nids,
9581 .channel_mode = alc885_mb5_6ch_modes,
9582 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9583 .input_mux = &mb5_capture_source,
9584 .dig_out_nid = ALC882_DIGOUT_NID,
9585 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009586 .unsol_event = alc_automute_amp_unsol_event,
9587 .setup = alc885_mb5_setup,
9588 .init_hook = alc_automute_amp,
Takashi Iwai49535502009-06-30 15:28:30 +02009589 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009590 [ALC885_MACMINI3] = {
9591 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9592 .init_verbs = { alc885_macmini3_init_verbs,
9593 alc880_gpio1_init_verbs },
9594 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9595 .dac_nids = alc882_dac_nids,
9596 .channel_mode = alc885_macmini3_6ch_modes,
9597 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9598 .input_mux = &macmini3_capture_source,
9599 .dig_out_nid = ALC882_DIGOUT_NID,
9600 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009601 .unsol_event = alc_automute_amp_unsol_event,
9602 .setup = alc885_macmini3_setup,
9603 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009604 },
Takashi Iwai49535502009-06-30 15:28:30 +02009605 [ALC885_MACPRO] = {
9606 .mixers = { alc882_macpro_mixer },
9607 .init_verbs = { alc882_macpro_init_verbs },
9608 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9609 .dac_nids = alc882_dac_nids,
9610 .dig_out_nid = ALC882_DIGOUT_NID,
9611 .dig_in_nid = ALC882_DIGIN_NID,
9612 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9613 .channel_mode = alc882_ch_modes,
9614 .input_mux = &alc882_capture_source,
9615 .init_hook = alc885_macpro_init_hook,
9616 },
9617 [ALC885_IMAC24] = {
9618 .mixers = { alc885_imac24_mixer },
9619 .init_verbs = { alc885_imac24_init_verbs },
9620 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9621 .dac_nids = alc882_dac_nids,
9622 .dig_out_nid = ALC882_DIGOUT_NID,
9623 .dig_in_nid = ALC882_DIGIN_NID,
9624 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9625 .channel_mode = alc882_ch_modes,
9626 .input_mux = &alc882_capture_source,
9627 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009628 .setup = alc885_imac24_setup,
Takashi Iwai49535502009-06-30 15:28:30 +02009629 .init_hook = alc885_imac24_init_hook,
9630 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009631 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009632 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009633 .init_verbs = { alc885_imac91_init_verbs,
9634 alc880_gpio1_init_verbs },
9635 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9636 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009637 .channel_mode = alc885_mba21_ch_modes,
9638 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9639 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009640 .dig_out_nid = ALC882_DIGOUT_NID,
9641 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009642 .unsol_event = alc_automute_amp_unsol_event,
9643 .setup = alc885_imac91_setup,
9644 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009645 },
Takashi Iwai49535502009-06-30 15:28:30 +02009646 [ALC882_TARGA] = {
9647 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009648 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009649 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai49535502009-06-30 15:28:30 +02009650 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9651 .dac_nids = alc882_dac_nids,
9652 .dig_out_nid = ALC882_DIGOUT_NID,
9653 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9654 .adc_nids = alc882_adc_nids,
9655 .capsrc_nids = alc882_capsrc_nids,
9656 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9657 .channel_mode = alc882_3ST_6ch_modes,
9658 .need_dac_fix = 1,
9659 .input_mux = &alc882_capture_source,
9660 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009661 .setup = alc882_targa_setup,
9662 .init_hook = alc882_targa_automute,
Takashi Iwai49535502009-06-30 15:28:30 +02009663 },
9664 [ALC882_ASUS_A7J] = {
9665 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009666 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9667 alc882_asus_a7j_verbs},
Takashi Iwai49535502009-06-30 15:28:30 +02009668 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9669 .dac_nids = alc882_dac_nids,
9670 .dig_out_nid = ALC882_DIGOUT_NID,
9671 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9672 .adc_nids = alc882_adc_nids,
9673 .capsrc_nids = alc882_capsrc_nids,
9674 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9675 .channel_mode = alc882_3ST_6ch_modes,
9676 .need_dac_fix = 1,
9677 .input_mux = &alc882_capture_source,
9678 },
9679 [ALC882_ASUS_A7M] = {
9680 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009681 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9682 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai49535502009-06-30 15:28:30 +02009683 alc882_asus_a7m_verbs },
9684 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9685 .dac_nids = alc882_dac_nids,
9686 .dig_out_nid = ALC882_DIGOUT_NID,
9687 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9688 .channel_mode = alc880_threestack_modes,
9689 .need_dac_fix = 1,
9690 .input_mux = &alc882_capture_source,
9691 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009692 [ALC883_3ST_2ch_DIG] = {
9693 .mixers = { alc883_3ST_2ch_mixer },
9694 .init_verbs = { alc883_init_verbs },
9695 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9696 .dac_nids = alc883_dac_nids,
9697 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009698 .dig_in_nid = ALC883_DIGIN_NID,
9699 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9700 .channel_mode = alc883_3ST_2ch_modes,
9701 .input_mux = &alc883_capture_source,
9702 },
9703 [ALC883_3ST_6ch_DIG] = {
9704 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9705 .init_verbs = { alc883_init_verbs },
9706 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9707 .dac_nids = alc883_dac_nids,
9708 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009709 .dig_in_nid = ALC883_DIGIN_NID,
9710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9711 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009712 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009713 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009714 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009715 [ALC883_3ST_6ch] = {
9716 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9717 .init_verbs = { alc883_init_verbs },
9718 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9719 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009720 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9721 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009722 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009723 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009724 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009725 [ALC883_3ST_6ch_INTEL] = {
9726 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9727 .init_verbs = { alc883_init_verbs },
9728 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9729 .dac_nids = alc883_dac_nids,
9730 .dig_out_nid = ALC883_DIGOUT_NID,
9731 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009732 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009733 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9734 .channel_mode = alc883_3ST_6ch_intel_modes,
9735 .need_dac_fix = 1,
9736 .input_mux = &alc883_3stack_6ch_intel,
9737 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009738 [ALC889A_INTEL] = {
9739 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009740 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9741 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009742 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9743 .dac_nids = alc883_dac_nids,
9744 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9745 .adc_nids = alc889_adc_nids,
9746 .dig_out_nid = ALC883_DIGOUT_NID,
9747 .dig_in_nid = ALC883_DIGIN_NID,
9748 .slave_dig_outs = alc883_slave_dig_outs,
9749 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9750 .channel_mode = alc889_8ch_intel_modes,
9751 .capsrc_nids = alc889_capsrc_nids,
9752 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009753 .setup = alc889_automute_setup,
9754 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009755 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009756 .need_dac_fix = 1,
9757 },
9758 [ALC889_INTEL] = {
9759 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9760 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009761 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009762 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9763 .dac_nids = alc883_dac_nids,
9764 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9765 .adc_nids = alc889_adc_nids,
9766 .dig_out_nid = ALC883_DIGOUT_NID,
9767 .dig_in_nid = ALC883_DIGIN_NID,
9768 .slave_dig_outs = alc883_slave_dig_outs,
9769 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9770 .channel_mode = alc889_8ch_intel_modes,
9771 .capsrc_nids = alc889_capsrc_nids,
9772 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009773 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009774 .init_hook = alc889_intel_init_hook,
9775 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009776 .need_dac_fix = 1,
9777 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009778 [ALC883_6ST_DIG] = {
9779 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9780 .init_verbs = { alc883_init_verbs },
9781 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9782 .dac_nids = alc883_dac_nids,
9783 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009784 .dig_in_nid = ALC883_DIGIN_NID,
9785 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9786 .channel_mode = alc883_sixstack_modes,
9787 .input_mux = &alc883_capture_source,
9788 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009789 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009790 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009791 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9792 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009793 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9794 .dac_nids = alc883_dac_nids,
9795 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009796 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9797 .channel_mode = alc883_3ST_6ch_modes,
9798 .need_dac_fix = 1,
9799 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009800 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009801 .setup = alc882_targa_setup,
9802 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009803 },
9804 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009805 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009806 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9807 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009808 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9809 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009810 .adc_nids = alc883_adc_nids_alt,
9811 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009812 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009813 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009814 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9815 .channel_mode = alc883_3ST_2ch_modes,
9816 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009817 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009818 .setup = alc882_targa_setup,
9819 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009820 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009821 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009822 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9823 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009824 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009825 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009826 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9827 .dac_nids = alc883_dac_nids,
9828 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9829 .adc_nids = alc883_adc_nids_rev,
9830 .capsrc_nids = alc883_capsrc_nids_rev,
9831 .dig_out_nid = ALC883_DIGOUT_NID,
9832 .dig_in_nid = ALC883_DIGIN_NID,
9833 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9834 .channel_mode = alc883_4ST_8ch_modes,
9835 .need_dac_fix = 1,
9836 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009837 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009838 .setup = alc882_targa_setup,
9839 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009840 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009841 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009842 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009843 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9844 * and the headphone jack. Turn this on and rely on the
9845 * standard mute methods whenever the user wants to turn
9846 * these outputs off.
9847 */
9848 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9849 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9850 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009851 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9852 .channel_mode = alc883_3ST_2ch_modes,
9853 .input_mux = &alc883_capture_source,
9854 },
Tobin Davis2880a862007-08-07 11:50:26 +02009855 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009856 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009857 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009858 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9859 .dac_nids = alc883_dac_nids,
9860 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009861 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9862 .channel_mode = alc883_3ST_2ch_modes,
9863 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009864 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009865 .setup = alc883_acer_aspire_setup,
9866 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009867 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009868 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009869 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009870 alc883_chmode_mixer },
9871 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9872 alc888_acer_aspire_4930g_verbs },
9873 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9874 .dac_nids = alc883_dac_nids,
9875 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9876 .adc_nids = alc883_adc_nids_rev,
9877 .capsrc_nids = alc883_capsrc_nids_rev,
9878 .dig_out_nid = ALC883_DIGOUT_NID,
9879 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9880 .channel_mode = alc883_3ST_6ch_modes,
9881 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009882 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009883 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009884 ARRAY_SIZE(alc888_2_capture_sources),
9885 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009886 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009887 .setup = alc888_acer_aspire_4930g_setup,
9888 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009889 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009890 [ALC888_ACER_ASPIRE_6530G] = {
9891 .mixers = { alc888_acer_aspire_6530_mixer },
9892 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9893 alc888_acer_aspire_6530g_verbs },
9894 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9895 .dac_nids = alc883_dac_nids,
9896 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9897 .adc_nids = alc883_adc_nids_rev,
9898 .capsrc_nids = alc883_capsrc_nids_rev,
9899 .dig_out_nid = ALC883_DIGOUT_NID,
9900 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9901 .channel_mode = alc883_3ST_2ch_modes,
9902 .num_mux_defs =
9903 ARRAY_SIZE(alc888_2_capture_sources),
9904 .input_mux = alc888_acer_aspire_6530_sources,
9905 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009906 .setup = alc888_acer_aspire_6530g_setup,
9907 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009908 },
Hector Martin3b315d72009-06-02 10:54:19 +02009909 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009910 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009911 alc883_chmode_mixer },
9912 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009913 alc889_acer_aspire_8930g_verbs,
9914 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009915 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9916 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009917 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9918 .adc_nids = alc889_adc_nids,
9919 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009920 .dig_out_nid = ALC883_DIGOUT_NID,
9921 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9922 .channel_mode = alc883_3ST_6ch_modes,
9923 .need_dac_fix = 1,
9924 .const_channel_count = 6,
9925 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009926 ARRAY_SIZE(alc889_capture_sources),
9927 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009928 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009929 .setup = alc889_acer_aspire_8930g_setup,
9930 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009931#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009932 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009933#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009934 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009935 [ALC888_ACER_ASPIRE_7730G] = {
9936 .mixers = { alc883_3ST_6ch_mixer,
9937 alc883_chmode_mixer },
9938 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9939 alc888_acer_aspire_7730G_verbs },
9940 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9941 .dac_nids = alc883_dac_nids,
9942 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9943 .adc_nids = alc883_adc_nids_rev,
9944 .capsrc_nids = alc883_capsrc_nids_rev,
9945 .dig_out_nid = ALC883_DIGOUT_NID,
9946 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9947 .channel_mode = alc883_3ST_6ch_modes,
9948 .need_dac_fix = 1,
9949 .const_channel_count = 6,
9950 .input_mux = &alc883_capture_source,
9951 .unsol_event = alc_automute_amp_unsol_event,
9952 .setup = alc888_acer_aspire_6530g_setup,
9953 .init_hook = alc_automute_amp,
9954 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009955 [ALC883_MEDION] = {
9956 .mixers = { alc883_fivestack_mixer,
9957 alc883_chmode_mixer },
9958 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009959 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009960 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9961 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009962 .adc_nids = alc883_adc_nids_alt,
9963 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009964 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009965 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9966 .channel_mode = alc883_sixstack_modes,
9967 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009968 },
Kailang Yang272a5272007-05-14 11:00:38 +02009969 [ALC883_MEDION_MD2] = {
9970 .mixers = { alc883_medion_md2_mixer},
9971 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9972 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9973 .dac_nids = alc883_dac_nids,
9974 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009975 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9976 .channel_mode = alc883_3ST_2ch_modes,
9977 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009978 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009979 .setup = alc883_medion_md2_setup,
9980 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009981 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009982 [ALC883_MEDION_WIM2160] = {
9983 .mixers = { alc883_medion_wim2160_mixer },
9984 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
9985 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9986 .dac_nids = alc883_dac_nids,
9987 .dig_out_nid = ALC883_DIGOUT_NID,
9988 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9989 .adc_nids = alc883_adc_nids,
9990 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9991 .channel_mode = alc883_3ST_2ch_modes,
9992 .input_mux = &alc883_capture_source,
9993 .unsol_event = alc_automute_amp_unsol_event,
9994 .setup = alc883_medion_wim2160_setup,
9995 .init_hook = alc_automute_amp,
9996 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009997 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009998 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009999 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10000 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10001 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010002 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10003 .channel_mode = alc883_3ST_2ch_modes,
10004 .input_mux = &alc883_capture_source,
10005 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010006 [ALC883_CLEVO_M540R] = {
10007 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10008 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10009 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10010 .dac_nids = alc883_dac_nids,
10011 .dig_out_nid = ALC883_DIGOUT_NID,
10012 .dig_in_nid = ALC883_DIGIN_NID,
10013 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10014 .channel_mode = alc883_3ST_6ch_clevo_modes,
10015 .need_dac_fix = 1,
10016 .input_mux = &alc883_capture_source,
10017 /* This machine has the hardware HP auto-muting, thus
10018 * we need no software mute via unsol event
10019 */
10020 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010021 [ALC883_CLEVO_M720] = {
10022 .mixers = { alc883_clevo_m720_mixer },
10023 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010024 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10025 .dac_nids = alc883_dac_nids,
10026 .dig_out_nid = ALC883_DIGOUT_NID,
10027 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10028 .channel_mode = alc883_3ST_2ch_modes,
10029 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010030 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010031 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010032 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010033 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010034 [ALC883_LENOVO_101E_2ch] = {
10035 .mixers = { alc883_lenovo_101e_2ch_mixer},
10036 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10037 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10038 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010039 .adc_nids = alc883_adc_nids_alt,
10040 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010041 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010042 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10043 .channel_mode = alc883_3ST_2ch_modes,
10044 .input_mux = &alc883_lenovo_101e_capture_source,
10045 .unsol_event = alc883_lenovo_101e_unsol_event,
10046 .init_hook = alc883_lenovo_101e_all_automute,
10047 },
Kailang Yang272a5272007-05-14 11:00:38 +020010048 [ALC883_LENOVO_NB0763] = {
10049 .mixers = { alc883_lenovo_nb0763_mixer },
10050 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10051 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10052 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010053 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10054 .channel_mode = alc883_3ST_2ch_modes,
10055 .need_dac_fix = 1,
10056 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010057 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010058 .setup = alc883_medion_md2_setup,
10059 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010060 },
10061 [ALC888_LENOVO_MS7195_DIG] = {
10062 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10063 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10064 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10065 .dac_nids = alc883_dac_nids,
10066 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010067 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10068 .channel_mode = alc883_3ST_6ch_modes,
10069 .need_dac_fix = 1,
10070 .input_mux = &alc883_capture_source,
10071 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10072 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010073 },
10074 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010075 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010076 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10077 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10078 .dac_nids = alc883_dac_nids,
10079 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010080 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10081 .channel_mode = alc883_3ST_2ch_modes,
10082 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010083 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010084 .setup = alc883_haier_w66_setup,
10085 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010086 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010087 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010088 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010089 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010090 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10091 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010092 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10093 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010094 .need_dac_fix = 1,
10095 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010096 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010097 .setup = alc888_3st_hp_setup,
10098 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010099 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010100 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010101 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010102 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10103 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10104 .dac_nids = alc883_dac_nids,
10105 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010106 .dig_in_nid = ALC883_DIGIN_NID,
10107 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10108 .channel_mode = alc883_sixstack_modes,
10109 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010110 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010111 .setup = alc888_6st_dell_setup,
10112 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010113 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010114 [ALC883_MITAC] = {
10115 .mixers = { alc883_mitac_mixer },
10116 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10117 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10118 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010119 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10120 .channel_mode = alc883_3ST_2ch_modes,
10121 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010122 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010123 .setup = alc883_mitac_setup,
10124 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010125 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010126 [ALC883_FUJITSU_PI2515] = {
10127 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10128 .init_verbs = { alc883_init_verbs,
10129 alc883_2ch_fujitsu_pi2515_verbs},
10130 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10131 .dac_nids = alc883_dac_nids,
10132 .dig_out_nid = ALC883_DIGOUT_NID,
10133 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10134 .channel_mode = alc883_3ST_2ch_modes,
10135 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010136 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010137 .setup = alc883_2ch_fujitsu_pi2515_setup,
10138 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010139 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010140 [ALC888_FUJITSU_XA3530] = {
10141 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10142 .init_verbs = { alc883_init_verbs,
10143 alc888_fujitsu_xa3530_verbs },
10144 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10145 .dac_nids = alc883_dac_nids,
10146 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10147 .adc_nids = alc883_adc_nids_rev,
10148 .capsrc_nids = alc883_capsrc_nids_rev,
10149 .dig_out_nid = ALC883_DIGOUT_NID,
10150 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10151 .channel_mode = alc888_4ST_8ch_intel_modes,
10152 .num_mux_defs =
10153 ARRAY_SIZE(alc888_2_capture_sources),
10154 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010155 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010156 .setup = alc888_fujitsu_xa3530_setup,
10157 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010158 },
Kailang Yange2757d52008-08-26 13:17:46 +020010159 [ALC888_LENOVO_SKY] = {
10160 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10161 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10162 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10163 .dac_nids = alc883_dac_nids,
10164 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010165 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10166 .channel_mode = alc883_sixstack_modes,
10167 .need_dac_fix = 1,
10168 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010169 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010170 .setup = alc888_lenovo_sky_setup,
10171 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010172 },
10173 [ALC888_ASUS_M90V] = {
10174 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10175 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10176 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10177 .dac_nids = alc883_dac_nids,
10178 .dig_out_nid = ALC883_DIGOUT_NID,
10179 .dig_in_nid = ALC883_DIGIN_NID,
10180 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10181 .channel_mode = alc883_3ST_6ch_modes,
10182 .need_dac_fix = 1,
10183 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010184 .unsol_event = alc_sku_unsol_event,
10185 .setup = alc883_mode2_setup,
10186 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010187 },
10188 [ALC888_ASUS_EEE1601] = {
10189 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010190 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010191 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10192 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10193 .dac_nids = alc883_dac_nids,
10194 .dig_out_nid = ALC883_DIGOUT_NID,
10195 .dig_in_nid = ALC883_DIGIN_NID,
10196 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10197 .channel_mode = alc883_3ST_2ch_modes,
10198 .need_dac_fix = 1,
10199 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010200 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010201 .init_hook = alc883_eee1601_inithook,
10202 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010203 [ALC1200_ASUS_P5Q] = {
10204 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10205 .init_verbs = { alc883_init_verbs },
10206 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10207 .dac_nids = alc883_dac_nids,
10208 .dig_out_nid = ALC1200_DIGOUT_NID,
10209 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010210 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010211 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10212 .channel_mode = alc883_sixstack_modes,
10213 .input_mux = &alc883_capture_source,
10214 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010215 [ALC889A_MB31] = {
10216 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10217 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10218 alc880_gpio1_init_verbs },
10219 .adc_nids = alc883_adc_nids,
10220 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010221 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010222 .dac_nids = alc883_dac_nids,
10223 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10224 .channel_mode = alc889A_mb31_6ch_modes,
10225 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10226 .input_mux = &alc889A_mb31_capture_source,
10227 .dig_out_nid = ALC883_DIGOUT_NID,
10228 .unsol_event = alc889A_mb31_unsol_event,
10229 .init_hook = alc889A_mb31_automute,
10230 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010231 [ALC883_SONY_VAIO_TT] = {
10232 .mixers = { alc883_vaiott_mixer },
10233 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10234 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10235 .dac_nids = alc883_dac_nids,
10236 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10237 .channel_mode = alc883_3ST_2ch_modes,
10238 .input_mux = &alc883_capture_source,
10239 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010240 .setup = alc883_vaiott_setup,
10241 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010242 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010243};
10244
10245
10246/*
Takashi Iwai49535502009-06-30 15:28:30 +020010247 * Pin config fixes
10248 */
10249enum {
10250 PINFIX_ABIT_AW9D_MAX
10251};
10252
10253static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10254 { 0x15, 0x01080104 }, /* side */
10255 { 0x16, 0x01011012 }, /* rear */
10256 { 0x17, 0x01016011 }, /* clfe */
10257 { }
10258};
10259
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010260static const struct alc_fixup alc882_fixups[] = {
10261 [PINFIX_ABIT_AW9D_MAX] = {
10262 .pins = alc882_abit_aw9d_pinfix
10263 },
Takashi Iwai49535502009-06-30 15:28:30 +020010264};
10265
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010266static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai49535502009-06-30 15:28:30 +020010267 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10268 {}
10269};
10270
10271/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010272 * BIOS auto configuration
10273 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010274static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10275 const struct auto_pin_cfg *cfg)
10276{
10277 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10278}
10279
Takashi Iwai49535502009-06-30 15:28:30 +020010280static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010281 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010282 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010283{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010284 int idx;
10285
Takashi Iwai489008c2010-04-07 09:06:00 +020010286 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010287 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010288
Takashi Iwai489008c2010-04-07 09:06:00 +020010289 if (dac == 0x25)
10290 idx = 4;
10291 else if (dac >= 0x02 && dac <= 0x05)
10292 idx = dac - 2;
10293 else
10294 return;
10295 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010296}
10297
Takashi Iwai49535502009-06-30 15:28:30 +020010298static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010299{
10300 struct alc_spec *spec = codec->spec;
10301 int i;
10302
10303 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010304 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010305 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010306 if (nid)
Takashi Iwai49535502009-06-30 15:28:30 +020010307 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010308 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010309 }
10310}
10311
Takashi Iwai49535502009-06-30 15:28:30 +020010312static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010313{
10314 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010315 hda_nid_t pin, dac;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010316
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010317 pin = spec->autocfg.hp_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010318 if (pin) {
10319 dac = spec->multiout.hp_nid;
10320 if (!dac)
10321 dac = spec->multiout.dac_nids[0]; /* to front */
10322 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10323 }
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010324 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010325 if (pin) {
10326 dac = spec->multiout.extra_out_nid[0];
10327 if (!dac)
10328 dac = spec->multiout.dac_nids[0]; /* to front */
10329 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10330 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010331}
10332
Takashi Iwai49535502009-06-30 15:28:30 +020010333static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010334{
10335 struct alc_spec *spec = codec->spec;
10336 int i;
10337
10338 for (i = 0; i < AUTO_PIN_LAST; i++) {
10339 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai49535502009-06-30 15:28:30 +020010340 if (!nid)
10341 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010342 alc_set_input_pin(codec, nid, i);
Takashi Iwai49535502009-06-30 15:28:30 +020010343 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10344 snd_hda_codec_write(codec, nid, 0,
10345 AC_VERB_SET_AMP_GAIN_MUTE,
10346 AMP_OUT_MUTE);
10347 }
10348}
10349
10350static void alc882_auto_init_input_src(struct hda_codec *codec)
10351{
10352 struct alc_spec *spec = codec->spec;
10353 int c;
10354
10355 for (c = 0; c < spec->num_adc_nids; c++) {
10356 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10357 hda_nid_t nid = spec->capsrc_nids[c];
10358 unsigned int mux_idx;
10359 const struct hda_input_mux *imux;
10360 int conns, mute, idx, item;
10361
10362 conns = snd_hda_get_connections(codec, nid, conn_list,
10363 ARRAY_SIZE(conn_list));
10364 if (conns < 0)
10365 continue;
10366 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10367 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010368 if (!imux->num_items && mux_idx > 0)
10369 imux = &spec->input_mux[0];
Takashi Iwai49535502009-06-30 15:28:30 +020010370 for (idx = 0; idx < conns; idx++) {
10371 /* if the current connection is the selected one,
10372 * unmute it as default - otherwise mute it
10373 */
10374 mute = AMP_IN_MUTE(idx);
10375 for (item = 0; item < imux->num_items; item++) {
10376 if (imux->items[item].index == idx) {
10377 if (spec->cur_mux[c] == item)
10378 mute = AMP_IN_UNMUTE(idx);
10379 break;
10380 }
10381 }
10382 /* check if we have a selector or mixer
10383 * we could check for the widget type instead, but
10384 * just check for Amp-In presence (in case of mixer
10385 * without amp-in there is something wrong, this
10386 * function shouldn't be used or capsrc nid is wrong)
10387 */
10388 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010389 snd_hda_codec_write(codec, nid, 0,
10390 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai49535502009-06-30 15:28:30 +020010391 mute);
10392 else if (mute != AMP_IN_MUTE(idx))
10393 snd_hda_codec_write(codec, nid, 0,
10394 AC_VERB_SET_CONNECT_SEL,
10395 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010396 }
10397 }
10398}
10399
Takashi Iwai49535502009-06-30 15:28:30 +020010400/* add mic boosts if needed */
10401static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010402{
10403 struct alc_spec *spec = codec->spec;
Takashi Iwai49535502009-06-30 15:28:30 +020010404 int err;
10405 hda_nid_t nid;
10406
10407 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10408 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10409 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10410 "Mic Boost",
10411 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10412 if (err < 0)
10413 return err;
10414 }
10415 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10416 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10417 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10418 "Front Mic Boost",
10419 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10420 if (err < 0)
10421 return err;
10422 }
10423 return 0;
10424}
10425
10426/* almost identical with ALC880 parser... */
10427static int alc882_parse_auto_config(struct hda_codec *codec)
10428{
10429 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010430 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10431 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010432
Takashi Iwai05f5f472009-08-25 13:10:18 +020010433 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10434 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010435 if (err < 0)
10436 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010437 if (!spec->autocfg.line_outs)
10438 return 0; /* can't find valid BIOS pin config */
10439
10440 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10441 if (err < 0)
10442 return err;
10443 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10444 if (err < 0)
10445 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010446 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10447 "Headphone");
10448 if (err < 0)
10449 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010450 err = alc880_auto_create_extra_out(spec,
10451 spec->autocfg.speaker_pins[0],
10452 "Speaker");
10453 if (err < 0)
10454 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010455 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10456 if (err < 0)
10457 return err;
10458
10459 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10460
10461 /* check multiple SPDIF-out (for recent codecs) */
10462 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10463 hda_nid_t dig_nid;
10464 err = snd_hda_get_connections(codec,
10465 spec->autocfg.dig_out_pins[i],
10466 &dig_nid, 1);
10467 if (err < 0)
10468 continue;
10469 if (!i)
10470 spec->multiout.dig_out_nid = dig_nid;
10471 else {
10472 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010473 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010474 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010475 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010476 }
10477 }
10478 if (spec->autocfg.dig_in_pin)
10479 spec->dig_in_nid = ALC880_DIGIN_NID;
10480
10481 if (spec->kctls.list)
10482 add_mixer(spec, spec->kctls.list);
10483
10484 add_verb(spec, alc883_auto_init_verbs);
10485 /* if ADC 0x07 is available, initialize it, too */
10486 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10487 add_verb(spec, alc882_adc1_init_verbs);
10488
10489 spec->num_mux_defs = 1;
10490 spec->input_mux = &spec->private_imux[0];
10491
Kailang Yang6227cdc2010-02-25 08:36:52 +010010492 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010493
10494 err = alc_auto_add_mic_boost(codec);
10495 if (err < 0)
10496 return err;
10497
Takashi Iwai776e1842007-08-29 15:07:11 +020010498 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010499}
10500
10501/* additional initialization for auto-configuration model */
Takashi Iwai49535502009-06-30 15:28:30 +020010502static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010503{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010504 struct alc_spec *spec = codec->spec;
Takashi Iwai49535502009-06-30 15:28:30 +020010505 alc882_auto_init_multi_out(codec);
10506 alc882_auto_init_hp_out(codec);
10507 alc882_auto_init_analog_input(codec);
10508 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010509 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010510 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010511}
10512
Takashi Iwai49535502009-06-30 15:28:30 +020010513static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010514{
10515 struct alc_spec *spec;
10516 int err, board_config;
10517
10518 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10519 if (spec == NULL)
10520 return -ENOMEM;
10521
10522 codec->spec = spec;
10523
Kailang Yangda00c242010-03-19 11:23:45 +010010524 alc_auto_parse_customize_define(codec);
10525
Takashi Iwai49535502009-06-30 15:28:30 +020010526 switch (codec->vendor_id) {
10527 case 0x10ec0882:
10528 case 0x10ec0885:
10529 break;
10530 default:
10531 /* ALC883 and variants */
10532 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10533 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010534 }
10535
Takashi Iwai49535502009-06-30 15:28:30 +020010536 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10537 alc882_models,
10538 alc882_cfg_tbl);
10539
10540 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10541 board_config = snd_hda_check_board_codec_sid_config(codec,
10542 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10543
10544 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010545 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai49535502009-06-30 15:28:30 +020010546 codec->chip_name);
10547 board_config = ALC882_AUTO;
10548 }
10549
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010550 if (board_config == ALC882_AUTO)
10551 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai49535502009-06-30 15:28:30 +020010552
10553 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010554 /* automatic parse from the BIOS config */
Takashi Iwai49535502009-06-30 15:28:30 +020010555 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010556 if (err < 0) {
10557 alc_free(codec);
10558 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010559 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010560 printk(KERN_INFO
10561 "hda_codec: Cannot set up configuration "
10562 "from BIOS. Using base mode...\n");
Takashi Iwai49535502009-06-30 15:28:30 +020010563 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010564 }
10565 }
10566
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010567 err = snd_hda_attach_beep_device(codec, 0x1);
10568 if (err < 0) {
10569 alc_free(codec);
10570 return err;
10571 }
10572
Takashi Iwai49535502009-06-30 15:28:30 +020010573 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010574 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010575
Takashi Iwai49535502009-06-30 15:28:30 +020010576 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10577 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10578 /* FIXME: setup DAC5 */
10579 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10580 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10581
10582 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10583 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10584
Takashi Iwai49535502009-06-30 15:28:30 +020010585 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010586 int i, j;
Takashi Iwai49535502009-06-30 15:28:30 +020010587 spec->num_adc_nids = 0;
10588 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010589 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai49535502009-06-30 15:28:30 +020010590 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010591 hda_nid_t items[16];
Takashi Iwai49535502009-06-30 15:28:30 +020010592 hda_nid_t nid = alc882_adc_nids[i];
10593 unsigned int wcap = get_wcaps(codec, nid);
10594 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010595 wcap = get_wcaps_type(wcap);
Takashi Iwai49535502009-06-30 15:28:30 +020010596 if (wcap != AC_WID_AUD_IN)
10597 continue;
10598 spec->private_adc_nids[spec->num_adc_nids] = nid;
10599 err = snd_hda_get_connections(codec, nid, &cap, 1);
10600 if (err < 0)
10601 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010602 err = snd_hda_get_connections(codec, cap, items,
10603 ARRAY_SIZE(items));
10604 if (err < 0)
10605 continue;
10606 for (j = 0; j < imux->num_items; j++)
10607 if (imux->items[j].index >= err)
10608 break;
10609 if (j < imux->num_items)
10610 continue;
Takashi Iwai49535502009-06-30 15:28:30 +020010611 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10612 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010613 }
Takashi Iwai49535502009-06-30 15:28:30 +020010614 spec->adc_nids = spec->private_adc_nids;
10615 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010616 }
10617
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010618 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010619
10620 if (spec->cdefine.enable_pcbeep)
10621 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010622
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010623 if (board_config == ALC882_AUTO)
10624 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10625
Takashi Iwai2134ea42008-01-10 16:53:55 +010010626 spec->vmaster_nid = 0x0c;
10627
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010628 codec->patch_ops = alc_patch_ops;
Takashi Iwai49535502009-06-30 15:28:30 +020010629 if (board_config == ALC882_AUTO)
10630 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010631#ifdef CONFIG_SND_HDA_POWER_SAVE
10632 if (!spec->loopback.amplist)
Takashi Iwai49535502009-06-30 15:28:30 +020010633 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010634#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010635
10636 return 0;
10637}
10638
Takashi Iwai49535502009-06-30 15:28:30 +020010639
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010640/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010641 * ALC262 support
10642 */
10643
10644#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10645#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10646
10647#define alc262_dac_nids alc260_dac_nids
10648#define alc262_adc_nids alc882_adc_nids
10649#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010650#define alc262_capsrc_nids alc882_capsrc_nids
10651#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010652
10653#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010654#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010655
Kailang Yang4e555fe2008-08-26 13:05:55 +020010656static hda_nid_t alc262_dmic_adc_nids[1] = {
10657 /* ADC0 */
10658 0x09
10659};
10660
10661static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10662
Kailang Yangdf694da2005-12-05 19:42:22 +010010663static struct snd_kcontrol_new alc262_base_mixer[] = {
10664 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10665 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10666 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10667 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010673 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10674 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010675 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010676 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10678 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10679 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010680 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010681};
10682
Takashi Iwaice875f02008-01-28 18:17:43 +010010683/* update HP, line and mono-out pins according to the master switch */
10684static void alc262_hp_master_update(struct hda_codec *codec)
10685{
10686 struct alc_spec *spec = codec->spec;
10687 int val = spec->master_sw;
10688
10689 /* HP & line-out */
10690 snd_hda_codec_write_cache(codec, 0x1b, 0,
10691 AC_VERB_SET_PIN_WIDGET_CONTROL,
10692 val ? PIN_HP : 0);
10693 snd_hda_codec_write_cache(codec, 0x15, 0,
10694 AC_VERB_SET_PIN_WIDGET_CONTROL,
10695 val ? PIN_HP : 0);
10696 /* mono (speaker) depending on the HP jack sense */
10697 val = val && !spec->jack_present;
10698 snd_hda_codec_write_cache(codec, 0x16, 0,
10699 AC_VERB_SET_PIN_WIDGET_CONTROL,
10700 val ? PIN_OUT : 0);
10701}
10702
10703static void alc262_hp_bpc_automute(struct hda_codec *codec)
10704{
10705 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010706
10707 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010708 alc262_hp_master_update(codec);
10709}
10710
10711static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10712{
10713 if ((res >> 26) != ALC880_HP_EVENT)
10714 return;
10715 alc262_hp_bpc_automute(codec);
10716}
10717
10718static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10719{
10720 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010721
10722 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010723 alc262_hp_master_update(codec);
10724}
10725
10726static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10727 unsigned int res)
10728{
10729 if ((res >> 26) != ALC880_HP_EVENT)
10730 return;
10731 alc262_hp_wildwest_automute(codec);
10732}
10733
Takashi Iwaib72519b2009-05-08 14:31:55 +020010734#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010735
10736static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10737 struct snd_ctl_elem_value *ucontrol)
10738{
10739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10740 struct alc_spec *spec = codec->spec;
10741 int val = !!*ucontrol->value.integer.value;
10742
10743 if (val == spec->master_sw)
10744 return 0;
10745 spec->master_sw = val;
10746 alc262_hp_master_update(codec);
10747 return 1;
10748}
10749
Takashi Iwaib72519b2009-05-08 14:31:55 +020010750#define ALC262_HP_MASTER_SWITCH \
10751 { \
10752 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10753 .name = "Master Playback Switch", \
10754 .info = snd_ctl_boolean_mono_info, \
10755 .get = alc262_hp_master_sw_get, \
10756 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010757 }, \
10758 { \
10759 .iface = NID_MAPPING, \
10760 .name = "Master Playback Switch", \
10761 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010762 }
10763
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010764
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010765static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010766 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010767 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10768 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010770 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10771 HDA_OUTPUT),
10772 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10773 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010777 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10778 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010779 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010780 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10781 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010784 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10785 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10786 { } /* end */
10787};
10788
Kailang Yangcd7509a2007-01-26 18:33:17 +010010789static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010790 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10792 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10793 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10794 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010795 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10796 HDA_OUTPUT),
10797 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10798 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010801 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010802 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10803 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010806 { } /* end */
10807};
10808
10809static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10810 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10811 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010812 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010813 { } /* end */
10814};
10815
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010816/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010817static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010818{
10819 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010820
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010821 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010822 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010823}
10824
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010825static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010826 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10827 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010828 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10831 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10832 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10833 { } /* end */
10834};
10835
10836static struct hda_verb alc262_hp_t5735_verbs[] = {
10837 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10838 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10839
10840 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10841 { }
10842};
10843
Kailang Yang8c427222008-01-10 13:03:59 +010010844static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010845 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010847 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10848 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010849 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10850 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10851 { } /* end */
10852};
10853
10854static struct hda_verb alc262_hp_rp5700_verbs[] = {
10855 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10856 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10857 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10858 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10859 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10860 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10863 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10865 {}
10866};
10867
10868static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10869 .num_items = 1,
10870 .items = {
10871 { "Line", 0x1 },
10872 },
10873};
10874
Takashi Iwai42171c12009-05-08 14:11:43 +020010875/* bind hp and internal speaker mute (with plug check) as master switch */
10876static void alc262_hippo_master_update(struct hda_codec *codec)
10877{
10878 struct alc_spec *spec = codec->spec;
10879 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10880 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10881 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10882 unsigned int mute;
10883
10884 /* HP */
10885 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10886 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10887 HDA_AMP_MUTE, mute);
10888 /* mute internal speaker per jack sense */
10889 if (spec->jack_present)
10890 mute = HDA_AMP_MUTE;
10891 if (line_nid)
10892 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10893 HDA_AMP_MUTE, mute);
10894 if (speaker_nid && speaker_nid != line_nid)
10895 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10896 HDA_AMP_MUTE, mute);
10897}
10898
10899#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10900
10901static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10902 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010903{
10904 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010905 struct alc_spec *spec = codec->spec;
10906 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010907
Takashi Iwai42171c12009-05-08 14:11:43 +020010908 if (val == spec->master_sw)
10909 return 0;
10910 spec->master_sw = val;
10911 alc262_hippo_master_update(codec);
10912 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010913}
Takashi Iwai5b319542007-07-26 11:49:22 +020010914
Takashi Iwai42171c12009-05-08 14:11:43 +020010915#define ALC262_HIPPO_MASTER_SWITCH \
10916 { \
10917 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10918 .name = "Master Playback Switch", \
10919 .info = snd_ctl_boolean_mono_info, \
10920 .get = alc262_hippo_master_sw_get, \
10921 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010922 }, \
10923 { \
10924 .iface = NID_MAPPING, \
10925 .name = "Master Playback Switch", \
10926 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10927 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010928 }
10929
10930static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10931 ALC262_HIPPO_MASTER_SWITCH,
10932 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10933 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10934 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10935 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10936 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10939 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10940 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10941 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10942 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10943 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10944 { } /* end */
10945};
10946
10947static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10948 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10949 ALC262_HIPPO_MASTER_SWITCH,
10950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10956 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10957 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10959 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10960 { } /* end */
10961};
10962
10963/* mute/unmute internal speaker according to the hp jack and mute state */
10964static void alc262_hippo_automute(struct hda_codec *codec)
10965{
10966 struct alc_spec *spec = codec->spec;
10967 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010968
Wu Fengguang864f92b2009-11-18 12:38:02 +080010969 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010970 alc262_hippo_master_update(codec);
10971}
10972
10973static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10974{
10975 if ((res >> 26) != ALC880_HP_EVENT)
10976 return;
10977 alc262_hippo_automute(codec);
10978}
10979
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010980static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010981{
10982 struct alc_spec *spec = codec->spec;
10983
10984 spec->autocfg.hp_pins[0] = 0x15;
10985 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010986}
10987
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010988static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010989{
10990 struct alc_spec *spec = codec->spec;
10991
10992 spec->autocfg.hp_pins[0] = 0x1b;
10993 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010994}
10995
10996
Kailang Yang272a5272007-05-14 11:00:38 +020010997static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010998 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010999 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11002 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11003 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11004 { } /* end */
11005};
11006
Kailang Yang83c34212007-07-05 11:43:05 +020011007static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011008 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11009 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11013 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11014 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11015 { } /* end */
11016};
Kailang Yang272a5272007-05-14 11:00:38 +020011017
Tony Vroonba340e82009-02-02 19:01:30 +000011018static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11019 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11020 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11021 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11022 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11027 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11028 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11030 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11031 { } /* end */
11032};
11033
11034static struct hda_verb alc262_tyan_verbs[] = {
11035 /* Headphone automute */
11036 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11037 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11038 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11039
11040 /* P11 AUX_IN, white 4-pin connector */
11041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11042 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11043 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11044 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11045
11046 {}
11047};
11048
11049/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011050static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011051{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011052 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011053
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011054 spec->autocfg.hp_pins[0] = 0x1b;
11055 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011056}
11057
Tony Vroonba340e82009-02-02 19:01:30 +000011058
Kailang Yangdf694da2005-12-05 19:42:22 +010011059#define alc262_capture_mixer alc882_capture_mixer
11060#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11061
11062/*
11063 * generic initialization of ADC, input mixers and output mixers
11064 */
11065static struct hda_verb alc262_init_verbs[] = {
11066 /*
11067 * Unmute ADC0-2 and set the default input to mic-in
11068 */
11069 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11071 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11073 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11075
Takashi Iwaicb53c622007-08-10 17:21:45 +020011076 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011077 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011078 * Note: PASD motherboards uses the Line In 2 as the input for
11079 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011080 */
11081 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011087
11088 /*
11089 * Set up output mixers (0x0c - 0x0e)
11090 */
11091 /* set vol=0 to output mixers */
11092 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11093 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11095 /* set up input amps for analog loopback */
11096 /* Amp Indices: DAC = 0, mixer = 1 */
11097 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11098 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11099 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11102 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11103
11104 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11105 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11106 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11107 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11108 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11109 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11110
11111 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11113 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11114 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11115 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011116
Kailang Yangdf694da2005-12-05 19:42:22 +010011117 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011119
Kailang Yangdf694da2005-12-05 19:42:22 +010011120 /* FIXME: use matrix-type input source selection */
11121 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11122 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11123 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11124 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11125 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11126 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11127 /* Input mixer2 */
11128 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11129 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11130 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11131 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11132 /* Input mixer3 */
11133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011137
11138 { }
11139};
11140
Kailang Yang4e555fe2008-08-26 13:05:55 +020011141static struct hda_verb alc262_eapd_verbs[] = {
11142 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11143 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11144 { }
11145};
11146
Kailang Yangccc656c2006-10-17 12:32:26 +020011147static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11148 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11149 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11150 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11151
11152 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11153 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11154 {}
11155};
11156
Kailang Yang272a5272007-05-14 11:00:38 +020011157static struct hda_verb alc262_sony_unsol_verbs[] = {
11158 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11159 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11160 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11161
11162 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011164 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011165};
11166
Kailang Yang4e555fe2008-08-26 13:05:55 +020011167static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11168 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11169 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11171 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11172 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011173 { } /* end */
11174};
11175
11176static struct hda_verb alc262_toshiba_s06_verbs[] = {
11177 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11180 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11181 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11182 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11183 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11184 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11185 {}
11186};
11187
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011188static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011189{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011190 struct alc_spec *spec = codec->spec;
11191
11192 spec->autocfg.hp_pins[0] = 0x15;
11193 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011194 spec->ext_mic.pin = 0x18;
11195 spec->ext_mic.mux_idx = 0;
11196 spec->int_mic.pin = 0x12;
11197 spec->int_mic.mux_idx = 9;
11198 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011199}
11200
Takashi Iwai834be882006-03-01 14:16:17 +010011201/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011202 * nec model
11203 * 0x15 = headphone
11204 * 0x16 = internal speaker
11205 * 0x18 = external mic
11206 */
11207
11208static struct snd_kcontrol_new alc262_nec_mixer[] = {
11209 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11210 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11211
11212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11214 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11215
11216 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11218 { } /* end */
11219};
11220
11221static struct hda_verb alc262_nec_verbs[] = {
11222 /* Unmute Speaker */
11223 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11224
11225 /* Headphone */
11226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11228
11229 /* External mic to headphone */
11230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11231 /* External mic to speaker */
11232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11233 {}
11234};
11235
11236/*
Takashi Iwai834be882006-03-01 14:16:17 +010011237 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011238 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11239 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011240 */
11241
11242#define ALC_HP_EVENT 0x37
11243
11244static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11245 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011247 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11248 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011249 {}
11250};
11251
Jiang zhe0e31daf2008-03-20 12:12:39 +010011252static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11253 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11254 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11255 {}
11256};
11257
Daniel T Chene2595322009-12-19 18:19:02 -050011258static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11259 /* Front Mic pin: input vref at 50% */
11260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11262 {}
11263};
11264
Takashi Iwai834be882006-03-01 14:16:17 +010011265static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011266 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011267 .items = {
11268 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011269 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011270 { "CD", 0x4 },
11271 },
11272};
11273
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011274static struct hda_input_mux alc262_HP_capture_source = {
11275 .num_items = 5,
11276 .items = {
11277 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011278 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011279 { "Line", 0x2 },
11280 { "CD", 0x4 },
11281 { "AUX IN", 0x6 },
11282 },
11283};
11284
zhejiangaccbe492007-08-31 12:36:05 +020011285static struct hda_input_mux alc262_HP_D7000_capture_source = {
11286 .num_items = 4,
11287 .items = {
11288 { "Mic", 0x0 },
11289 { "Front Mic", 0x2 },
11290 { "Line", 0x1 },
11291 { "CD", 0x4 },
11292 },
11293};
11294
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011295/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011296static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11297{
11298 struct alc_spec *spec = codec->spec;
11299 unsigned int mute;
11300
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011301 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011302 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11303 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011304 spec->sense_updated = 1;
11305 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011306 /* unmute internal speaker only if both HPs are unplugged and
11307 * master switch is on
11308 */
11309 if (spec->jack_present)
11310 mute = HDA_AMP_MUTE;
11311 else
Takashi Iwai834be882006-03-01 14:16:17 +010011312 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011313 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11314 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011315}
11316
11317/* unsolicited event for HP jack sensing */
11318static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11319 unsigned int res)
11320{
11321 if ((res >> 26) != ALC_HP_EVENT)
11322 return;
11323 alc262_fujitsu_automute(codec, 1);
11324}
11325
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011326static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11327{
11328 alc262_fujitsu_automute(codec, 1);
11329}
11330
Takashi Iwai834be882006-03-01 14:16:17 +010011331/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011332static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11333 .ops = &snd_hda_bind_vol,
11334 .values = {
11335 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11336 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11337 0
11338 },
11339};
Takashi Iwai834be882006-03-01 14:16:17 +010011340
Jiang zhe0e31daf2008-03-20 12:12:39 +010011341/* mute/unmute internal speaker according to the hp jack and mute state */
11342static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11343{
11344 struct alc_spec *spec = codec->spec;
11345 unsigned int mute;
11346
11347 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011348 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011349 spec->sense_updated = 1;
11350 }
11351 if (spec->jack_present) {
11352 /* mute internal speaker */
11353 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11354 HDA_AMP_MUTE, HDA_AMP_MUTE);
11355 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11356 HDA_AMP_MUTE, HDA_AMP_MUTE);
11357 } else {
11358 /* unmute internal speaker if necessary */
11359 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11360 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11361 HDA_AMP_MUTE, mute);
11362 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11363 HDA_AMP_MUTE, mute);
11364 }
11365}
11366
11367/* unsolicited event for HP jack sensing */
11368static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11369 unsigned int res)
11370{
11371 if ((res >> 26) != ALC_HP_EVENT)
11372 return;
11373 alc262_lenovo_3000_automute(codec, 1);
11374}
11375
Takashi Iwai8de56b72009-07-24 16:51:47 +020011376static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11377 int dir, int idx, long *valp)
11378{
11379 int i, change = 0;
11380
11381 for (i = 0; i < 2; i++, valp++)
11382 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11383 HDA_AMP_MUTE,
11384 *valp ? 0 : HDA_AMP_MUTE);
11385 return change;
11386}
11387
Takashi Iwai834be882006-03-01 14:16:17 +010011388/* bind hp and internal speaker mute (with plug check) */
11389static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11390 struct snd_ctl_elem_value *ucontrol)
11391{
11392 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11393 long *valp = ucontrol->value.integer.value;
11394 int change;
11395
Takashi Iwai8de56b72009-07-24 16:51:47 +020011396 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11397 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011398 if (change)
11399 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011400 return change;
11401}
11402
11403static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011404 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011405 {
11406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11407 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011408 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011409 .info = snd_hda_mixer_amp_switch_info,
11410 .get = snd_hda_mixer_amp_switch_get,
11411 .put = alc262_fujitsu_master_sw_put,
11412 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11413 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011414 {
11415 .iface = NID_MAPPING,
11416 .name = "Master Playback Switch",
11417 .private_value = 0x1b,
11418 },
Takashi Iwai834be882006-03-01 14:16:17 +010011419 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11420 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011424 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11425 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11426 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011427 { } /* end */
11428};
11429
Jiang zhe0e31daf2008-03-20 12:12:39 +010011430/* bind hp and internal speaker mute (with plug check) */
11431static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11432 struct snd_ctl_elem_value *ucontrol)
11433{
11434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11435 long *valp = ucontrol->value.integer.value;
11436 int change;
11437
Takashi Iwai8de56b72009-07-24 16:51:47 +020011438 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011439 if (change)
11440 alc262_lenovo_3000_automute(codec, 0);
11441 return change;
11442}
11443
11444static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11445 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11446 {
11447 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11448 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011449 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011450 .info = snd_hda_mixer_amp_switch_info,
11451 .get = snd_hda_mixer_amp_switch_get,
11452 .put = alc262_lenovo_3000_master_sw_put,
11453 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11454 },
11455 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11456 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11457 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11460 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11461 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11462 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11463 { } /* end */
11464};
11465
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011466static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11467 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011468 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11470 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11471 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11472 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11473 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11474 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11475 { } /* end */
11476};
11477
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011478/* additional init verbs for Benq laptops */
11479static struct hda_verb alc262_EAPD_verbs[] = {
11480 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11481 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11482 {}
11483};
11484
Kailang Yang83c34212007-07-05 11:43:05 +020011485static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11486 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11487 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11488
11489 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11490 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11491 {}
11492};
11493
Tobin Davisf651b502007-10-26 12:40:47 +020011494/* Samsung Q1 Ultra Vista model setup */
11495static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011496 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11497 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11499 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11500 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011501 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011502 { } /* end */
11503};
11504
11505static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011506 /* output mixer */
11507 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11508 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11510 /* speaker */
11511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11513 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11514 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11515 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011516 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11519 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11520 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11521 /* internal mic */
11522 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11524 /* ADC, choose mic */
11525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11526 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11527 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11528 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11529 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11530 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11531 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11532 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11533 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11534 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011535 {}
11536};
11537
Tobin Davisf651b502007-10-26 12:40:47 +020011538/* mute/unmute internal speaker according to the hp jack and mute state */
11539static void alc262_ultra_automute(struct hda_codec *codec)
11540{
11541 struct alc_spec *spec = codec->spec;
11542 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011543
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011544 mute = 0;
11545 /* auto-mute only when HP is used as HP */
11546 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011547 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011548 if (spec->jack_present)
11549 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011550 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011551 /* mute/unmute internal speaker */
11552 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11553 HDA_AMP_MUTE, mute);
11554 /* mute/unmute HP */
11555 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11556 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011557}
11558
11559/* unsolicited event for HP jack sensing */
11560static void alc262_ultra_unsol_event(struct hda_codec *codec,
11561 unsigned int res)
11562{
11563 if ((res >> 26) != ALC880_HP_EVENT)
11564 return;
11565 alc262_ultra_automute(codec);
11566}
11567
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011568static struct hda_input_mux alc262_ultra_capture_source = {
11569 .num_items = 2,
11570 .items = {
11571 { "Mic", 0x1 },
11572 { "Headphone", 0x7 },
11573 },
11574};
11575
11576static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11577 struct snd_ctl_elem_value *ucontrol)
11578{
11579 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11580 struct alc_spec *spec = codec->spec;
11581 int ret;
11582
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011583 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011584 if (!ret)
11585 return 0;
11586 /* reprogram the HP pin as mic or HP according to the input source */
11587 snd_hda_codec_write_cache(codec, 0x15, 0,
11588 AC_VERB_SET_PIN_WIDGET_CONTROL,
11589 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11590 alc262_ultra_automute(codec); /* mute/unmute HP */
11591 return ret;
11592}
11593
11594static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11595 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11596 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11597 {
11598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11599 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011600 .info = alc_mux_enum_info,
11601 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011602 .put = alc262_ultra_mux_enum_put,
11603 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011604 {
11605 .iface = NID_MAPPING,
11606 .name = "Capture Source",
11607 .private_value = 0x15,
11608 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011609 { } /* end */
11610};
11611
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011612/* We use two mixers depending on the output pin; 0x16 is a mono output
11613 * and thus it's bound with a different mixer.
11614 * This function returns which mixer amp should be used.
11615 */
11616static int alc262_check_volbit(hda_nid_t nid)
11617{
11618 if (!nid)
11619 return 0;
11620 else if (nid == 0x16)
11621 return 2;
11622 else
11623 return 1;
11624}
11625
11626static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11627 const char *pfx, int *vbits)
11628{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011629 unsigned long val;
11630 int vbit;
11631
11632 vbit = alc262_check_volbit(nid);
11633 if (!vbit)
11634 return 0;
11635 if (*vbits & vbit) /* a volume control for this mixer already there */
11636 return 0;
11637 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011638 if (vbit == 2)
11639 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11640 else
11641 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011642 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011643}
11644
11645static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11646 const char *pfx)
11647{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011648 unsigned long val;
11649
11650 if (!nid)
11651 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011652 if (nid == 0x16)
11653 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11654 else
11655 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011656 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011657}
11658
Kailang Yangdf694da2005-12-05 19:42:22 +010011659/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011660static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11661 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011662{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011663 const char *pfx;
11664 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011665 int err;
11666
11667 spec->multiout.num_dacs = 1; /* only use one dac */
11668 spec->multiout.dac_nids = spec->private_dac_nids;
11669 spec->multiout.dac_nids[0] = 2;
11670
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011671 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11672 pfx = "Master";
11673 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11674 pfx = "Speaker";
11675 else
11676 pfx = "Front";
11677 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11678 if (err < 0)
11679 return err;
11680 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11681 if (err < 0)
11682 return err;
11683 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11684 if (err < 0)
11685 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011686
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011687 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11688 alc262_check_volbit(cfg->speaker_pins[0]) |
11689 alc262_check_volbit(cfg->hp_pins[0]);
11690 if (vbits == 1 || vbits == 2)
11691 pfx = "Master"; /* only one mixer is used */
11692 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11693 pfx = "Speaker";
11694 else
11695 pfx = "Front";
11696 vbits = 0;
11697 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11698 if (err < 0)
11699 return err;
11700 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11701 &vbits);
11702 if (err < 0)
11703 return err;
11704 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11705 &vbits);
11706 if (err < 0)
11707 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011708 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011709}
11710
Takashi Iwai05f5f472009-08-25 13:10:18 +020011711#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011712 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011713
11714/*
11715 * generic initialization of ADC, input mixers and output mixers
11716 */
11717static struct hda_verb alc262_volume_init_verbs[] = {
11718 /*
11719 * Unmute ADC0-2 and set the default input to mic-in
11720 */
11721 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11723 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11724 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11725 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11726 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11727
Takashi Iwaicb53c622007-08-10 17:21:45 +020011728 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011729 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011730 * Note: PASD motherboards uses the Line In 2 as the input for
11731 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011732 */
11733 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011739
11740 /*
11741 * Set up output mixers (0x0c - 0x0f)
11742 */
11743 /* set vol=0 to output mixers */
11744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11746 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011747
Kailang Yangdf694da2005-12-05 19:42:22 +010011748 /* set up input amps for analog loopback */
11749 /* Amp Indices: DAC = 0, mixer = 1 */
11750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11756
11757 /* FIXME: use matrix-type input source selection */
11758 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11759 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11762 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11763 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11764 /* Input mixer2 */
11765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11767 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11768 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11769 /* Input mixer3 */
11770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11774
11775 { }
11776};
11777
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011778static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11779 /*
11780 * Unmute ADC0-2 and set the default input to mic-in
11781 */
11782 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11784 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11786 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11788
Takashi Iwaicb53c622007-08-10 17:21:45 +020011789 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011790 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011791 * Note: PASD motherboards uses the Line In 2 as the input for
11792 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011793 */
11794 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011802
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011803 /*
11804 * Set up output mixers (0x0c - 0x0e)
11805 */
11806 /* set vol=0 to output mixers */
11807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11809 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11810
11811 /* set up input amps for analog loopback */
11812 /* Amp Indices: DAC = 0, mixer = 1 */
11813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11814 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11817 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11818 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11819
Takashi Iwaice875f02008-01-28 18:17:43 +010011820 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011821 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11822 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11823
11824 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11826
11827 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11828 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11829
11830 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11831 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11832 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11834 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11835
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011839 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011840 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11841 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11842
11843
11844 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011845 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11846 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011848 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11849 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11850 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11851 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11852 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11853 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11854 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011856 /* Input mixer2 */
11857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11862 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11863 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11865 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011866 /* Input mixer3 */
11867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011876
Takashi Iwaice875f02008-01-28 18:17:43 +010011877 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11878
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011879 { }
11880};
11881
Kailang Yangcd7509a2007-01-26 18:33:17 +010011882static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11883 /*
11884 * Unmute ADC0-2 and set the default input to mic-in
11885 */
11886 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11888 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11890 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11892
Takashi Iwaicb53c622007-08-10 17:21:45 +020011893 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011894 * mixer widget
11895 * Note: PASD motherboards uses the Line In 2 as the input for front
11896 * panel mic (mic 2)
11897 */
11898 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11903 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011907 /*
11908 * Set up output mixers (0x0c - 0x0e)
11909 */
11910 /* set vol=0 to output mixers */
11911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11912 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11913 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11914
11915 /* set up input amps for analog loopback */
11916 /* Amp Indices: DAC = 0, mixer = 1 */
11917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11923
11924
11925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11926 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11928 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11930 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11931 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11932
11933 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11934 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11935
11936 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11937 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11938
11939 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11940 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11941 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11942 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11943 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11944 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11945
11946 /* FIXME: use matrix-type input source selection */
11947 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11948 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11949 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11950 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11951 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11952 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11953 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11954 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11955 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11956 /* Input mixer2 */
11957 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11958 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11959 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11960 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11961 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11962 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11964 /* Input mixer3 */
11965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11966 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11968 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11970 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11972
Takashi Iwaice875f02008-01-28 18:17:43 +010011973 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11974
Kailang Yangcd7509a2007-01-26 18:33:17 +010011975 { }
11976};
11977
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011978static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11979
11980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11982 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11983
11984 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11986 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11987 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11988
11989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11990 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11991 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11992 {}
11993};
11994
11995
Takashi Iwaicb53c622007-08-10 17:21:45 +020011996#ifdef CONFIG_SND_HDA_POWER_SAVE
11997#define alc262_loopbacks alc880_loopbacks
11998#endif
11999
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012000/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012001#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12002#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12003#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12004#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12005
12006/*
12007 * BIOS auto configuration
12008 */
12009static int alc262_parse_auto_config(struct hda_codec *codec)
12010{
12011 struct alc_spec *spec = codec->spec;
12012 int err;
12013 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12014
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012015 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12016 alc262_ignore);
12017 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012018 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012019 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012020 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012021 spec->multiout.max_channels = 2;
12022 spec->no_analog = 1;
12023 goto dig_only;
12024 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012025 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012026 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012027 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12028 if (err < 0)
12029 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012030 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012031 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012032 return err;
12033
12034 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12035
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012036 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012037 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012038 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012039 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012040 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012041 if (spec->autocfg.dig_in_pin)
12042 spec->dig_in_nid = ALC262_DIGIN_NID;
12043
Takashi Iwai603c4012008-07-30 15:01:44 +020012044 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012045 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012046
Takashi Iwaid88897e2008-10-31 15:01:37 +010012047 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012048 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012049 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012050
Takashi Iwai776e1842007-08-29 15:07:11 +020012051 err = alc_auto_add_mic_boost(codec);
12052 if (err < 0)
12053 return err;
12054
Kailang Yang6227cdc2010-02-25 08:36:52 +010012055 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012056
Kailang Yangdf694da2005-12-05 19:42:22 +010012057 return 1;
12058}
12059
12060#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12061#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12062#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012063#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012064
12065
12066/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012067static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012068{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012069 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012070 alc262_auto_init_multi_out(codec);
12071 alc262_auto_init_hp_out(codec);
12072 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012073 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012074 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012075 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012076}
12077
12078/*
12079 * configuration and preset
12080 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012081static const char *alc262_models[ALC262_MODEL_LAST] = {
12082 [ALC262_BASIC] = "basic",
12083 [ALC262_HIPPO] = "hippo",
12084 [ALC262_HIPPO_1] = "hippo_1",
12085 [ALC262_FUJITSU] = "fujitsu",
12086 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012087 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012088 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012089 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012090 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012091 [ALC262_BENQ_T31] = "benq-t31",
12092 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012093 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012094 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012095 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012096 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012097 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012098 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012099 [ALC262_AUTO] = "auto",
12100};
12101
12102static struct snd_pci_quirk alc262_cfg_tbl[] = {
12103 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012104 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012105 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12106 ALC262_HP_BPC),
12107 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12108 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012109 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12110 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012111 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012112 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012113 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012114 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012115 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012116 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012117 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012118 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012119 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12120 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12121 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012122 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12123 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012124 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012125 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012126 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012127 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012128 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012129 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012130 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012131 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012132#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012133 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12134 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012135#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012136 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012137 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012138 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012139 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012140 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012141 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012142 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12143 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012144 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012145 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012146 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012147 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012148 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012149 {}
12150};
12151
12152static struct alc_config_preset alc262_presets[] = {
12153 [ALC262_BASIC] = {
12154 .mixers = { alc262_base_mixer },
12155 .init_verbs = { alc262_init_verbs },
12156 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12157 .dac_nids = alc262_dac_nids,
12158 .hp_nid = 0x03,
12159 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12160 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012161 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012162 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012163 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012164 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012165 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012166 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12167 .dac_nids = alc262_dac_nids,
12168 .hp_nid = 0x03,
12169 .dig_out_nid = ALC262_DIGOUT_NID,
12170 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12171 .channel_mode = alc262_modes,
12172 .input_mux = &alc262_capture_source,
12173 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012174 .setup = alc262_hippo_setup,
12175 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012176 },
12177 [ALC262_HIPPO_1] = {
12178 .mixers = { alc262_hippo1_mixer },
12179 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12180 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12181 .dac_nids = alc262_dac_nids,
12182 .hp_nid = 0x02,
12183 .dig_out_nid = ALC262_DIGOUT_NID,
12184 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12185 .channel_mode = alc262_modes,
12186 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012187 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012188 .setup = alc262_hippo1_setup,
12189 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012190 },
Takashi Iwai834be882006-03-01 14:16:17 +010012191 [ALC262_FUJITSU] = {
12192 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012193 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12194 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012195 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12196 .dac_nids = alc262_dac_nids,
12197 .hp_nid = 0x03,
12198 .dig_out_nid = ALC262_DIGOUT_NID,
12199 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12200 .channel_mode = alc262_modes,
12201 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012202 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012203 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012204 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012205 [ALC262_HP_BPC] = {
12206 .mixers = { alc262_HP_BPC_mixer },
12207 .init_verbs = { alc262_HP_BPC_init_verbs },
12208 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12209 .dac_nids = alc262_dac_nids,
12210 .hp_nid = 0x03,
12211 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12212 .channel_mode = alc262_modes,
12213 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012214 .unsol_event = alc262_hp_bpc_unsol_event,
12215 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012216 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012217 [ALC262_HP_BPC_D7000_WF] = {
12218 .mixers = { alc262_HP_BPC_WildWest_mixer },
12219 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12220 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12221 .dac_nids = alc262_dac_nids,
12222 .hp_nid = 0x03,
12223 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12224 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012225 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012226 .unsol_event = alc262_hp_wildwest_unsol_event,
12227 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012228 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012229 [ALC262_HP_BPC_D7000_WL] = {
12230 .mixers = { alc262_HP_BPC_WildWest_mixer,
12231 alc262_HP_BPC_WildWest_option_mixer },
12232 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12233 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12234 .dac_nids = alc262_dac_nids,
12235 .hp_nid = 0x03,
12236 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12237 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012238 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012239 .unsol_event = alc262_hp_wildwest_unsol_event,
12240 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012241 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012242 [ALC262_HP_TC_T5735] = {
12243 .mixers = { alc262_hp_t5735_mixer },
12244 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12245 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12246 .dac_nids = alc262_dac_nids,
12247 .hp_nid = 0x03,
12248 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12249 .channel_mode = alc262_modes,
12250 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012251 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012252 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012253 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012254 },
12255 [ALC262_HP_RP5700] = {
12256 .mixers = { alc262_hp_rp5700_mixer },
12257 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12258 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12259 .dac_nids = alc262_dac_nids,
12260 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12261 .channel_mode = alc262_modes,
12262 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012263 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012264 [ALC262_BENQ_ED8] = {
12265 .mixers = { alc262_base_mixer },
12266 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12267 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12268 .dac_nids = alc262_dac_nids,
12269 .hp_nid = 0x03,
12270 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12271 .channel_mode = alc262_modes,
12272 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012273 },
Kailang Yang272a5272007-05-14 11:00:38 +020012274 [ALC262_SONY_ASSAMD] = {
12275 .mixers = { alc262_sony_mixer },
12276 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12277 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12278 .dac_nids = alc262_dac_nids,
12279 .hp_nid = 0x02,
12280 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12281 .channel_mode = alc262_modes,
12282 .input_mux = &alc262_capture_source,
12283 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012284 .setup = alc262_hippo_setup,
12285 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012286 },
12287 [ALC262_BENQ_T31] = {
12288 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012289 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12290 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012291 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12292 .dac_nids = alc262_dac_nids,
12293 .hp_nid = 0x03,
12294 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12295 .channel_mode = alc262_modes,
12296 .input_mux = &alc262_capture_source,
12297 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012298 .setup = alc262_hippo_setup,
12299 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012300 },
Tobin Davisf651b502007-10-26 12:40:47 +020012301 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012302 .mixers = { alc262_ultra_mixer },
12303 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012304 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012305 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12306 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012307 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12308 .channel_mode = alc262_modes,
12309 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012310 .adc_nids = alc262_adc_nids, /* ADC0 */
12311 .capsrc_nids = alc262_capsrc_nids,
12312 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012313 .unsol_event = alc262_ultra_unsol_event,
12314 .init_hook = alc262_ultra_automute,
12315 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012316 [ALC262_LENOVO_3000] = {
12317 .mixers = { alc262_lenovo_3000_mixer },
12318 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012319 alc262_lenovo_3000_unsol_verbs,
12320 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012321 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12322 .dac_nids = alc262_dac_nids,
12323 .hp_nid = 0x03,
12324 .dig_out_nid = ALC262_DIGOUT_NID,
12325 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12326 .channel_mode = alc262_modes,
12327 .input_mux = &alc262_fujitsu_capture_source,
12328 .unsol_event = alc262_lenovo_3000_unsol_event,
12329 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012330 [ALC262_NEC] = {
12331 .mixers = { alc262_nec_mixer },
12332 .init_verbs = { alc262_nec_verbs },
12333 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12334 .dac_nids = alc262_dac_nids,
12335 .hp_nid = 0x03,
12336 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12337 .channel_mode = alc262_modes,
12338 .input_mux = &alc262_capture_source,
12339 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012340 [ALC262_TOSHIBA_S06] = {
12341 .mixers = { alc262_toshiba_s06_mixer },
12342 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12343 alc262_eapd_verbs },
12344 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12345 .capsrc_nids = alc262_dmic_capsrc_nids,
12346 .dac_nids = alc262_dac_nids,
12347 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012348 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012349 .dig_out_nid = ALC262_DIGOUT_NID,
12350 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12351 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012352 .unsol_event = alc_sku_unsol_event,
12353 .setup = alc262_toshiba_s06_setup,
12354 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012355 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012356 [ALC262_TOSHIBA_RX1] = {
12357 .mixers = { alc262_toshiba_rx1_mixer },
12358 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12359 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12360 .dac_nids = alc262_dac_nids,
12361 .hp_nid = 0x03,
12362 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12363 .channel_mode = alc262_modes,
12364 .input_mux = &alc262_capture_source,
12365 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012366 .setup = alc262_hippo_setup,
12367 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012368 },
Tony Vroonba340e82009-02-02 19:01:30 +000012369 [ALC262_TYAN] = {
12370 .mixers = { alc262_tyan_mixer },
12371 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12372 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12373 .dac_nids = alc262_dac_nids,
12374 .hp_nid = 0x02,
12375 .dig_out_nid = ALC262_DIGOUT_NID,
12376 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12377 .channel_mode = alc262_modes,
12378 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012379 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012380 .setup = alc262_tyan_setup,
12381 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012382 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012383};
12384
12385static int patch_alc262(struct hda_codec *codec)
12386{
12387 struct alc_spec *spec;
12388 int board_config;
12389 int err;
12390
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012391 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012392 if (spec == NULL)
12393 return -ENOMEM;
12394
12395 codec->spec = spec;
12396#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012397 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12398 * under-run
12399 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012400 {
12401 int tmp;
12402 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12403 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12404 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12405 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12406 }
12407#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012408 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012409
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012410 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12411
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012412 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12413 alc262_models,
12414 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012415
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012416 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012417 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12418 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012419 board_config = ALC262_AUTO;
12420 }
12421
12422 if (board_config == ALC262_AUTO) {
12423 /* automatic parse from the BIOS config */
12424 err = alc262_parse_auto_config(codec);
12425 if (err < 0) {
12426 alc_free(codec);
12427 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012428 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012429 printk(KERN_INFO
12430 "hda_codec: Cannot set up configuration "
12431 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012432 board_config = ALC262_BASIC;
12433 }
12434 }
12435
Takashi Iwai07eba612009-02-19 08:06:35 +010012436 if (!spec->no_analog) {
12437 err = snd_hda_attach_beep_device(codec, 0x1);
12438 if (err < 0) {
12439 alc_free(codec);
12440 return err;
12441 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012442 }
12443
Kailang Yangdf694da2005-12-05 19:42:22 +010012444 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012445 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012446
Kailang Yangdf694da2005-12-05 19:42:22 +010012447 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12448 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012449
Kailang Yangdf694da2005-12-05 19:42:22 +010012450 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12451 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12452
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012453 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012454 int i;
12455 /* check whether the digital-mic has to be supported */
12456 for (i = 0; i < spec->input_mux->num_items; i++) {
12457 if (spec->input_mux->items[i].index >= 9)
12458 break;
12459 }
12460 if (i < spec->input_mux->num_items) {
12461 /* use only ADC0 */
12462 spec->adc_nids = alc262_dmic_adc_nids;
12463 spec->num_adc_nids = 1;
12464 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012465 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012466 /* all analog inputs */
12467 /* check whether NID 0x07 is valid */
12468 unsigned int wcap = get_wcaps(codec, 0x07);
12469
12470 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012471 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012472 if (wcap != AC_WID_AUD_IN) {
12473 spec->adc_nids = alc262_adc_nids_alt;
12474 spec->num_adc_nids =
12475 ARRAY_SIZE(alc262_adc_nids_alt);
12476 spec->capsrc_nids = alc262_capsrc_nids_alt;
12477 } else {
12478 spec->adc_nids = alc262_adc_nids;
12479 spec->num_adc_nids =
12480 ARRAY_SIZE(alc262_adc_nids);
12481 spec->capsrc_nids = alc262_capsrc_nids;
12482 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012483 }
12484 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012485 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012486 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010012487 if (!spec->no_analog && spec->cdefine.enable_pcbeep)
Takashi Iwai07eba612009-02-19 08:06:35 +010012488 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012489
Takashi Iwai2134ea42008-01-10 16:53:55 +010012490 spec->vmaster_nid = 0x0c;
12491
Kailang Yangdf694da2005-12-05 19:42:22 +010012492 codec->patch_ops = alc_patch_ops;
12493 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012494 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012495#ifdef CONFIG_SND_HDA_POWER_SAVE
12496 if (!spec->loopback.amplist)
12497 spec->loopback.amplist = alc262_loopbacks;
12498#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012499
Kailang Yangdf694da2005-12-05 19:42:22 +010012500 return 0;
12501}
12502
Kailang Yangdf694da2005-12-05 19:42:22 +010012503/*
Kailang Yanga361d842007-06-05 12:30:55 +020012504 * ALC268 channel source setting (2 channel)
12505 */
12506#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12507#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012508
Kailang Yanga361d842007-06-05 12:30:55 +020012509static hda_nid_t alc268_dac_nids[2] = {
12510 /* front, hp */
12511 0x02, 0x03
12512};
12513
12514static hda_nid_t alc268_adc_nids[2] = {
12515 /* ADC0-1 */
12516 0x08, 0x07
12517};
12518
12519static hda_nid_t alc268_adc_nids_alt[1] = {
12520 /* ADC0 */
12521 0x08
12522};
12523
Takashi Iwaie1406342008-02-11 18:32:32 +010012524static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12525
Kailang Yanga361d842007-06-05 12:30:55 +020012526static struct snd_kcontrol_new alc268_base_mixer[] = {
12527 /* output mixer control */
12528 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12529 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12530 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012532 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12533 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12534 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012535 { }
12536};
12537
Takashi Iwai42171c12009-05-08 14:11:43 +020012538static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12539 /* output mixer control */
12540 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12541 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12542 ALC262_HIPPO_MASTER_SWITCH,
12543 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12544 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12545 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12546 { }
12547};
12548
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012549/* bind Beep switches of both NID 0x0f and 0x10 */
12550static struct hda_bind_ctls alc268_bind_beep_sw = {
12551 .ops = &snd_hda_bind_sw,
12552 .values = {
12553 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12554 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12555 0
12556 },
12557};
12558
12559static struct snd_kcontrol_new alc268_beep_mixer[] = {
12560 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12561 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12562 { }
12563};
12564
Kailang Yangd1a991a2007-08-15 16:21:59 +020012565static struct hda_verb alc268_eapd_verbs[] = {
12566 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12567 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12568 { }
12569};
12570
Takashi Iwaid2738092007-08-16 14:59:45 +020012571/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012572static struct hda_verb alc268_toshiba_verbs[] = {
12573 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12574 { } /* end */
12575};
12576
12577/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012578/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012579static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12580 .ops = &snd_hda_bind_vol,
12581 .values = {
12582 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12583 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12584 0
12585 },
12586};
12587
Takashi Iwai889c4392007-08-23 18:56:52 +020012588/* mute/unmute internal speaker according to the hp jack and mute state */
12589static void alc268_acer_automute(struct hda_codec *codec, int force)
12590{
12591 struct alc_spec *spec = codec->spec;
12592 unsigned int mute;
12593
12594 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012595 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012596 spec->sense_updated = 1;
12597 }
12598 if (spec->jack_present)
12599 mute = HDA_AMP_MUTE; /* mute internal speaker */
12600 else /* unmute internal speaker if necessary */
12601 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12602 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12603 HDA_AMP_MUTE, mute);
12604}
12605
12606
12607/* bind hp and internal speaker mute (with plug check) */
12608static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12609 struct snd_ctl_elem_value *ucontrol)
12610{
12611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12612 long *valp = ucontrol->value.integer.value;
12613 int change;
12614
Takashi Iwai8de56b72009-07-24 16:51:47 +020012615 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012616 if (change)
12617 alc268_acer_automute(codec, 0);
12618 return change;
12619}
Takashi Iwaid2738092007-08-16 14:59:45 +020012620
Kailang Yang8ef355d2008-08-26 13:10:22 +020012621static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12622 /* output mixer control */
12623 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12624 {
12625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12626 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012627 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012628 .info = snd_hda_mixer_amp_switch_info,
12629 .get = snd_hda_mixer_amp_switch_get,
12630 .put = alc268_acer_master_sw_put,
12631 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12632 },
12633 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12634 { }
12635};
12636
Takashi Iwaid2738092007-08-16 14:59:45 +020012637static struct snd_kcontrol_new alc268_acer_mixer[] = {
12638 /* output mixer control */
12639 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12640 {
12641 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12642 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012643 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012644 .info = snd_hda_mixer_amp_switch_info,
12645 .get = snd_hda_mixer_amp_switch_get,
12646 .put = alc268_acer_master_sw_put,
12647 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12648 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012649 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12650 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12651 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012652 { }
12653};
12654
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012655static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12656 /* output mixer control */
12657 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12658 {
12659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12660 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012661 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012662 .info = snd_hda_mixer_amp_switch_info,
12663 .get = snd_hda_mixer_amp_switch_get,
12664 .put = alc268_acer_master_sw_put,
12665 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12666 },
12667 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12668 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12669 { }
12670};
12671
Kailang Yang8ef355d2008-08-26 13:10:22 +020012672static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12673 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12675 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12676 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12677 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12679 { }
12680};
12681
Takashi Iwaid2738092007-08-16 14:59:45 +020012682static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012683 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12684 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012685 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12686 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012687 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12688 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012689 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12690 { }
12691};
12692
12693/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012694#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012695#define alc268_toshiba_setup alc262_hippo_setup
12696#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012697
12698static void alc268_acer_unsol_event(struct hda_codec *codec,
12699 unsigned int res)
12700{
Takashi Iwai889c4392007-08-23 18:56:52 +020012701 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012702 return;
12703 alc268_acer_automute(codec, 1);
12704}
12705
Takashi Iwai889c4392007-08-23 18:56:52 +020012706static void alc268_acer_init_hook(struct hda_codec *codec)
12707{
12708 alc268_acer_automute(codec, 1);
12709}
12710
Kailang Yang8ef355d2008-08-26 13:10:22 +020012711/* toggle speaker-output according to the hp-jack state */
12712static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12713{
12714 unsigned int present;
12715 unsigned char bits;
12716
Wu Fengguang864f92b2009-11-18 12:38:02 +080012717 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012718 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012719 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012720 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012721 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012722 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012723}
12724
Kailang Yang8ef355d2008-08-26 13:10:22 +020012725static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12726 unsigned int res)
12727{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012728 switch (res >> 26) {
12729 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012730 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012731 break;
12732 case ALC880_MIC_EVENT:
12733 alc_mic_automute(codec);
12734 break;
12735 }
12736}
12737
12738static void alc268_acer_lc_setup(struct hda_codec *codec)
12739{
12740 struct alc_spec *spec = codec->spec;
12741 spec->ext_mic.pin = 0x18;
12742 spec->ext_mic.mux_idx = 0;
12743 spec->int_mic.pin = 0x12;
12744 spec->int_mic.mux_idx = 6;
12745 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012746}
12747
12748static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12749{
12750 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012751 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012752}
12753
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012754static struct snd_kcontrol_new alc268_dell_mixer[] = {
12755 /* output mixer control */
12756 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12757 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12758 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12759 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12760 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12761 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12762 { }
12763};
12764
12765static struct hda_verb alc268_dell_verbs[] = {
12766 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12768 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012769 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012770 { }
12771};
12772
12773/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012774static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012775{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012776 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012777
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012778 spec->autocfg.hp_pins[0] = 0x15;
12779 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012780 spec->ext_mic.pin = 0x18;
12781 spec->ext_mic.mux_idx = 0;
12782 spec->int_mic.pin = 0x19;
12783 spec->int_mic.mux_idx = 1;
12784 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012785}
12786
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012787static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12788 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12789 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12790 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12792 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12793 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12794 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12795 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12796 { }
12797};
12798
12799static struct hda_verb alc267_quanta_il1_verbs[] = {
12800 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12801 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12802 { }
12803};
12804
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012805static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012806{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012807 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012808 spec->autocfg.hp_pins[0] = 0x15;
12809 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012810 spec->ext_mic.pin = 0x18;
12811 spec->ext_mic.mux_idx = 0;
12812 spec->int_mic.pin = 0x19;
12813 spec->int_mic.mux_idx = 1;
12814 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012815}
12816
Kailang Yanga361d842007-06-05 12:30:55 +020012817/*
12818 * generic initialization of ADC, input mixers and output mixers
12819 */
12820static struct hda_verb alc268_base_init_verbs[] = {
12821 /* Unmute DAC0-1 and set vol = 0 */
12822 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012823 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012824
12825 /*
12826 * Set up output mixers (0x0c - 0x0e)
12827 */
12828 /* set vol=0 to output mixers */
12829 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012830 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12831
12832 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12833 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12834
12835 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12836 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12837 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12838 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12839 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12840 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12841 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12842 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12843
12844 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12846 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012848 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012849
12850 /* set PCBEEP vol = 0, mute connections */
12851 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12852 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12853 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012854
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012855 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012856
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012857 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12859 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012861
Kailang Yanga361d842007-06-05 12:30:55 +020012862 { }
12863};
12864
12865/*
12866 * generic initialization of ADC, input mixers and output mixers
12867 */
12868static struct hda_verb alc268_volume_init_verbs[] = {
12869 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012870 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12871 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012872
12873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12874 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12875 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12876 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12877 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12878
Kailang Yanga361d842007-06-05 12:30:55 +020012879 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012880 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12881 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12882
12883 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012884 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012885
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012886 /* set PCBEEP vol = 0, mute connections */
12887 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12888 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12889 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012890
12891 { }
12892};
12893
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012894static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12895 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12896 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12897 { } /* end */
12898};
12899
Kailang Yanga361d842007-06-05 12:30:55 +020012900static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12901 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12902 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012903 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012904 { } /* end */
12905};
12906
12907static struct snd_kcontrol_new alc268_capture_mixer[] = {
12908 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12909 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12910 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12911 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012912 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012913 { } /* end */
12914};
12915
12916static struct hda_input_mux alc268_capture_source = {
12917 .num_items = 4,
12918 .items = {
12919 { "Mic", 0x0 },
12920 { "Front Mic", 0x1 },
12921 { "Line", 0x2 },
12922 { "CD", 0x3 },
12923 },
12924};
12925
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012926static struct hda_input_mux alc268_acer_capture_source = {
12927 .num_items = 3,
12928 .items = {
12929 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012930 { "Internal Mic", 0x1 },
12931 { "Line", 0x2 },
12932 },
12933};
12934
12935static struct hda_input_mux alc268_acer_dmic_capture_source = {
12936 .num_items = 3,
12937 .items = {
12938 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012939 { "Internal Mic", 0x6 },
12940 { "Line", 0x2 },
12941 },
12942};
12943
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012944#ifdef CONFIG_SND_DEBUG
12945static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012946 /* Volume widgets */
12947 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12948 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12949 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12950 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12951 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12952 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12953 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12954 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12955 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12956 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12957 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12958 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12959 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012960 /* The below appears problematic on some hardwares */
12961 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012962 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12963 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12964 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12965 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12966
12967 /* Modes for retasking pin widgets */
12968 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12969 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12970 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12971 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12972
12973 /* Controls for GPIO pins, assuming they are configured as outputs */
12974 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12975 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12976 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12977 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12978
12979 /* Switches to allow the digital SPDIF output pin to be enabled.
12980 * The ALC268 does not have an SPDIF input.
12981 */
12982 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12983
12984 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12985 * this output to turn on an external amplifier.
12986 */
12987 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12988 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12989
12990 { } /* end */
12991};
12992#endif
12993
Kailang Yanga361d842007-06-05 12:30:55 +020012994/* create input playback/capture controls for the given pin */
12995static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12996 const char *ctlname, int idx)
12997{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012998 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012999 int err;
13000
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013001 switch (nid) {
13002 case 0x14:
13003 case 0x16:
13004 dac = 0x02;
13005 break;
13006 case 0x15:
Kailang Yang531d8792010-04-09 10:57:33 +020013007 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013008 dac = 0x03;
13009 break;
13010 default:
13011 return 0;
13012 }
13013 if (spec->multiout.dac_nids[0] != dac &&
13014 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013015 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013016 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013017 HDA_OUTPUT));
13018 if (err < 0)
13019 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013020 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13021 }
13022
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013023 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013024 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013025 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013026 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013027 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013028 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013029 if (err < 0)
13030 return err;
13031 return 0;
13032}
13033
13034/* add playback controls from the parsed DAC table */
13035static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13036 const struct auto_pin_cfg *cfg)
13037{
13038 hda_nid_t nid;
13039 int err;
13040
Kailang Yanga361d842007-06-05 12:30:55 +020013041 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013042
13043 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013044 if (nid) {
13045 const char *name;
13046 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13047 name = "Speaker";
13048 else
13049 name = "Front";
13050 err = alc268_new_analog_output(spec, nid, name, 0);
13051 if (err < 0)
13052 return err;
13053 }
Kailang Yanga361d842007-06-05 12:30:55 +020013054
13055 nid = cfg->speaker_pins[0];
13056 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013057 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013058 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13059 if (err < 0)
13060 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013061 } else {
13062 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13063 if (err < 0)
13064 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013065 }
13066 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013067 if (nid) {
13068 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13069 if (err < 0)
13070 return err;
13071 }
Kailang Yanga361d842007-06-05 12:30:55 +020013072
13073 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13074 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013075 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013076 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013077 if (err < 0)
13078 return err;
13079 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013080 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013081}
13082
13083/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013084static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013085 const struct auto_pin_cfg *cfg)
13086{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013087 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013088}
13089
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013090static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13091 hda_nid_t nid, int pin_type)
13092{
13093 int idx;
13094
13095 alc_set_pin_output(codec, nid, pin_type);
13096 if (nid == 0x14 || nid == 0x16)
13097 idx = 0;
13098 else
13099 idx = 1;
13100 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13101}
13102
13103static void alc268_auto_init_multi_out(struct hda_codec *codec)
13104{
13105 struct alc_spec *spec = codec->spec;
13106 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13107 if (nid) {
13108 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13109 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13110 }
13111}
13112
13113static void alc268_auto_init_hp_out(struct hda_codec *codec)
13114{
13115 struct alc_spec *spec = codec->spec;
13116 hda_nid_t pin;
13117
13118 pin = spec->autocfg.hp_pins[0];
13119 if (pin)
13120 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13121 pin = spec->autocfg.speaker_pins[0];
13122 if (pin)
13123 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13124}
13125
Kailang Yanga361d842007-06-05 12:30:55 +020013126static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13127{
13128 struct alc_spec *spec = codec->spec;
13129 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13130 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13131 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13132 unsigned int dac_vol1, dac_vol2;
13133
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013134 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013135 snd_hda_codec_write(codec, speaker_nid, 0,
13136 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013137 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013138 snd_hda_codec_write(codec, 0x0f, 0,
13139 AC_VERB_SET_AMP_GAIN_MUTE,
13140 AMP_IN_UNMUTE(1));
13141 snd_hda_codec_write(codec, 0x10, 0,
13142 AC_VERB_SET_AMP_GAIN_MUTE,
13143 AMP_IN_UNMUTE(1));
13144 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013145 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013146 snd_hda_codec_write(codec, 0x0f, 0,
13147 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13148 snd_hda_codec_write(codec, 0x10, 0,
13149 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13150 }
13151
13152 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013153 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013154 dac_vol2 = AMP_OUT_ZERO;
13155 else if (line_nid == 0x15)
13156 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013157 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013158 dac_vol2 = AMP_OUT_ZERO;
13159 else if (hp_nid == 0x15)
13160 dac_vol1 = AMP_OUT_ZERO;
13161 if (line_nid != 0x16 || hp_nid != 0x16 ||
13162 spec->autocfg.line_out_pins[1] != 0x16 ||
13163 spec->autocfg.line_out_pins[2] != 0x16)
13164 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13165
13166 snd_hda_codec_write(codec, 0x02, 0,
13167 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13168 snd_hda_codec_write(codec, 0x03, 0,
13169 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13170}
13171
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013172/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013173#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13174#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013175#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013176#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13177
13178/*
13179 * BIOS auto configuration
13180 */
13181static int alc268_parse_auto_config(struct hda_codec *codec)
13182{
13183 struct alc_spec *spec = codec->spec;
13184 int err;
13185 static hda_nid_t alc268_ignore[] = { 0 };
13186
13187 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13188 alc268_ignore);
13189 if (err < 0)
13190 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013191 if (!spec->autocfg.line_outs) {
13192 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13193 spec->multiout.max_channels = 2;
13194 spec->no_analog = 1;
13195 goto dig_only;
13196 }
Kailang Yanga361d842007-06-05 12:30:55 +020013197 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013198 }
Kailang Yanga361d842007-06-05 12:30:55 +020013199 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13200 if (err < 0)
13201 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013202 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013203 if (err < 0)
13204 return err;
13205
13206 spec->multiout.max_channels = 2;
13207
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013208 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013209 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013210 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020013211 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013212 spec->dig_out_type = spec->autocfg.dig_out_type[0];
13213 }
Takashi Iwai603c4012008-07-30 15:01:44 +020013214 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013215 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013216
Takashi Iwai892981f2009-03-02 08:04:35 +010013217 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013218 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013219
Takashi Iwaid88897e2008-10-31 15:01:37 +010013220 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013221 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013222 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013223
Takashi Iwai776e1842007-08-29 15:07:11 +020013224 err = alc_auto_add_mic_boost(codec);
13225 if (err < 0)
13226 return err;
13227
Kailang Yang6227cdc2010-02-25 08:36:52 +010013228 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013229
Kailang Yanga361d842007-06-05 12:30:55 +020013230 return 1;
13231}
13232
Kailang Yanga361d842007-06-05 12:30:55 +020013233#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13234
13235/* init callback for auto-configuration model -- overriding the default init */
13236static void alc268_auto_init(struct hda_codec *codec)
13237{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013238 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013239 alc268_auto_init_multi_out(codec);
13240 alc268_auto_init_hp_out(codec);
13241 alc268_auto_init_mono_speaker_out(codec);
13242 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013243 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013244 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013245}
13246
13247/*
13248 * configuration and preset
13249 */
13250static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013251 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013252 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013253 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013254 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013255 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013256 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013257 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013258 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013259#ifdef CONFIG_SND_DEBUG
13260 [ALC268_TEST] = "test",
13261#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013262 [ALC268_AUTO] = "auto",
13263};
13264
13265static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013266 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013267 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013268 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013269 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013270 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013271 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13272 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013273 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013274 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13275 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013276 /* almost compatible with toshiba but with optional digital outs;
13277 * auto-probing seems working fine
13278 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013279 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013280 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013281 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013282 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013283 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013284 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013285 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013286 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013287 {}
13288};
13289
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013290/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13291static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13292 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13293 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13294 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13295 ALC268_TOSHIBA),
13296 {}
13297};
13298
Kailang Yanga361d842007-06-05 12:30:55 +020013299static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013300 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013301 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13302 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013303 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13304 alc267_quanta_il1_verbs },
13305 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13306 .dac_nids = alc268_dac_nids,
13307 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13308 .adc_nids = alc268_adc_nids_alt,
13309 .hp_nid = 0x03,
13310 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13311 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013312 .unsol_event = alc_sku_unsol_event,
13313 .setup = alc267_quanta_il1_setup,
13314 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013315 },
Kailang Yanga361d842007-06-05 12:30:55 +020013316 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013317 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13318 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013319 .init_verbs = { alc268_base_init_verbs },
13320 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13321 .dac_nids = alc268_dac_nids,
13322 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13323 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013324 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013325 .hp_nid = 0x03,
13326 .dig_out_nid = ALC268_DIGOUT_NID,
13327 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13328 .channel_mode = alc268_modes,
13329 .input_mux = &alc268_capture_source,
13330 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013331 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013332 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013333 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013334 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13335 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013336 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13337 .dac_nids = alc268_dac_nids,
13338 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13339 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013340 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013341 .hp_nid = 0x03,
13342 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13343 .channel_mode = alc268_modes,
13344 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013345 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013346 .setup = alc268_toshiba_setup,
13347 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013348 },
13349 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013350 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013351 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013352 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13353 alc268_acer_verbs },
13354 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13355 .dac_nids = alc268_dac_nids,
13356 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13357 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013358 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013359 .hp_nid = 0x02,
13360 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13361 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013362 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013363 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013364 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013365 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013366 [ALC268_ACER_DMIC] = {
13367 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13368 alc268_beep_mixer },
13369 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13370 alc268_acer_verbs },
13371 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13372 .dac_nids = alc268_dac_nids,
13373 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13374 .adc_nids = alc268_adc_nids_alt,
13375 .capsrc_nids = alc268_capsrc_nids,
13376 .hp_nid = 0x02,
13377 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13378 .channel_mode = alc268_modes,
13379 .input_mux = &alc268_acer_dmic_capture_source,
13380 .unsol_event = alc268_acer_unsol_event,
13381 .init_hook = alc268_acer_init_hook,
13382 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013383 [ALC268_ACER_ASPIRE_ONE] = {
13384 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013385 alc268_beep_mixer,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013386 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013387 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13388 alc268_acer_aspire_one_verbs },
13389 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13390 .dac_nids = alc268_dac_nids,
13391 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13392 .adc_nids = alc268_adc_nids_alt,
13393 .capsrc_nids = alc268_capsrc_nids,
13394 .hp_nid = 0x03,
13395 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13396 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013397 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013398 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013399 .init_hook = alc268_acer_lc_init_hook,
13400 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013401 [ALC268_DELL] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013402 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13403 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013404 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13405 alc268_dell_verbs },
13406 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13407 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013408 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13409 .adc_nids = alc268_adc_nids_alt,
13410 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013411 .hp_nid = 0x02,
13412 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13413 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013414 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013415 .setup = alc268_dell_setup,
13416 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013417 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013418 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013419 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13420 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013421 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13422 alc268_toshiba_verbs },
13423 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13424 .dac_nids = alc268_dac_nids,
13425 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13426 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013427 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013428 .hp_nid = 0x03,
13429 .dig_out_nid = ALC268_DIGOUT_NID,
13430 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13431 .channel_mode = alc268_modes,
13432 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013433 .setup = alc268_toshiba_setup,
13434 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013435 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013436#ifdef CONFIG_SND_DEBUG
13437 [ALC268_TEST] = {
13438 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13439 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13440 alc268_volume_init_verbs },
13441 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13442 .dac_nids = alc268_dac_nids,
13443 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13444 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013445 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013446 .hp_nid = 0x03,
13447 .dig_out_nid = ALC268_DIGOUT_NID,
13448 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13449 .channel_mode = alc268_modes,
13450 .input_mux = &alc268_capture_source,
13451 },
13452#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013453};
13454
13455static int patch_alc268(struct hda_codec *codec)
13456{
13457 struct alc_spec *spec;
13458 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013459 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013460
Julia Lawallef86f582009-12-19 08:18:03 +010013461 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013462 if (spec == NULL)
13463 return -ENOMEM;
13464
13465 codec->spec = spec;
13466
13467 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13468 alc268_models,
13469 alc268_cfg_tbl);
13470
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013471 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13472 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013473 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013474
Kailang Yanga361d842007-06-05 12:30:55 +020013475 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013476 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13477 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013478 board_config = ALC268_AUTO;
13479 }
13480
13481 if (board_config == ALC268_AUTO) {
13482 /* automatic parse from the BIOS config */
13483 err = alc268_parse_auto_config(codec);
13484 if (err < 0) {
13485 alc_free(codec);
13486 return err;
13487 } else if (!err) {
13488 printk(KERN_INFO
13489 "hda_codec: Cannot set up configuration "
13490 "from BIOS. Using base mode...\n");
13491 board_config = ALC268_3ST;
13492 }
13493 }
13494
13495 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013496 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013497
Kailang Yanga361d842007-06-05 12:30:55 +020013498 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13499 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013500 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013501
Kailang Yanga361d842007-06-05 12:30:55 +020013502 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13503
Takashi Iwai22971e32009-02-10 11:56:44 +010013504 has_beep = 0;
13505 for (i = 0; i < spec->num_mixers; i++) {
13506 if (spec->mixers[i] == alc268_beep_mixer) {
13507 has_beep = 1;
13508 break;
13509 }
13510 }
13511
13512 if (has_beep) {
13513 err = snd_hda_attach_beep_device(codec, 0x1);
13514 if (err < 0) {
13515 alc_free(codec);
13516 return err;
13517 }
13518 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13519 /* override the amp caps for beep generator */
13520 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013521 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13522 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13523 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13524 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013525 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013526
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013527 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013528 /* check whether NID 0x07 is valid */
13529 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013530 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013531
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013532 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013533 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013534 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013535 if (spec->auto_mic ||
13536 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013537 spec->adc_nids = alc268_adc_nids_alt;
13538 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013539 if (spec->auto_mic)
13540 fixup_automic_adc(codec);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013541 if (spec->auto_mic || spec->input_mux->num_items == 1)
13542 add_mixer(spec, alc268_capture_nosrc_mixer);
13543 else
13544 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013545 } else {
13546 spec->adc_nids = alc268_adc_nids;
13547 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013548 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013549 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013550 /* set default input source */
13551 for (i = 0; i < spec->num_adc_nids; i++)
13552 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13553 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013554 i < spec->num_mux_defs ?
13555 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013556 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013557 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013558
13559 spec->vmaster_nid = 0x02;
13560
Kailang Yanga361d842007-06-05 12:30:55 +020013561 codec->patch_ops = alc_patch_ops;
13562 if (board_config == ALC268_AUTO)
13563 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013564
Kailang Yanga361d842007-06-05 12:30:55 +020013565 return 0;
13566}
13567
13568/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013569 * ALC269 channel source setting (2 channel)
13570 */
13571#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13572
13573#define alc269_dac_nids alc260_dac_nids
13574
13575static hda_nid_t alc269_adc_nids[1] = {
13576 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013577 0x08,
13578};
13579
Takashi Iwaie01bf502008-08-21 16:25:07 +020013580static hda_nid_t alc269_capsrc_nids[1] = {
13581 0x23,
13582};
13583
Kailang Yang84898e82010-02-04 14:16:14 +010013584static hda_nid_t alc269vb_adc_nids[1] = {
13585 /* ADC1 */
13586 0x09,
13587};
13588
13589static hda_nid_t alc269vb_capsrc_nids[1] = {
13590 0x22,
13591};
13592
Takashi Iwai66946352010-03-29 17:21:45 +020013593static hda_nid_t alc269_adc_candidates[] = {
13594 0x08, 0x09, 0x07,
13595};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013596
Kailang Yangf6a92242007-12-13 16:52:54 +010013597#define alc269_modes alc260_modes
13598#define alc269_capture_source alc880_lg_lw_capture_source
13599
13600static struct snd_kcontrol_new alc269_base_mixer[] = {
13601 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13602 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13603 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13604 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13605 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13606 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13607 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13608 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13609 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13610 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13612 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13613 { } /* end */
13614};
13615
Kailang Yang60db6b52008-08-26 13:13:00 +020013616static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13617 /* output mixer control */
13618 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13619 {
13620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13621 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013622 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013623 .info = snd_hda_mixer_amp_switch_info,
13624 .get = snd_hda_mixer_amp_switch_get,
13625 .put = alc268_acer_master_sw_put,
13626 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13627 },
13628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13630 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13631 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13632 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13633 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013634 { }
13635};
13636
Tony Vroon64154832008-11-06 15:08:49 +000013637static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13638 /* output mixer control */
13639 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13640 {
13641 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13642 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013643 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013644 .info = snd_hda_mixer_amp_switch_info,
13645 .get = snd_hda_mixer_amp_switch_get,
13646 .put = alc268_acer_master_sw_put,
13647 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13648 },
13649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13651 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13652 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13653 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13654 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13655 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13656 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13657 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013658 { }
13659};
13660
Kailang Yang84898e82010-02-04 14:16:14 +010013661static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013662 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013663 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013665 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013666 { } /* end */
13667};
13668
Kailang Yang84898e82010-02-04 14:16:14 +010013669static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13670 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13671 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13672 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13673 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13674 { } /* end */
13675};
13676
Kailang Yangf6a92242007-12-13 16:52:54 +010013677/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013678static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13679 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13680 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13681 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13682 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13683 { } /* end */
13684};
13685
13686static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013687 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13688 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013689 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13690 { } /* end */
13691};
13692
Kailang Yang84898e82010-02-04 14:16:14 +010013693static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13694 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13695 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13696 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13697 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13698 { } /* end */
13699};
13700
13701static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13702 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13703 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13704 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13705 { } /* end */
13706};
13707
Takashi Iwai26f5df22008-11-03 17:39:46 +010013708/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013709#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013710
Kailang Yang60db6b52008-08-26 13:13:00 +020013711static struct hda_verb alc269_quanta_fl1_verbs[] = {
13712 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13713 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13715 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13716 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13717 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13718 { }
13719};
13720
Tony Vroon64154832008-11-06 15:08:49 +000013721static struct hda_verb alc269_lifebook_verbs[] = {
13722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13723 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13724 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13725 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13726 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13728 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13729 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13730 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13731 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13732 { }
13733};
13734
Kailang Yang60db6b52008-08-26 13:13:00 +020013735/* toggle speaker-output according to the hp-jack state */
13736static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13737{
13738 unsigned int present;
13739 unsigned char bits;
13740
Wu Fengguang864f92b2009-11-18 12:38:02 +080013741 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013742 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013743 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013744 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013745 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013746 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013747
13748 snd_hda_codec_write(codec, 0x20, 0,
13749 AC_VERB_SET_COEF_INDEX, 0x0c);
13750 snd_hda_codec_write(codec, 0x20, 0,
13751 AC_VERB_SET_PROC_COEF, 0x680);
13752
13753 snd_hda_codec_write(codec, 0x20, 0,
13754 AC_VERB_SET_COEF_INDEX, 0x0c);
13755 snd_hda_codec_write(codec, 0x20, 0,
13756 AC_VERB_SET_PROC_COEF, 0x480);
13757}
13758
Tony Vroon64154832008-11-06 15:08:49 +000013759/* toggle speaker-output according to the hp-jacks state */
13760static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13761{
13762 unsigned int present;
13763 unsigned char bits;
13764
13765 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013766 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013767
13768 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013769 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013770
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013771 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013772 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013773 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013774 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013775 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013776
13777 snd_hda_codec_write(codec, 0x20, 0,
13778 AC_VERB_SET_COEF_INDEX, 0x0c);
13779 snd_hda_codec_write(codec, 0x20, 0,
13780 AC_VERB_SET_PROC_COEF, 0x680);
13781
13782 snd_hda_codec_write(codec, 0x20, 0,
13783 AC_VERB_SET_COEF_INDEX, 0x0c);
13784 snd_hda_codec_write(codec, 0x20, 0,
13785 AC_VERB_SET_PROC_COEF, 0x480);
13786}
13787
Tony Vroon64154832008-11-06 15:08:49 +000013788static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13789{
13790 unsigned int present_laptop;
13791 unsigned int present_dock;
13792
Wu Fengguang864f92b2009-11-18 12:38:02 +080013793 present_laptop = snd_hda_jack_detect(codec, 0x18);
13794 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013795
13796 /* Laptop mic port overrides dock mic port, design decision */
13797 if (present_dock)
13798 snd_hda_codec_write(codec, 0x23, 0,
13799 AC_VERB_SET_CONNECT_SEL, 0x3);
13800 if (present_laptop)
13801 snd_hda_codec_write(codec, 0x23, 0,
13802 AC_VERB_SET_CONNECT_SEL, 0x0);
13803 if (!present_dock && !present_laptop)
13804 snd_hda_codec_write(codec, 0x23, 0,
13805 AC_VERB_SET_CONNECT_SEL, 0x1);
13806}
13807
Kailang Yang60db6b52008-08-26 13:13:00 +020013808static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13809 unsigned int res)
13810{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013811 switch (res >> 26) {
13812 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013813 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013814 break;
13815 case ALC880_MIC_EVENT:
13816 alc_mic_automute(codec);
13817 break;
13818 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013819}
13820
Tony Vroon64154832008-11-06 15:08:49 +000013821static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13822 unsigned int res)
13823{
13824 if ((res >> 26) == ALC880_HP_EVENT)
13825 alc269_lifebook_speaker_automute(codec);
13826 if ((res >> 26) == ALC880_MIC_EVENT)
13827 alc269_lifebook_mic_autoswitch(codec);
13828}
13829
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013830static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13831{
13832 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013833 spec->autocfg.hp_pins[0] = 0x15;
13834 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013835 spec->ext_mic.pin = 0x18;
13836 spec->ext_mic.mux_idx = 0;
13837 spec->int_mic.pin = 0x19;
13838 spec->int_mic.mux_idx = 1;
13839 spec->auto_mic = 1;
13840}
13841
Kailang Yang60db6b52008-08-26 13:13:00 +020013842static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13843{
13844 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013845 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013846}
13847
Tony Vroon64154832008-11-06 15:08:49 +000013848static void alc269_lifebook_init_hook(struct hda_codec *codec)
13849{
13850 alc269_lifebook_speaker_automute(codec);
13851 alc269_lifebook_mic_autoswitch(codec);
13852}
13853
Kailang Yang84898e82010-02-04 14:16:14 +010013854static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013855 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13856 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13857 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13859 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13860 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13861 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13862 {}
13863};
13864
Kailang Yang84898e82010-02-04 14:16:14 +010013865static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13867 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13868 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13869 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13870 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13871 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13872 {}
13873};
13874
Kailang Yang84898e82010-02-04 14:16:14 +010013875static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13876 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13877 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13878 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13880 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13881 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13882 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13883 {}
13884};
13885
13886static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13887 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13888 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13889 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13891 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13892 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13893 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13894 {}
13895};
13896
Kailang Yang60db6b52008-08-26 13:13:00 +020013897/* toggle speaker-output according to the hp-jack state */
13898static void alc269_speaker_automute(struct hda_codec *codec)
13899{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013900 struct alc_spec *spec = codec->spec;
13901 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013902 unsigned int present;
13903 unsigned char bits;
13904
Kailang Yangebb83ee2009-12-17 12:23:00 +010013905 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013906 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013907 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013908 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013909 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013910 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013911}
13912
Kailang Yang60db6b52008-08-26 13:13:00 +020013913/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013914static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013915 unsigned int res)
13916{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013917 switch (res >> 26) {
13918 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013919 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013920 break;
13921 case ALC880_MIC_EVENT:
13922 alc_mic_automute(codec);
13923 break;
13924 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013925}
13926
Kailang Yang226b1ec2010-04-09 11:01:20 +020013927static void alc269_laptop_amic_setup(struct hda_codec *codec)
13928{
13929 struct alc_spec *spec = codec->spec;
13930 spec->autocfg.hp_pins[0] = 0x15;
13931 spec->autocfg.speaker_pins[0] = 0x14;
13932 spec->ext_mic.pin = 0x18;
13933 spec->ext_mic.mux_idx = 0;
13934 spec->int_mic.pin = 0x19;
13935 spec->int_mic.mux_idx = 1;
13936 spec->auto_mic = 1;
13937}
13938
Kailang Yang84898e82010-02-04 14:16:14 +010013939static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013940{
13941 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013942 spec->autocfg.hp_pins[0] = 0x15;
13943 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013944 spec->ext_mic.pin = 0x18;
13945 spec->ext_mic.mux_idx = 0;
13946 spec->int_mic.pin = 0x12;
13947 spec->int_mic.mux_idx = 5;
13948 spec->auto_mic = 1;
13949}
13950
Kailang Yang226b1ec2010-04-09 11:01:20 +020013951static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010013952{
13953 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020013954 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010013955 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013956 spec->ext_mic.pin = 0x18;
13957 spec->ext_mic.mux_idx = 0;
13958 spec->int_mic.pin = 0x19;
13959 spec->int_mic.mux_idx = 1;
13960 spec->auto_mic = 1;
13961}
13962
Kailang Yang226b1ec2010-04-09 11:01:20 +020013963static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13964{
13965 struct alc_spec *spec = codec->spec;
13966 spec->autocfg.hp_pins[0] = 0x21;
13967 spec->autocfg.speaker_pins[0] = 0x14;
13968 spec->ext_mic.pin = 0x18;
13969 spec->ext_mic.mux_idx = 0;
13970 spec->int_mic.pin = 0x12;
13971 spec->int_mic.mux_idx = 6;
13972 spec->auto_mic = 1;
13973}
13974
Kailang Yang84898e82010-02-04 14:16:14 +010013975static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013976{
13977 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013978 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013979}
13980
Kailang Yangf6a92242007-12-13 16:52:54 +010013981/*
13982 * generic initialization of ADC, input mixers and output mixers
13983 */
13984static struct hda_verb alc269_init_verbs[] = {
13985 /*
13986 * Unmute ADC0 and set the default input to mic-in
13987 */
Kailang Yang84898e82010-02-04 14:16:14 +010013988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013989
13990 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013991 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013992 */
13993 /* set vol=0 to output mixers */
13994 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13995 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13996
13997 /* set up input amps for analog loopback */
13998 /* Amp Indices: DAC = 0, mixer = 1 */
13999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14000 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14001 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14002 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14004 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14005
14006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14008 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14009 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14010 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14011 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14012 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14013
14014 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14015 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014016
Kailang Yang84898e82010-02-04 14:16:14 +010014017 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014018 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14019 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014020 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014021
14022 /* set EAPD */
14023 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014024 { }
14025};
14026
14027static struct hda_verb alc269vb_init_verbs[] = {
14028 /*
14029 * Unmute ADC0 and set the default input to mic-in
14030 */
14031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14032
14033 /*
14034 * Set up output mixers (0x02 - 0x03)
14035 */
14036 /* set vol=0 to output mixers */
14037 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14038 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14039
14040 /* set up input amps for analog loopback */
14041 /* Amp Indices: DAC = 0, mixer = 1 */
14042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14043 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14044 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14045 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14046 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14047 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14048
14049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14050 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14051 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14052 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14053 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14054 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14055 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14056
14057 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14058 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14059
14060 /* FIXME: use Mux-type input source selection */
14061 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14062 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14063 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14064
14065 /* set EAPD */
14066 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014067 { }
14068};
14069
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014070#define alc269_auto_create_multi_out_ctls \
14071 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014072#define alc269_auto_create_input_ctls \
14073 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014074
14075#ifdef CONFIG_SND_HDA_POWER_SAVE
14076#define alc269_loopbacks alc880_loopbacks
14077#endif
14078
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014079/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014080#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14081#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14082#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14083#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14084
Takashi Iwaif03d3112009-03-05 14:18:16 +010014085static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14086 .substreams = 1,
14087 .channels_min = 2,
14088 .channels_max = 8,
14089 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14090 /* NID is set in alc_build_pcms */
14091 .ops = {
14092 .open = alc880_playback_pcm_open,
14093 .prepare = alc880_playback_pcm_prepare,
14094 .cleanup = alc880_playback_pcm_cleanup
14095 },
14096};
14097
14098static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14099 .substreams = 1,
14100 .channels_min = 2,
14101 .channels_max = 2,
14102 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14103 /* NID is set in alc_build_pcms */
14104};
14105
Takashi Iwaiad358792010-03-30 18:00:59 +020014106#ifdef CONFIG_SND_HDA_POWER_SAVE
14107static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14108{
14109 switch (codec->subsystem_id) {
14110 case 0x103c1586:
14111 return 1;
14112 }
14113 return 0;
14114}
14115
14116static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14117{
14118 /* update mute-LED according to the speaker mute state */
14119 if (nid == 0x01 || nid == 0x14) {
14120 int pinval;
14121 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14122 HDA_AMP_MUTE)
14123 pinval = 0x24;
14124 else
14125 pinval = 0x20;
14126 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014127 snd_hda_codec_update_cache(codec, 0x19, 0,
14128 AC_VERB_SET_PIN_WIDGET_CONTROL,
14129 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014130 }
14131 return alc_check_power_status(codec, nid);
14132}
14133#endif /* CONFIG_SND_HDA_POWER_SAVE */
14134
Kailang Yangf6a92242007-12-13 16:52:54 +010014135/*
14136 * BIOS auto configuration
14137 */
14138static int alc269_parse_auto_config(struct hda_codec *codec)
14139{
14140 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014141 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014142 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14143
14144 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14145 alc269_ignore);
14146 if (err < 0)
14147 return err;
14148
14149 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14150 if (err < 0)
14151 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014152 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014153 if (err < 0)
14154 return err;
14155
14156 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14157
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014158 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010014159 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
14160
Takashi Iwai603c4012008-07-30 15:01:44 +020014161 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014162 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014163
Kailang Yang84898e82010-02-04 14:16:14 +010014164 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14165 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014166 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014167 } else {
14168 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014169 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014170 }
14171
Kailang Yangf6a92242007-12-13 16:52:54 +010014172 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014173 spec->input_mux = &spec->private_imux[0];
Takashi Iwai66946352010-03-29 17:21:45 +020014174 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14175 sizeof(alc269_adc_candidates));
14176
Takashi Iwaie01bf502008-08-21 16:25:07 +020014177 /* set default input source */
Takashi Iwai66946352010-03-29 17:21:45 +020014178 snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
Takashi Iwaie01bf502008-08-21 16:25:07 +020014179 0, AC_VERB_SET_CONNECT_SEL,
14180 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014181
14182 err = alc_auto_add_mic_boost(codec);
14183 if (err < 0)
14184 return err;
14185
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014186 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014187 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014188
Kailang Yangf6a92242007-12-13 16:52:54 +010014189 return 1;
14190}
14191
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014192#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14193#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014194#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14195
14196
14197/* init callback for auto-configuration model -- overriding the default init */
14198static void alc269_auto_init(struct hda_codec *codec)
14199{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014200 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014201 alc269_auto_init_multi_out(codec);
14202 alc269_auto_init_hp_out(codec);
14203 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014204 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014205 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014206}
14207
Takashi Iwaiff818c22010-04-12 08:59:25 +020014208enum {
14209 ALC269_FIXUP_SONY_VAIO,
14210};
14211
Tobias Klauserfbc25662010-05-20 10:40:55 +020014212static const struct hda_verb alc269_sony_vaio_fixup_verbs[] = {
Takashi Iwaiff818c22010-04-12 08:59:25 +020014213 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14214 {}
14215};
14216
14217static const struct alc_fixup alc269_fixups[] = {
14218 [ALC269_FIXUP_SONY_VAIO] = {
14219 .verbs = alc269_sony_vaio_fixup_verbs
14220 },
14221};
14222
14223static struct snd_pci_quirk alc269_fixup_tbl[] = {
14224 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
14225 {}
14226};
14227
14228
Kailang Yangf6a92242007-12-13 16:52:54 +010014229/*
14230 * configuration and preset
14231 */
14232static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014233 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014234 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014235 [ALC269_AMIC] = "laptop-amic",
14236 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014237 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014238 [ALC269_LIFEBOOK] = "lifebook",
14239 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014240};
14241
14242static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014243 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020014244 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014245 ALC269_AMIC),
14246 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14247 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14248 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14249 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14250 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14251 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14252 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14253 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14254 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14255 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14256 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14257 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14258 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14259 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14260 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14261 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14262 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14263 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14264 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14265 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14266 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14267 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14268 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14269 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14270 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14271 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14272 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14273 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14274 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14275 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14276 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14277 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14278 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14279 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14280 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14281 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014282 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014283 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014284 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014285 ALC269_DMIC),
14286 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14287 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014288 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014289 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014290 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14291 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14292 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14293 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14294 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14295 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014296 {}
14297};
14298
14299static struct alc_config_preset alc269_presets[] = {
14300 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014301 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014302 .init_verbs = { alc269_init_verbs },
14303 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14304 .dac_nids = alc269_dac_nids,
14305 .hp_nid = 0x03,
14306 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14307 .channel_mode = alc269_modes,
14308 .input_mux = &alc269_capture_source,
14309 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014310 [ALC269_QUANTA_FL1] = {
14311 .mixers = { alc269_quanta_fl1_mixer },
14312 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14313 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14314 .dac_nids = alc269_dac_nids,
14315 .hp_nid = 0x03,
14316 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14317 .channel_mode = alc269_modes,
14318 .input_mux = &alc269_capture_source,
14319 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014320 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014321 .init_hook = alc269_quanta_fl1_init_hook,
14322 },
Kailang Yang84898e82010-02-04 14:16:14 +010014323 [ALC269_AMIC] = {
14324 .mixers = { alc269_laptop_mixer },
14325 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014326 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014327 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014328 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14329 .dac_nids = alc269_dac_nids,
14330 .hp_nid = 0x03,
14331 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14332 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014333 .unsol_event = alc269_laptop_unsol_event,
14334 .setup = alc269_laptop_amic_setup,
14335 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014336 },
Kailang Yang84898e82010-02-04 14:16:14 +010014337 [ALC269_DMIC] = {
14338 .mixers = { alc269_laptop_mixer },
14339 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014340 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014341 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014342 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14343 .dac_nids = alc269_dac_nids,
14344 .hp_nid = 0x03,
14345 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14346 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014347 .unsol_event = alc269_laptop_unsol_event,
14348 .setup = alc269_laptop_dmic_setup,
14349 .init_hook = alc269_laptop_inithook,
14350 },
14351 [ALC269VB_AMIC] = {
14352 .mixers = { alc269vb_laptop_mixer },
14353 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14354 .init_verbs = { alc269vb_init_verbs,
14355 alc269vb_laptop_amic_init_verbs },
14356 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14357 .dac_nids = alc269_dac_nids,
14358 .hp_nid = 0x03,
14359 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14360 .channel_mode = alc269_modes,
14361 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014362 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014363 .init_hook = alc269_laptop_inithook,
14364 },
14365 [ALC269VB_DMIC] = {
14366 .mixers = { alc269vb_laptop_mixer },
14367 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14368 .init_verbs = { alc269vb_init_verbs,
14369 alc269vb_laptop_dmic_init_verbs },
14370 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14371 .dac_nids = alc269_dac_nids,
14372 .hp_nid = 0x03,
14373 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14374 .channel_mode = alc269_modes,
14375 .unsol_event = alc269_laptop_unsol_event,
14376 .setup = alc269vb_laptop_dmic_setup,
14377 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014378 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014379 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014380 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014381 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014382 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014383 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014384 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14385 .dac_nids = alc269_dac_nids,
14386 .hp_nid = 0x03,
14387 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14388 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014389 .unsol_event = alc269_laptop_unsol_event,
14390 .setup = alc269_laptop_dmic_setup,
14391 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014392 },
Tony Vroon64154832008-11-06 15:08:49 +000014393 [ALC269_LIFEBOOK] = {
14394 .mixers = { alc269_lifebook_mixer },
14395 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14396 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14397 .dac_nids = alc269_dac_nids,
14398 .hp_nid = 0x03,
14399 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14400 .channel_mode = alc269_modes,
14401 .input_mux = &alc269_capture_source,
14402 .unsol_event = alc269_lifebook_unsol_event,
14403 .init_hook = alc269_lifebook_init_hook,
14404 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014405};
14406
14407static int patch_alc269(struct hda_codec *codec)
14408{
14409 struct alc_spec *spec;
14410 int board_config;
14411 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014412 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014413
14414 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14415 if (spec == NULL)
14416 return -ENOMEM;
14417
14418 codec->spec = spec;
14419
Kailang Yangda00c242010-03-19 11:23:45 +010014420 alc_auto_parse_customize_define(codec);
14421
Kailang Yang274693f2009-12-03 10:07:50 +010014422 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014423 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14424 spec->cdefine.platform_type == 1)
14425 alc_codec_rename(codec, "ALC271X");
14426 else
14427 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014428 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014429 } else
14430 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014431
Kailang Yangf6a92242007-12-13 16:52:54 +010014432 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14433 alc269_models,
14434 alc269_cfg_tbl);
14435
14436 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014437 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14438 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014439 board_config = ALC269_AUTO;
14440 }
14441
Takashi Iwaiff818c22010-04-12 08:59:25 +020014442 if (board_config == ALC269_AUTO)
14443 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14444
Kailang Yangf6a92242007-12-13 16:52:54 +010014445 if (board_config == ALC269_AUTO) {
14446 /* automatic parse from the BIOS config */
14447 err = alc269_parse_auto_config(codec);
14448 if (err < 0) {
14449 alc_free(codec);
14450 return err;
14451 } else if (!err) {
14452 printk(KERN_INFO
14453 "hda_codec: Cannot set up configuration "
14454 "from BIOS. Using base mode...\n");
14455 board_config = ALC269_BASIC;
14456 }
14457 }
14458
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014459 err = snd_hda_attach_beep_device(codec, 0x1);
14460 if (err < 0) {
14461 alc_free(codec);
14462 return err;
14463 }
14464
Kailang Yangf6a92242007-12-13 16:52:54 +010014465 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014466 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014467
Kailang Yang84898e82010-02-04 14:16:14 +010014468 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014469 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14470 * fix the sample rate of analog I/O to 44.1kHz
14471 */
14472 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14473 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14474 } else {
14475 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14476 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14477 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014478 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14479 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14480
Takashi Iwai66946352010-03-29 17:21:45 +020014481 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14482 if (!is_alc269vb) {
14483 spec->adc_nids = alc269_adc_nids;
14484 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14485 spec->capsrc_nids = alc269_capsrc_nids;
14486 } else {
14487 spec->adc_nids = alc269vb_adc_nids;
14488 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14489 spec->capsrc_nids = alc269vb_capsrc_nids;
14490 }
Kailang Yang84898e82010-02-04 14:16:14 +010014491 }
14492
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014493 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014494 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010014495 if (spec->cdefine.enable_pcbeep)
14496 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014497
Takashi Iwaiff818c22010-04-12 08:59:25 +020014498 if (board_config == ALC269_AUTO)
14499 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14500
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014501 spec->vmaster_nid = 0x02;
14502
Kailang Yangf6a92242007-12-13 16:52:54 +010014503 codec->patch_ops = alc_patch_ops;
14504 if (board_config == ALC269_AUTO)
14505 spec->init_hook = alc269_auto_init;
14506#ifdef CONFIG_SND_HDA_POWER_SAVE
14507 if (!spec->loopback.amplist)
14508 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014509 if (alc269_mic2_for_mute_led(codec))
14510 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014511#endif
14512
14513 return 0;
14514}
14515
14516/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014517 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14518 */
14519
14520/*
14521 * set the path ways for 2 channel output
14522 * need to set the codec line out and mic 1 pin widgets to inputs
14523 */
14524static struct hda_verb alc861_threestack_ch2_init[] = {
14525 /* set pin widget 1Ah (line in) for input */
14526 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014527 /* set pin widget 18h (mic1/2) for input, for mic also enable
14528 * the vref
14529 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014530 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14531
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014532 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14533#if 0
14534 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14535 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14536#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014537 { } /* end */
14538};
14539/*
14540 * 6ch mode
14541 * need to set the codec line out and mic 1 pin widgets to outputs
14542 */
14543static struct hda_verb alc861_threestack_ch6_init[] = {
14544 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14545 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14546 /* set pin widget 18h (mic1) for output (CLFE)*/
14547 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14548
14549 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014550 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014551
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014552 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14553#if 0
14554 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14555 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14556#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014557 { } /* end */
14558};
14559
14560static struct hda_channel_mode alc861_threestack_modes[2] = {
14561 { 2, alc861_threestack_ch2_init },
14562 { 6, alc861_threestack_ch6_init },
14563};
Takashi Iwai22309c32006-08-09 16:57:28 +020014564/* Set mic1 as input and unmute the mixer */
14565static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14566 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14567 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14568 { } /* end */
14569};
14570/* Set mic1 as output and mute mixer */
14571static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14572 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14573 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14574 { } /* end */
14575};
14576
14577static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14578 { 2, alc861_uniwill_m31_ch2_init },
14579 { 4, alc861_uniwill_m31_ch4_init },
14580};
Kailang Yangdf694da2005-12-05 19:42:22 +010014581
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014582/* Set mic1 and line-in as input and unmute the mixer */
14583static struct hda_verb alc861_asus_ch2_init[] = {
14584 /* set pin widget 1Ah (line in) for input */
14585 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014586 /* set pin widget 18h (mic1/2) for input, for mic also enable
14587 * the vref
14588 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014589 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14590
14591 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14592#if 0
14593 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14594 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14595#endif
14596 { } /* end */
14597};
14598/* Set mic1 nad line-in as output and mute mixer */
14599static struct hda_verb alc861_asus_ch6_init[] = {
14600 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14601 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14602 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14603 /* set pin widget 18h (mic1) for output (CLFE)*/
14604 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14605 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14606 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14607 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14608
14609 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14610#if 0
14611 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14612 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14613#endif
14614 { } /* end */
14615};
14616
14617static struct hda_channel_mode alc861_asus_modes[2] = {
14618 { 2, alc861_asus_ch2_init },
14619 { 6, alc861_asus_ch6_init },
14620};
14621
Kailang Yangdf694da2005-12-05 19:42:22 +010014622/* patch-ALC861 */
14623
14624static struct snd_kcontrol_new alc861_base_mixer[] = {
14625 /* output mixer control */
14626 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14627 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14628 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14629 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14630 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14631
14632 /*Input mixer control */
14633 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14634 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14635 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14636 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14637 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14638 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14640 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14641 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014643
Kailang Yangdf694da2005-12-05 19:42:22 +010014644 { } /* end */
14645};
14646
14647static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14648 /* output mixer control */
14649 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14650 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14651 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14652 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14653 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14654
14655 /* Input mixer control */
14656 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14657 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14658 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14659 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14660 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14661 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14662 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14663 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14664 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014666
Kailang Yangdf694da2005-12-05 19:42:22 +010014667 {
14668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14669 .name = "Channel Mode",
14670 .info = alc_ch_mode_info,
14671 .get = alc_ch_mode_get,
14672 .put = alc_ch_mode_put,
14673 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14674 },
14675 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014676};
14677
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014678static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014679 /* output mixer control */
14680 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14682 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014683
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014684 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014685};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014686
Takashi Iwai22309c32006-08-09 16:57:28 +020014687static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14688 /* output mixer control */
14689 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14690 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14691 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14692 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14693 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14694
14695 /* Input mixer control */
14696 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14697 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14698 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14699 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14700 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14701 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14702 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14703 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14704 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14705 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014706
Takashi Iwai22309c32006-08-09 16:57:28 +020014707 {
14708 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14709 .name = "Channel Mode",
14710 .info = alc_ch_mode_info,
14711 .get = alc_ch_mode_get,
14712 .put = alc_ch_mode_put,
14713 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14714 },
14715 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014716};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014717
14718static struct snd_kcontrol_new alc861_asus_mixer[] = {
14719 /* output mixer control */
14720 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14721 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14722 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14723 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14724 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14725
14726 /* Input mixer control */
14727 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14728 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14729 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14730 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14731 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14732 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14734 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14735 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14737
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014738 {
14739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14740 .name = "Channel Mode",
14741 .info = alc_ch_mode_info,
14742 .get = alc_ch_mode_get,
14743 .put = alc_ch_mode_put,
14744 .private_value = ARRAY_SIZE(alc861_asus_modes),
14745 },
14746 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014747};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014748
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014749/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014750static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014751 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14752 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014753 { }
14754};
14755
Kailang Yangdf694da2005-12-05 19:42:22 +010014756/*
14757 * generic initialization of ADC, input mixers and output mixers
14758 */
14759static struct hda_verb alc861_base_init_verbs[] = {
14760 /*
14761 * Unmute ADC0 and set the default input to mic-in
14762 */
14763 /* port-A for surround (rear panel) */
14764 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14765 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14766 /* port-B for mic-in (rear panel) with vref */
14767 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14768 /* port-C for line-in (rear panel) */
14769 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14770 /* port-D for Front */
14771 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14772 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14773 /* port-E for HP out (front panel) */
14774 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14775 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014776 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014777 /* port-F for mic-in (front panel) with vref */
14778 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14779 /* port-G for CLFE (rear panel) */
14780 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14781 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14782 /* port-H for side (rear panel) */
14783 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14784 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14785 /* CD-in */
14786 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14787 /* route front mic to ADC1*/
14788 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14789 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014790
Kailang Yangdf694da2005-12-05 19:42:22 +010014791 /* Unmute DAC0~3 & spdif out*/
14792 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14793 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14794 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14795 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014797
Kailang Yangdf694da2005-12-05 19:42:22 +010014798 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14799 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14800 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14801 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14802 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014803
Kailang Yangdf694da2005-12-05 19:42:22 +010014804 /* Unmute Stereo Mixer 15 */
14805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14806 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14807 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014809
14810 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14813 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14814 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14815 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14816 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14817 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014818 /* hp used DAC 3 (Front) */
14819 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014820 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14821
14822 { }
14823};
14824
14825static struct hda_verb alc861_threestack_init_verbs[] = {
14826 /*
14827 * Unmute ADC0 and set the default input to mic-in
14828 */
14829 /* port-A for surround (rear panel) */
14830 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14831 /* port-B for mic-in (rear panel) with vref */
14832 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14833 /* port-C for line-in (rear panel) */
14834 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14835 /* port-D for Front */
14836 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14837 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14838 /* port-E for HP out (front panel) */
14839 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14840 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014841 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014842 /* port-F for mic-in (front panel) with vref */
14843 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14844 /* port-G for CLFE (rear panel) */
14845 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14846 /* port-H for side (rear panel) */
14847 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14848 /* CD-in */
14849 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14850 /* route front mic to ADC1*/
14851 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14852 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14853 /* Unmute DAC0~3 & spdif out*/
14854 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14855 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14856 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14857 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014859
Kailang Yangdf694da2005-12-05 19:42:22 +010014860 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14861 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14862 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14863 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14864 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014865
Kailang Yangdf694da2005-12-05 19:42:22 +010014866 /* Unmute Stereo Mixer 15 */
14867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14868 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014870 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014871
14872 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14873 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14874 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14875 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14876 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14877 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14878 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14879 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014880 /* hp used DAC 3 (Front) */
14881 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014882 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14883 { }
14884};
Takashi Iwai22309c32006-08-09 16:57:28 +020014885
14886static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14887 /*
14888 * Unmute ADC0 and set the default input to mic-in
14889 */
14890 /* port-A for surround (rear panel) */
14891 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14892 /* port-B for mic-in (rear panel) with vref */
14893 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14894 /* port-C for line-in (rear panel) */
14895 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14896 /* port-D for Front */
14897 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14898 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14899 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014900 /* this has to be set to VREF80 */
14901 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014902 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014903 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014904 /* port-F for mic-in (front panel) with vref */
14905 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14906 /* port-G for CLFE (rear panel) */
14907 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14908 /* port-H for side (rear panel) */
14909 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14910 /* CD-in */
14911 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14912 /* route front mic to ADC1*/
14913 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14914 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14915 /* Unmute DAC0~3 & spdif out*/
14916 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14917 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14918 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14919 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014921
Takashi Iwai22309c32006-08-09 16:57:28 +020014922 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14923 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14924 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14925 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14926 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014927
Takashi Iwai22309c32006-08-09 16:57:28 +020014928 /* Unmute Stereo Mixer 15 */
14929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014933
14934 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14935 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14936 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14939 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14940 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14941 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014942 /* hp used DAC 3 (Front) */
14943 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014944 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14945 { }
14946};
14947
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014948static struct hda_verb alc861_asus_init_verbs[] = {
14949 /*
14950 * Unmute ADC0 and set the default input to mic-in
14951 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014952 /* port-A for surround (rear panel)
14953 * according to codec#0 this is the HP jack
14954 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014955 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14956 /* route front PCM to HP */
14957 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14958 /* port-B for mic-in (rear panel) with vref */
14959 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14960 /* port-C for line-in (rear panel) */
14961 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14962 /* port-D for Front */
14963 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14964 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14965 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014966 /* this has to be set to VREF80 */
14967 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014968 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014969 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014970 /* port-F for mic-in (front panel) with vref */
14971 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14972 /* port-G for CLFE (rear panel) */
14973 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14974 /* port-H for side (rear panel) */
14975 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14976 /* CD-in */
14977 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14978 /* route front mic to ADC1*/
14979 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14980 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14981 /* Unmute DAC0~3 & spdif out*/
14982 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14983 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14984 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14985 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14986 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14987 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14988 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14989 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14990 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14991 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014992
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014993 /* Unmute Stereo Mixer 15 */
14994 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014998
14999 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15000 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15001 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15002 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15003 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15004 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15005 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15006 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015007 /* hp used DAC 3 (Front) */
15008 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015009 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15010 { }
15011};
15012
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015013/* additional init verbs for ASUS laptops */
15014static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15015 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15016 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15017 { }
15018};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015019
Kailang Yangdf694da2005-12-05 19:42:22 +010015020/*
15021 * generic initialization of ADC, input mixers and output mixers
15022 */
15023static struct hda_verb alc861_auto_init_verbs[] = {
15024 /*
15025 * Unmute ADC0 and set the default input to mic-in
15026 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015027 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015029
Kailang Yangdf694da2005-12-05 19:42:22 +010015030 /* Unmute DAC0~3 & spdif out*/
15031 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15032 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15033 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15034 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015036
Kailang Yangdf694da2005-12-05 19:42:22 +010015037 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15038 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15039 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15040 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15041 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015042
Kailang Yangdf694da2005-12-05 19:42:22 +010015043 /* Unmute Stereo Mixer 15 */
15044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15045 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15046 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15047 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15048
Takashi Iwai1c209302009-07-22 15:17:45 +020015049 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15050 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15051 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15052 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15053 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15054 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15055 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15056 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015057
15058 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15059 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015060 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15061 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15063 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015064 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15065 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015066
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015067 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015068
15069 { }
15070};
15071
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015072static struct hda_verb alc861_toshiba_init_verbs[] = {
15073 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015074
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015075 { }
15076};
15077
15078/* toggle speaker-output according to the hp-jack state */
15079static void alc861_toshiba_automute(struct hda_codec *codec)
15080{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015081 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015082
Takashi Iwai47fd8302007-08-10 17:11:07 +020015083 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15084 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15085 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15086 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015087}
15088
15089static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15090 unsigned int res)
15091{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015092 if ((res >> 26) == ALC880_HP_EVENT)
15093 alc861_toshiba_automute(codec);
15094}
15095
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015096/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015097#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15098#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15099#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15100#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15101
15102
15103#define ALC861_DIGOUT_NID 0x07
15104
15105static struct hda_channel_mode alc861_8ch_modes[1] = {
15106 { 8, NULL }
15107};
15108
15109static hda_nid_t alc861_dac_nids[4] = {
15110 /* front, surround, clfe, side */
15111 0x03, 0x06, 0x05, 0x04
15112};
15113
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015114static hda_nid_t alc660_dac_nids[3] = {
15115 /* front, clfe, surround */
15116 0x03, 0x05, 0x06
15117};
15118
Kailang Yangdf694da2005-12-05 19:42:22 +010015119static hda_nid_t alc861_adc_nids[1] = {
15120 /* ADC0-2 */
15121 0x08,
15122};
15123
15124static struct hda_input_mux alc861_capture_source = {
15125 .num_items = 5,
15126 .items = {
15127 { "Mic", 0x0 },
15128 { "Front Mic", 0x3 },
15129 { "Line", 0x1 },
15130 { "CD", 0x4 },
15131 { "Mixer", 0x5 },
15132 },
15133};
15134
Takashi Iwai1c209302009-07-22 15:17:45 +020015135static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15136{
15137 struct alc_spec *spec = codec->spec;
15138 hda_nid_t mix, srcs[5];
15139 int i, j, num;
15140
15141 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15142 return 0;
15143 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15144 if (num < 0)
15145 return 0;
15146 for (i = 0; i < num; i++) {
15147 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015148 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015149 if (type != AC_WID_AUD_OUT)
15150 continue;
15151 for (j = 0; j < spec->multiout.num_dacs; j++)
15152 if (spec->multiout.dac_nids[j] == srcs[i])
15153 break;
15154 if (j >= spec->multiout.num_dacs)
15155 return srcs[i];
15156 }
15157 return 0;
15158}
15159
Kailang Yangdf694da2005-12-05 19:42:22 +010015160/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015161static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015162 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015163{
Takashi Iwai1c209302009-07-22 15:17:45 +020015164 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015165 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015166 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015167
15168 spec->multiout.dac_nids = spec->private_dac_nids;
15169 for (i = 0; i < cfg->line_outs; i++) {
15170 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015171 dac = alc861_look_for_dac(codec, nid);
15172 if (!dac)
15173 continue;
15174 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015175 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015176 return 0;
15177}
15178
Takashi Iwai1c209302009-07-22 15:17:45 +020015179static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15180 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015181{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015182 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015183 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15184}
15185
15186/* add playback controls from the parsed DAC table */
15187static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15188 const struct auto_pin_cfg *cfg)
15189{
15190 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015191 static const char *chname[4] = {
15192 "Front", "Surround", NULL /*CLFE*/, "Side"
15193 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015194 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015195 int i, err;
15196
15197 if (cfg->line_outs == 1) {
15198 const char *pfx = NULL;
15199 if (!cfg->hp_outs)
15200 pfx = "Master";
15201 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15202 pfx = "Speaker";
15203 if (pfx) {
15204 nid = spec->multiout.dac_nids[0];
15205 return alc861_create_out_sw(codec, pfx, nid, 3);
15206 }
15207 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015208
15209 for (i = 0; i < cfg->line_outs; i++) {
15210 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015211 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015212 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015213 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015214 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015215 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015216 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015217 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015218 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015219 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015220 return err;
15221 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015222 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015223 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015224 return err;
15225 }
15226 }
15227 return 0;
15228}
15229
Takashi Iwai1c209302009-07-22 15:17:45 +020015230static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015231{
Takashi Iwai1c209302009-07-22 15:17:45 +020015232 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015233 int err;
15234 hda_nid_t nid;
15235
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015236 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015237 return 0;
15238
15239 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015240 nid = alc861_look_for_dac(codec, pin);
15241 if (nid) {
15242 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15243 if (err < 0)
15244 return err;
15245 spec->multiout.hp_nid = nid;
15246 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015247 }
15248 return 0;
15249}
15250
15251/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015252static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015253 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015254{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015255 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015256}
15257
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015258static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15259 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015260 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015261{
Takashi Iwai1c209302009-07-22 15:17:45 +020015262 hda_nid_t mix, srcs[5];
15263 int i, num;
15264
Jacek Luczak564c5be2008-05-03 18:41:23 +020015265 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15266 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015267 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015268 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015269 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15270 return;
15271 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15272 if (num < 0)
15273 return;
15274 for (i = 0; i < num; i++) {
15275 unsigned int mute;
15276 if (srcs[i] == dac || srcs[i] == 0x15)
15277 mute = AMP_IN_UNMUTE(i);
15278 else
15279 mute = AMP_IN_MUTE(i);
15280 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15281 mute);
15282 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015283}
15284
15285static void alc861_auto_init_multi_out(struct hda_codec *codec)
15286{
15287 struct alc_spec *spec = codec->spec;
15288 int i;
15289
15290 for (i = 0; i < spec->autocfg.line_outs; i++) {
15291 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015292 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015293 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015294 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015295 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015296 }
15297}
15298
15299static void alc861_auto_init_hp_out(struct hda_codec *codec)
15300{
15301 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015302
Takashi Iwai15870f02009-10-05 08:25:13 +020015303 if (spec->autocfg.hp_outs)
15304 alc861_auto_set_output_and_unmute(codec,
15305 spec->autocfg.hp_pins[0],
15306 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015307 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015308 if (spec->autocfg.speaker_outs)
15309 alc861_auto_set_output_and_unmute(codec,
15310 spec->autocfg.speaker_pins[0],
15311 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015312 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015313}
15314
15315static void alc861_auto_init_analog_input(struct hda_codec *codec)
15316{
15317 struct alc_spec *spec = codec->spec;
15318 int i;
15319
15320 for (i = 0; i < AUTO_PIN_LAST; i++) {
15321 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015322 if (nid >= 0x0c && nid <= 0x11)
15323 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015324 }
15325}
15326
15327/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015328/* return 1 if successful, 0 if the proper config is not found,
15329 * or a negative error code
15330 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015331static int alc861_parse_auto_config(struct hda_codec *codec)
15332{
15333 struct alc_spec *spec = codec->spec;
15334 int err;
15335 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15336
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015337 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15338 alc861_ignore);
15339 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015340 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015341 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015342 return 0; /* can't find valid BIOS pin config */
15343
Takashi Iwai1c209302009-07-22 15:17:45 +020015344 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015345 if (err < 0)
15346 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015347 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015348 if (err < 0)
15349 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015350 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015351 if (err < 0)
15352 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015353 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015354 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015355 return err;
15356
15357 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15358
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015359 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015360 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15361
Takashi Iwai603c4012008-07-30 15:01:44 +020015362 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015363 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015364
Takashi Iwaid88897e2008-10-31 15:01:37 +010015365 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015366
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015367 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015368 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015369
15370 spec->adc_nids = alc861_adc_nids;
15371 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015372 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015373
Kailang Yang6227cdc2010-02-25 08:36:52 +010015374 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015375
Kailang Yangdf694da2005-12-05 19:42:22 +010015376 return 1;
15377}
15378
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015379/* additional initialization for auto-configuration model */
15380static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015381{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015382 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015383 alc861_auto_init_multi_out(codec);
15384 alc861_auto_init_hp_out(codec);
15385 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015386 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015387 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015388}
15389
Takashi Iwaicb53c622007-08-10 17:21:45 +020015390#ifdef CONFIG_SND_HDA_POWER_SAVE
15391static struct hda_amp_list alc861_loopbacks[] = {
15392 { 0x15, HDA_INPUT, 0 },
15393 { 0x15, HDA_INPUT, 1 },
15394 { 0x15, HDA_INPUT, 2 },
15395 { 0x15, HDA_INPUT, 3 },
15396 { } /* end */
15397};
15398#endif
15399
Kailang Yangdf694da2005-12-05 19:42:22 +010015400
15401/*
15402 * configuration and preset
15403 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015404static const char *alc861_models[ALC861_MODEL_LAST] = {
15405 [ALC861_3ST] = "3stack",
15406 [ALC660_3ST] = "3stack-660",
15407 [ALC861_3ST_DIG] = "3stack-dig",
15408 [ALC861_6ST_DIG] = "6stack-dig",
15409 [ALC861_UNIWILL_M31] = "uniwill-m31",
15410 [ALC861_TOSHIBA] = "toshiba",
15411 [ALC861_ASUS] = "asus",
15412 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15413 [ALC861_AUTO] = "auto",
15414};
15415
15416static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015417 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015418 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15419 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15420 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015421 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015422 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015423 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015424 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15425 * Any other models that need this preset?
15426 */
15427 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015428 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15429 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015430 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15431 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15432 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15433 /* FIXME: the below seems conflict */
15434 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15435 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15436 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015437 {}
15438};
15439
15440static struct alc_config_preset alc861_presets[] = {
15441 [ALC861_3ST] = {
15442 .mixers = { alc861_3ST_mixer },
15443 .init_verbs = { alc861_threestack_init_verbs },
15444 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15445 .dac_nids = alc861_dac_nids,
15446 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15447 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015448 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015449 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15450 .adc_nids = alc861_adc_nids,
15451 .input_mux = &alc861_capture_source,
15452 },
15453 [ALC861_3ST_DIG] = {
15454 .mixers = { alc861_base_mixer },
15455 .init_verbs = { alc861_threestack_init_verbs },
15456 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15457 .dac_nids = alc861_dac_nids,
15458 .dig_out_nid = ALC861_DIGOUT_NID,
15459 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15460 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015461 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015462 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15463 .adc_nids = alc861_adc_nids,
15464 .input_mux = &alc861_capture_source,
15465 },
15466 [ALC861_6ST_DIG] = {
15467 .mixers = { alc861_base_mixer },
15468 .init_verbs = { alc861_base_init_verbs },
15469 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15470 .dac_nids = alc861_dac_nids,
15471 .dig_out_nid = ALC861_DIGOUT_NID,
15472 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15473 .channel_mode = alc861_8ch_modes,
15474 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15475 .adc_nids = alc861_adc_nids,
15476 .input_mux = &alc861_capture_source,
15477 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015478 [ALC660_3ST] = {
15479 .mixers = { alc861_3ST_mixer },
15480 .init_verbs = { alc861_threestack_init_verbs },
15481 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15482 .dac_nids = alc660_dac_nids,
15483 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15484 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015485 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015486 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15487 .adc_nids = alc861_adc_nids,
15488 .input_mux = &alc861_capture_source,
15489 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015490 [ALC861_UNIWILL_M31] = {
15491 .mixers = { alc861_uniwill_m31_mixer },
15492 .init_verbs = { alc861_uniwill_m31_init_verbs },
15493 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15494 .dac_nids = alc861_dac_nids,
15495 .dig_out_nid = ALC861_DIGOUT_NID,
15496 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15497 .channel_mode = alc861_uniwill_m31_modes,
15498 .need_dac_fix = 1,
15499 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15500 .adc_nids = alc861_adc_nids,
15501 .input_mux = &alc861_capture_source,
15502 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015503 [ALC861_TOSHIBA] = {
15504 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015505 .init_verbs = { alc861_base_init_verbs,
15506 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015507 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15508 .dac_nids = alc861_dac_nids,
15509 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15510 .channel_mode = alc883_3ST_2ch_modes,
15511 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15512 .adc_nids = alc861_adc_nids,
15513 .input_mux = &alc861_capture_source,
15514 .unsol_event = alc861_toshiba_unsol_event,
15515 .init_hook = alc861_toshiba_automute,
15516 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015517 [ALC861_ASUS] = {
15518 .mixers = { alc861_asus_mixer },
15519 .init_verbs = { alc861_asus_init_verbs },
15520 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15521 .dac_nids = alc861_dac_nids,
15522 .dig_out_nid = ALC861_DIGOUT_NID,
15523 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15524 .channel_mode = alc861_asus_modes,
15525 .need_dac_fix = 1,
15526 .hp_nid = 0x06,
15527 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15528 .adc_nids = alc861_adc_nids,
15529 .input_mux = &alc861_capture_source,
15530 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015531 [ALC861_ASUS_LAPTOP] = {
15532 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15533 .init_verbs = { alc861_asus_init_verbs,
15534 alc861_asus_laptop_init_verbs },
15535 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15536 .dac_nids = alc861_dac_nids,
15537 .dig_out_nid = ALC861_DIGOUT_NID,
15538 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15539 .channel_mode = alc883_3ST_2ch_modes,
15540 .need_dac_fix = 1,
15541 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15542 .adc_nids = alc861_adc_nids,
15543 .input_mux = &alc861_capture_source,
15544 },
15545};
Kailang Yangdf694da2005-12-05 19:42:22 +010015546
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015547/* Pin config fixes */
15548enum {
15549 PINFIX_FSC_AMILO_PI1505,
15550};
15551
15552static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15553 { 0x0b, 0x0221101f }, /* HP */
15554 { 0x0f, 0x90170310 }, /* speaker */
15555 { }
15556};
15557
15558static const struct alc_fixup alc861_fixups[] = {
15559 [PINFIX_FSC_AMILO_PI1505] = {
15560 .pins = alc861_fsc_amilo_pi1505_pinfix
15561 },
15562};
15563
15564static struct snd_pci_quirk alc861_fixup_tbl[] = {
15565 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15566 {}
15567};
Kailang Yangdf694da2005-12-05 19:42:22 +010015568
15569static int patch_alc861(struct hda_codec *codec)
15570{
15571 struct alc_spec *spec;
15572 int board_config;
15573 int err;
15574
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015575 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015576 if (spec == NULL)
15577 return -ENOMEM;
15578
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015579 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015580
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015581 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15582 alc861_models,
15583 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015584
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015585 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015586 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15587 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015588 board_config = ALC861_AUTO;
15589 }
15590
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015591 if (board_config == ALC861_AUTO)
15592 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015593
Kailang Yangdf694da2005-12-05 19:42:22 +010015594 if (board_config == ALC861_AUTO) {
15595 /* automatic parse from the BIOS config */
15596 err = alc861_parse_auto_config(codec);
15597 if (err < 0) {
15598 alc_free(codec);
15599 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015600 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015601 printk(KERN_INFO
15602 "hda_codec: Cannot set up configuration "
15603 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015604 board_config = ALC861_3ST_DIG;
15605 }
15606 }
15607
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015608 err = snd_hda_attach_beep_device(codec, 0x23);
15609 if (err < 0) {
15610 alc_free(codec);
15611 return err;
15612 }
15613
Kailang Yangdf694da2005-12-05 19:42:22 +010015614 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015615 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015616
Kailang Yangdf694da2005-12-05 19:42:22 +010015617 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15618 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15619
Kailang Yangdf694da2005-12-05 19:42:22 +010015620 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15621 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15622
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015623 if (!spec->cap_mixer)
15624 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015625 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15626
Takashi Iwai2134ea42008-01-10 16:53:55 +010015627 spec->vmaster_nid = 0x03;
15628
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015629 if (board_config == ALC861_AUTO)
15630 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15631
Kailang Yangdf694da2005-12-05 19:42:22 +010015632 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015633 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015634 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015635#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015636 spec->power_hook = alc_power_eapd;
15637#endif
15638 }
15639#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015640 if (!spec->loopback.amplist)
15641 spec->loopback.amplist = alc861_loopbacks;
15642#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015643
Kailang Yangdf694da2005-12-05 19:42:22 +010015644 return 0;
15645}
15646
15647/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015648 * ALC861-VD support
15649 *
15650 * Based on ALC882
15651 *
15652 * In addition, an independent DAC
15653 */
15654#define ALC861VD_DIGOUT_NID 0x06
15655
15656static hda_nid_t alc861vd_dac_nids[4] = {
15657 /* front, surr, clfe, side surr */
15658 0x02, 0x03, 0x04, 0x05
15659};
15660
15661/* dac_nids for ALC660vd are in a different order - according to
15662 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015663 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015664 * of ALC660vd codecs, but for now there is only 3stack mixer
15665 * - and it is the same as in 861vd.
15666 * adc_nids in ALC660vd are (is) the same as in 861vd
15667 */
15668static hda_nid_t alc660vd_dac_nids[3] = {
15669 /* front, rear, clfe, rear_surr */
15670 0x02, 0x04, 0x03
15671};
15672
15673static hda_nid_t alc861vd_adc_nids[1] = {
15674 /* ADC0 */
15675 0x09,
15676};
15677
Takashi Iwaie1406342008-02-11 18:32:32 +010015678static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15679
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015680/* input MUX */
15681/* FIXME: should be a matrix-type input source selection */
15682static struct hda_input_mux alc861vd_capture_source = {
15683 .num_items = 4,
15684 .items = {
15685 { "Mic", 0x0 },
15686 { "Front Mic", 0x1 },
15687 { "Line", 0x2 },
15688 { "CD", 0x4 },
15689 },
15690};
15691
Kailang Yang272a5272007-05-14 11:00:38 +020015692static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015693 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015694 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015695 { "Ext Mic", 0x0 },
15696 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015697 },
15698};
15699
Kailang Yangd1a991a2007-08-15 16:21:59 +020015700static struct hda_input_mux alc861vd_hp_capture_source = {
15701 .num_items = 2,
15702 .items = {
15703 { "Front Mic", 0x0 },
15704 { "ATAPI Mic", 0x1 },
15705 },
15706};
15707
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015708/*
15709 * 2ch mode
15710 */
15711static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15712 { 2, NULL }
15713};
15714
15715/*
15716 * 6ch mode
15717 */
15718static struct hda_verb alc861vd_6stack_ch6_init[] = {
15719 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15720 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15721 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15722 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15723 { } /* end */
15724};
15725
15726/*
15727 * 8ch mode
15728 */
15729static struct hda_verb alc861vd_6stack_ch8_init[] = {
15730 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15731 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15732 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15733 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15734 { } /* end */
15735};
15736
15737static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15738 { 6, alc861vd_6stack_ch6_init },
15739 { 8, alc861vd_6stack_ch8_init },
15740};
15741
15742static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15743 {
15744 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15745 .name = "Channel Mode",
15746 .info = alc_ch_mode_info,
15747 .get = alc_ch_mode_get,
15748 .put = alc_ch_mode_put,
15749 },
15750 { } /* end */
15751};
15752
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015753/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15754 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15755 */
15756static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15757 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15758 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15759
15760 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15761 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15762
15763 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15764 HDA_OUTPUT),
15765 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15766 HDA_OUTPUT),
15767 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15768 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15769
15770 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15771 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15772
15773 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15774
15775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15778
15779 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15780 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15781 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15782
15783 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15784 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15785
15786 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15787 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15788
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015789 { } /* end */
15790};
15791
15792static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15793 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15794 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15795
15796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15797
15798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15801
15802 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15803 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15804 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15805
15806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15808
15809 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15810 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15811
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015812 { } /* end */
15813};
15814
Kailang Yangbdd148a2007-05-08 15:19:08 +020015815static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15816 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15817 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15818 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15819
15820 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15821
15822 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15825
15826 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15827 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15828 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15829
15830 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15831 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15832
15833 { } /* end */
15834};
15835
Tobin Davisb419f342008-03-07 11:57:51 +010015836/* Pin assignment: Speaker=0x14, HP = 0x15,
15837 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015838 */
15839static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015840 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15841 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015842 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15843 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015844 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15845 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15846 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15847 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15848 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15849 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015850 { } /* end */
15851};
15852
Kailang Yangd1a991a2007-08-15 16:21:59 +020015853/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15854 * Front Mic=0x18, ATAPI Mic = 0x19,
15855 */
15856static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15857 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15858 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15859 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15860 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15861 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15862 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15863 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15864 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015865
Kailang Yangd1a991a2007-08-15 16:21:59 +020015866 { } /* end */
15867};
15868
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015869/*
15870 * generic initialization of ADC, input mixers and output mixers
15871 */
15872static struct hda_verb alc861vd_volume_init_verbs[] = {
15873 /*
15874 * Unmute ADC0 and set the default input to mic-in
15875 */
15876 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15877 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15878
15879 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15880 * the analog-loopback mixer widget
15881 */
15882 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015888
15889 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015890 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015894
15895 /*
15896 * Set up output mixers (0x02 - 0x05)
15897 */
15898 /* set vol=0 to output mixers */
15899 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15900 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15901 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15902 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15903
15904 /* set up input amps for analog loopback */
15905 /* Amp Indices: DAC = 0, mixer = 1 */
15906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15911 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15912 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15913 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15914
15915 { }
15916};
15917
15918/*
15919 * 3-stack pin configuration:
15920 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15921 */
15922static struct hda_verb alc861vd_3stack_init_verbs[] = {
15923 /*
15924 * Set pin mode and muting
15925 */
15926 /* set front pin widgets 0x14 for output */
15927 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15928 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15929 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15930
15931 /* Mic (rear) pin: input vref at 80% */
15932 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15933 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15934 /* Front Mic pin: input vref at 80% */
15935 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15936 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15937 /* Line In pin: input */
15938 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15939 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15940 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15941 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15942 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15943 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15944 /* CD pin widget for input */
15945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15946
15947 { }
15948};
15949
15950/*
15951 * 6-stack pin configuration:
15952 */
15953static struct hda_verb alc861vd_6stack_init_verbs[] = {
15954 /*
15955 * Set pin mode and muting
15956 */
15957 /* set front pin widgets 0x14 for output */
15958 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15960 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15961
15962 /* Rear Pin: output 1 (0x0d) */
15963 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15964 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15965 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15966 /* CLFE Pin: output 2 (0x0e) */
15967 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15968 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15969 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15970 /* Side Pin: output 3 (0x0f) */
15971 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15972 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15973 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15974
15975 /* Mic (rear) pin: input vref at 80% */
15976 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15977 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15978 /* Front Mic pin: input vref at 80% */
15979 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15980 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15981 /* Line In pin: input */
15982 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15983 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15984 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15985 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15986 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15987 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15988 /* CD pin widget for input */
15989 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15990
15991 { }
15992};
15993
Kailang Yangbdd148a2007-05-08 15:19:08 +020015994static struct hda_verb alc861vd_eapd_verbs[] = {
15995 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15996 { }
15997};
15998
Kailang Yangf9423e72008-05-27 12:32:25 +020015999static struct hda_verb alc660vd_eapd_verbs[] = {
16000 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16001 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16002 { }
16003};
16004
Kailang Yangbdd148a2007-05-08 15:19:08 +020016005static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16009 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016010 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016011 {}
16012};
16013
Kailang Yangbdd148a2007-05-08 15:19:08 +020016014static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16015{
16016 unsigned int present;
16017 unsigned char bits;
16018
Wu Fengguang864f92b2009-11-18 12:38:02 +080016019 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016020 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016021
Takashi Iwai47fd8302007-08-10 17:11:07 +020016022 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16023 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016024}
16025
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016026static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016027{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016028 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016029 spec->autocfg.hp_pins[0] = 0x1b;
16030 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016031}
16032
16033static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16034{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016035 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016036 alc861vd_lenovo_mic_automute(codec);
16037}
16038
16039static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16040 unsigned int res)
16041{
16042 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016043 case ALC880_MIC_EVENT:
16044 alc861vd_lenovo_mic_automute(codec);
16045 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016046 default:
16047 alc_automute_amp_unsol_event(codec, res);
16048 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016049 }
16050}
16051
Kailang Yang272a5272007-05-14 11:00:38 +020016052static struct hda_verb alc861vd_dallas_verbs[] = {
16053 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16054 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16055 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16056 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16057
16058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16060 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16061 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16062 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16064 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16065 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016066
Kailang Yang272a5272007-05-14 11:00:38 +020016067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16068 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16069 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16071 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16072 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16073 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16074 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16075
16076 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16077 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16078 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16079 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16080 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16081 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16082 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16083 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16084
16085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16089
16090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016091 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016092 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16093
16094 { } /* end */
16095};
16096
16097/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016098static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016099{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016100 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016101
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016102 spec->autocfg.hp_pins[0] = 0x15;
16103 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016104}
16105
Takashi Iwaicb53c622007-08-10 17:21:45 +020016106#ifdef CONFIG_SND_HDA_POWER_SAVE
16107#define alc861vd_loopbacks alc880_loopbacks
16108#endif
16109
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016110/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016111#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16112#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16113#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16114#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16115
16116/*
16117 * configuration and preset
16118 */
16119static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16120 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016121 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016122 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016123 [ALC861VD_3ST] = "3stack",
16124 [ALC861VD_3ST_DIG] = "3stack-digout",
16125 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016126 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016127 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016128 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016129 [ALC861VD_AUTO] = "auto",
16130};
16131
16132static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016133 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16134 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016135 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016136 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016137 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016138 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016139 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016140 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016141 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016142 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016143 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016144 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016145 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016146 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016147 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016148 {}
16149};
16150
16151static struct alc_config_preset alc861vd_presets[] = {
16152 [ALC660VD_3ST] = {
16153 .mixers = { alc861vd_3st_mixer },
16154 .init_verbs = { alc861vd_volume_init_verbs,
16155 alc861vd_3stack_init_verbs },
16156 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16157 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016158 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16159 .channel_mode = alc861vd_3stack_2ch_modes,
16160 .input_mux = &alc861vd_capture_source,
16161 },
Mike Crash6963f842007-06-25 12:12:51 +020016162 [ALC660VD_3ST_DIG] = {
16163 .mixers = { alc861vd_3st_mixer },
16164 .init_verbs = { alc861vd_volume_init_verbs,
16165 alc861vd_3stack_init_verbs },
16166 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16167 .dac_nids = alc660vd_dac_nids,
16168 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016169 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16170 .channel_mode = alc861vd_3stack_2ch_modes,
16171 .input_mux = &alc861vd_capture_source,
16172 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016173 [ALC861VD_3ST] = {
16174 .mixers = { alc861vd_3st_mixer },
16175 .init_verbs = { alc861vd_volume_init_verbs,
16176 alc861vd_3stack_init_verbs },
16177 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16178 .dac_nids = alc861vd_dac_nids,
16179 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16180 .channel_mode = alc861vd_3stack_2ch_modes,
16181 .input_mux = &alc861vd_capture_source,
16182 },
16183 [ALC861VD_3ST_DIG] = {
16184 .mixers = { alc861vd_3st_mixer },
16185 .init_verbs = { alc861vd_volume_init_verbs,
16186 alc861vd_3stack_init_verbs },
16187 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16188 .dac_nids = alc861vd_dac_nids,
16189 .dig_out_nid = ALC861VD_DIGOUT_NID,
16190 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16191 .channel_mode = alc861vd_3stack_2ch_modes,
16192 .input_mux = &alc861vd_capture_source,
16193 },
16194 [ALC861VD_6ST_DIG] = {
16195 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16196 .init_verbs = { alc861vd_volume_init_verbs,
16197 alc861vd_6stack_init_verbs },
16198 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16199 .dac_nids = alc861vd_dac_nids,
16200 .dig_out_nid = ALC861VD_DIGOUT_NID,
16201 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16202 .channel_mode = alc861vd_6stack_modes,
16203 .input_mux = &alc861vd_capture_source,
16204 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016205 [ALC861VD_LENOVO] = {
16206 .mixers = { alc861vd_lenovo_mixer },
16207 .init_verbs = { alc861vd_volume_init_verbs,
16208 alc861vd_3stack_init_verbs,
16209 alc861vd_eapd_verbs,
16210 alc861vd_lenovo_unsol_verbs },
16211 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16212 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016213 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16214 .channel_mode = alc861vd_3stack_2ch_modes,
16215 .input_mux = &alc861vd_capture_source,
16216 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016217 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016218 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016219 },
Kailang Yang272a5272007-05-14 11:00:38 +020016220 [ALC861VD_DALLAS] = {
16221 .mixers = { alc861vd_dallas_mixer },
16222 .init_verbs = { alc861vd_dallas_verbs },
16223 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16224 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016225 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16226 .channel_mode = alc861vd_3stack_2ch_modes,
16227 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016228 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016229 .setup = alc861vd_dallas_setup,
16230 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016231 },
16232 [ALC861VD_HP] = {
16233 .mixers = { alc861vd_hp_mixer },
16234 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16235 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16236 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016237 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016238 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16239 .channel_mode = alc861vd_3stack_2ch_modes,
16240 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016241 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016242 .setup = alc861vd_dallas_setup,
16243 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016244 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016245 [ALC660VD_ASUS_V1S] = {
16246 .mixers = { alc861vd_lenovo_mixer },
16247 .init_verbs = { alc861vd_volume_init_verbs,
16248 alc861vd_3stack_init_verbs,
16249 alc861vd_eapd_verbs,
16250 alc861vd_lenovo_unsol_verbs },
16251 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16252 .dac_nids = alc660vd_dac_nids,
16253 .dig_out_nid = ALC861VD_DIGOUT_NID,
16254 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16255 .channel_mode = alc861vd_3stack_2ch_modes,
16256 .input_mux = &alc861vd_capture_source,
16257 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016258 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016259 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016260 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016261};
16262
16263/*
16264 * BIOS auto configuration
16265 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016266static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16267 const struct auto_pin_cfg *cfg)
16268{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016269 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016270}
16271
16272
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016273static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16274 hda_nid_t nid, int pin_type, int dac_idx)
16275{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016276 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016277}
16278
16279static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16280{
16281 struct alc_spec *spec = codec->spec;
16282 int i;
16283
16284 for (i = 0; i <= HDA_SIDE; i++) {
16285 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016286 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016287 if (nid)
16288 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016289 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016290 }
16291}
16292
16293
16294static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16295{
16296 struct alc_spec *spec = codec->spec;
16297 hda_nid_t pin;
16298
16299 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016300 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016301 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016302 pin = spec->autocfg.speaker_pins[0];
16303 if (pin)
16304 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016305}
16306
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016307#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16308
16309static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16310{
16311 struct alc_spec *spec = codec->spec;
16312 int i;
16313
16314 for (i = 0; i < AUTO_PIN_LAST; i++) {
16315 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016316 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016317 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016318 if (nid != ALC861VD_PIN_CD_NID &&
16319 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016320 snd_hda_codec_write(codec, nid, 0,
16321 AC_VERB_SET_AMP_GAIN_MUTE,
16322 AMP_OUT_MUTE);
16323 }
16324 }
16325}
16326
Takashi Iwaif511b012008-08-15 16:46:42 +020016327#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16328
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016329#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16330#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16331
16332/* add playback controls from the parsed DAC table */
16333/* Based on ALC880 version. But ALC861VD has separate,
16334 * different NIDs for mute/unmute switch and volume control */
16335static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16336 const struct auto_pin_cfg *cfg)
16337{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016338 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16339 hda_nid_t nid_v, nid_s;
16340 int i, err;
16341
16342 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016343 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016344 continue;
16345 nid_v = alc861vd_idx_to_mixer_vol(
16346 alc880_dac_to_idx(
16347 spec->multiout.dac_nids[i]));
16348 nid_s = alc861vd_idx_to_mixer_switch(
16349 alc880_dac_to_idx(
16350 spec->multiout.dac_nids[i]));
16351
16352 if (i == 2) {
16353 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016354 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16355 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016356 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16357 HDA_OUTPUT));
16358 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016359 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016360 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16361 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016362 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16363 HDA_OUTPUT));
16364 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016365 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016366 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16367 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016368 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16369 HDA_INPUT));
16370 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016371 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016372 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16373 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016374 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16375 HDA_INPUT));
16376 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016377 return err;
16378 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016379 const char *pfx;
16380 if (cfg->line_outs == 1 &&
16381 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16382 if (!cfg->hp_pins)
16383 pfx = "Speaker";
16384 else
16385 pfx = "PCM";
16386 } else
16387 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016388 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016389 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16390 HDA_OUTPUT));
16391 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016392 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016393 if (cfg->line_outs == 1 &&
16394 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16395 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016396 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016397 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016398 HDA_INPUT));
16399 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016400 return err;
16401 }
16402 }
16403 return 0;
16404}
16405
16406/* add playback controls for speaker and HP outputs */
16407/* Based on ALC880 version. But ALC861VD has separate,
16408 * different NIDs for mute/unmute switch and volume control */
16409static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16410 hda_nid_t pin, const char *pfx)
16411{
16412 hda_nid_t nid_v, nid_s;
16413 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016414
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016415 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016416 return 0;
16417
16418 if (alc880_is_fixed_pin(pin)) {
16419 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16420 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016421 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016422 spec->multiout.hp_nid = nid_v;
16423 else
16424 spec->multiout.extra_out_nid[0] = nid_v;
16425 /* control HP volume/switch on the output mixer amp */
16426 nid_v = alc861vd_idx_to_mixer_vol(
16427 alc880_fixed_pin_idx(pin));
16428 nid_s = alc861vd_idx_to_mixer_switch(
16429 alc880_fixed_pin_idx(pin));
16430
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016431 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016432 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16433 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016434 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016435 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016436 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16437 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016438 return err;
16439 } else if (alc880_is_multi_pin(pin)) {
16440 /* set manual connection */
16441 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016442 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016443 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16444 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016445 return err;
16446 }
16447 return 0;
16448}
16449
16450/* parse the BIOS configuration and set up the alc_spec
16451 * return 1 if successful, 0 if the proper config is not found,
16452 * or a negative error code
16453 * Based on ALC880 version - had to change it to override
16454 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16455static int alc861vd_parse_auto_config(struct hda_codec *codec)
16456{
16457 struct alc_spec *spec = codec->spec;
16458 int err;
16459 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16460
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016461 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16462 alc861vd_ignore);
16463 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016464 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016465 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016466 return 0; /* can't find valid BIOS pin config */
16467
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016468 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16469 if (err < 0)
16470 return err;
16471 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16472 if (err < 0)
16473 return err;
16474 err = alc861vd_auto_create_extra_out(spec,
16475 spec->autocfg.speaker_pins[0],
16476 "Speaker");
16477 if (err < 0)
16478 return err;
16479 err = alc861vd_auto_create_extra_out(spec,
16480 spec->autocfg.hp_pins[0],
16481 "Headphone");
16482 if (err < 0)
16483 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016484 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016485 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016486 return err;
16487
16488 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16489
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016490 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016491 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16492
Takashi Iwai603c4012008-07-30 15:01:44 +020016493 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016494 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016495
Takashi Iwaid88897e2008-10-31 15:01:37 +010016496 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016497
16498 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016499 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016500
Takashi Iwai776e1842007-08-29 15:07:11 +020016501 err = alc_auto_add_mic_boost(codec);
16502 if (err < 0)
16503 return err;
16504
Kailang Yang6227cdc2010-02-25 08:36:52 +010016505 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016506
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016507 return 1;
16508}
16509
16510/* additional initialization for auto-configuration model */
16511static void alc861vd_auto_init(struct hda_codec *codec)
16512{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016513 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016514 alc861vd_auto_init_multi_out(codec);
16515 alc861vd_auto_init_hp_out(codec);
16516 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016517 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016518 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016519 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016520}
16521
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016522enum {
16523 ALC660VD_FIX_ASUS_GPIO1
16524};
16525
16526/* reset GPIO1 */
16527static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16528 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16529 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16530 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16531 { }
16532};
16533
16534static const struct alc_fixup alc861vd_fixups[] = {
16535 [ALC660VD_FIX_ASUS_GPIO1] = {
16536 .verbs = alc660vd_fix_asus_gpio1_verbs,
16537 },
16538};
16539
16540static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16541 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16542 {}
16543};
16544
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016545static int patch_alc861vd(struct hda_codec *codec)
16546{
16547 struct alc_spec *spec;
16548 int err, board_config;
16549
16550 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16551 if (spec == NULL)
16552 return -ENOMEM;
16553
16554 codec->spec = spec;
16555
16556 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16557 alc861vd_models,
16558 alc861vd_cfg_tbl);
16559
16560 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016561 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16562 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016563 board_config = ALC861VD_AUTO;
16564 }
16565
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016566 if (board_config == ALC861VD_AUTO)
16567 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016568
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016569 if (board_config == ALC861VD_AUTO) {
16570 /* automatic parse from the BIOS config */
16571 err = alc861vd_parse_auto_config(codec);
16572 if (err < 0) {
16573 alc_free(codec);
16574 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016575 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016576 printk(KERN_INFO
16577 "hda_codec: Cannot set up configuration "
16578 "from BIOS. Using base mode...\n");
16579 board_config = ALC861VD_3ST;
16580 }
16581 }
16582
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016583 err = snd_hda_attach_beep_device(codec, 0x23);
16584 if (err < 0) {
16585 alc_free(codec);
16586 return err;
16587 }
16588
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016589 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016590 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016591
Kailang Yang2f893282008-05-27 12:14:47 +020016592 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016593 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016594 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016595 }
16596
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016597 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16598 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16599
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016600 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16601 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16602
Takashi Iwaidd704692009-08-11 08:45:11 +020016603 if (!spec->adc_nids) {
16604 spec->adc_nids = alc861vd_adc_nids;
16605 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16606 }
16607 if (!spec->capsrc_nids)
16608 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016609
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016610 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016611 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016612
Takashi Iwai2134ea42008-01-10 16:53:55 +010016613 spec->vmaster_nid = 0x02;
16614
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016615 if (board_config == ALC861VD_AUTO)
16616 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16617
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016618 codec->patch_ops = alc_patch_ops;
16619
16620 if (board_config == ALC861VD_AUTO)
16621 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016622#ifdef CONFIG_SND_HDA_POWER_SAVE
16623 if (!spec->loopback.amplist)
16624 spec->loopback.amplist = alc861vd_loopbacks;
16625#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016626
16627 return 0;
16628}
16629
16630/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016631 * ALC662 support
16632 *
16633 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16634 * configuration. Each pin widget can choose any input DACs and a mixer.
16635 * Each ADC is connected from a mixer of all inputs. This makes possible
16636 * 6-channel independent captures.
16637 *
16638 * In addition, an independent DAC for the multi-playback (not used in this
16639 * driver yet).
16640 */
16641#define ALC662_DIGOUT_NID 0x06
16642#define ALC662_DIGIN_NID 0x0a
16643
16644static hda_nid_t alc662_dac_nids[4] = {
16645 /* front, rear, clfe, rear_surr */
16646 0x02, 0x03, 0x04
16647};
16648
Kailang Yang622e84c2009-04-21 07:39:04 +020016649static hda_nid_t alc272_dac_nids[2] = {
16650 0x02, 0x03
16651};
16652
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016653static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016654 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016655 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016656};
Takashi Iwaie1406342008-02-11 18:32:32 +010016657
Kailang Yang622e84c2009-04-21 07:39:04 +020016658static hda_nid_t alc272_adc_nids[1] = {
16659 /* ADC1-2 */
16660 0x08,
16661};
16662
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016663static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016664static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16665
Takashi Iwaie1406342008-02-11 18:32:32 +010016666
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016667/* input MUX */
16668/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016669static struct hda_input_mux alc662_capture_source = {
16670 .num_items = 4,
16671 .items = {
16672 { "Mic", 0x0 },
16673 { "Front Mic", 0x1 },
16674 { "Line", 0x2 },
16675 { "CD", 0x4 },
16676 },
16677};
16678
16679static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16680 .num_items = 2,
16681 .items = {
16682 { "Mic", 0x1 },
16683 { "Line", 0x2 },
16684 },
16685};
Kailang Yang291702f2007-10-16 14:28:03 +020016686
Kailang Yang6dda9f42008-05-27 12:05:31 +020016687static struct hda_input_mux alc663_capture_source = {
16688 .num_items = 3,
16689 .items = {
16690 { "Mic", 0x0 },
16691 { "Front Mic", 0x1 },
16692 { "Line", 0x2 },
16693 },
16694};
16695
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016696#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016697static struct hda_input_mux alc272_nc10_capture_source = {
16698 .num_items = 16,
16699 .items = {
16700 { "Autoselect Mic", 0x0 },
16701 { "Internal Mic", 0x1 },
16702 { "In-0x02", 0x2 },
16703 { "In-0x03", 0x3 },
16704 { "In-0x04", 0x4 },
16705 { "In-0x05", 0x5 },
16706 { "In-0x06", 0x6 },
16707 { "In-0x07", 0x7 },
16708 { "In-0x08", 0x8 },
16709 { "In-0x09", 0x9 },
16710 { "In-0x0a", 0x0a },
16711 { "In-0x0b", 0x0b },
16712 { "In-0x0c", 0x0c },
16713 { "In-0x0d", 0x0d },
16714 { "In-0x0e", 0x0e },
16715 { "In-0x0f", 0x0f },
16716 },
16717};
16718#endif
16719
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016720/*
16721 * 2ch mode
16722 */
16723static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16724 { 2, NULL }
16725};
16726
16727/*
16728 * 2ch mode
16729 */
16730static struct hda_verb alc662_3ST_ch2_init[] = {
16731 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16732 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16733 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16734 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16735 { } /* end */
16736};
16737
16738/*
16739 * 6ch mode
16740 */
16741static struct hda_verb alc662_3ST_ch6_init[] = {
16742 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16743 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16744 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16745 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16746 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16747 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16748 { } /* end */
16749};
16750
16751static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16752 { 2, alc662_3ST_ch2_init },
16753 { 6, alc662_3ST_ch6_init },
16754};
16755
16756/*
16757 * 2ch mode
16758 */
16759static struct hda_verb alc662_sixstack_ch6_init[] = {
16760 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16761 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16762 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16763 { } /* end */
16764};
16765
16766/*
16767 * 6ch mode
16768 */
16769static struct hda_verb alc662_sixstack_ch8_init[] = {
16770 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16771 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16772 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16773 { } /* end */
16774};
16775
16776static struct hda_channel_mode alc662_5stack_modes[2] = {
16777 { 2, alc662_sixstack_ch6_init },
16778 { 6, alc662_sixstack_ch8_init },
16779};
16780
16781/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16782 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16783 */
16784
16785static struct snd_kcontrol_new alc662_base_mixer[] = {
16786 /* output mixer control */
16787 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016788 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016789 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016790 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016791 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016793 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16794 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16796
16797 /*Input mixer control */
16798 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16799 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16800 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16801 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16802 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16803 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16804 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16805 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016806 { } /* end */
16807};
16808
16809static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16810 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016811 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16815 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16816 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16818 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16819 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16820 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016821 { } /* end */
16822};
16823
16824static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16825 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016826 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016827 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016828 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016829 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16830 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016831 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16832 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016842 { } /* end */
16843};
16844
16845static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16846 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16847 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016848 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16849 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16851 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16852 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016855 { } /* end */
16856};
16857
Kailang Yang291702f2007-10-16 14:28:03 +020016858static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016859 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16860 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016861
16862 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16863 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16864 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16865
16866 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16867 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16868 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16869 { } /* end */
16870};
16871
Kailang Yang8c427222008-01-10 13:03:59 +010016872static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016873 ALC262_HIPPO_MASTER_SWITCH,
16874 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016875 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016876 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16877 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016878 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16882 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16883 { } /* end */
16884};
16885
Kailang Yangf1d4e282008-08-26 14:03:29 +020016886static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16887 .ops = &snd_hda_bind_vol,
16888 .values = {
16889 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16890 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16891 0
16892 },
16893};
16894
16895static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16896 .ops = &snd_hda_bind_sw,
16897 .values = {
16898 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16899 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16900 0
16901 },
16902};
16903
Kailang Yang6dda9f42008-05-27 12:05:31 +020016904static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016905 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16906 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16909 { } /* end */
16910};
16911
16912static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16913 .ops = &snd_hda_bind_sw,
16914 .values = {
16915 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16916 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16917 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16918 0
16919 },
16920};
16921
16922static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16923 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16924 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16927 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16928 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16929
16930 { } /* end */
16931};
16932
16933static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16934 .ops = &snd_hda_bind_sw,
16935 .values = {
16936 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16937 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16938 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16939 0
16940 },
16941};
16942
16943static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16944 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16945 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16948 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16949 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16950 { } /* end */
16951};
16952
16953static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016954 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16955 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16959 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16960 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16961 { } /* end */
16962};
16963
16964static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16965 .ops = &snd_hda_bind_vol,
16966 .values = {
16967 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16968 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16969 0
16970 },
16971};
16972
16973static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16974 .ops = &snd_hda_bind_sw,
16975 .values = {
16976 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16977 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16978 0
16979 },
16980};
16981
16982static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16983 HDA_BIND_VOL("Master Playback Volume",
16984 &alc663_asus_two_bind_master_vol),
16985 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16986 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016990 { } /* end */
16991};
16992
16993static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16994 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16995 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16996 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16997 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017000 { } /* end */
17001};
17002
17003static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17005 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17006 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17007 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17009
17010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17011 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17012 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17013 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17014 { } /* end */
17015};
17016
17017static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17018 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17019 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17021
17022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17024 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17025 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17027 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17028 { } /* end */
17029};
17030
Kailang Yangebb83ee2009-12-17 12:23:00 +010017031static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17032 .ops = &snd_hda_bind_sw,
17033 .values = {
17034 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17035 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17036 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17037 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17038 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17039 0
17040 },
17041};
17042
17043static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17044 .ops = &snd_hda_bind_sw,
17045 .values = {
17046 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17047 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17048 0
17049 },
17050};
17051
17052static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17053 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17054 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17055 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17056 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17057 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17058 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17059 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17062 { } /* end */
17063};
17064
17065static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17066 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17067 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17068 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17069 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17070 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17072 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17073 { } /* end */
17074};
17075
17076
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017077static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17078 {
17079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17080 .name = "Channel Mode",
17081 .info = alc_ch_mode_info,
17082 .get = alc_ch_mode_get,
17083 .put = alc_ch_mode_put,
17084 },
17085 { } /* end */
17086};
17087
17088static struct hda_verb alc662_init_verbs[] = {
17089 /* ADC: mute amp left and right */
17090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17091 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017092
Kailang Yangb60dd392007-09-20 12:50:29 +020017093 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17095 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17096 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17097 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17098 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017099
17100 /* Front Pin: output 0 (0x0c) */
17101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17102 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17103
17104 /* Rear Pin: output 1 (0x0d) */
17105 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17107
17108 /* CLFE Pin: output 2 (0x0e) */
17109 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17110 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17111
17112 /* Mic (rear) pin: input vref at 80% */
17113 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17114 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17115 /* Front Mic pin: input vref at 80% */
17116 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17117 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17118 /* Line In pin: input */
17119 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17120 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17121 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17122 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17123 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17124 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17125 /* CD pin widget for input */
17126 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17127
17128 /* FIXME: use matrix-type input source selection */
17129 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17130 /* Input mixer */
17131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017132 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017133
17134 /* always trun on EAPD */
17135 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17136 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17137
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017138 { }
17139};
17140
Kailang Yangcec27c82010-02-04 14:18:18 +010017141static struct hda_verb alc663_init_verbs[] = {
17142 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17143 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17144 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17145 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17148 { }
17149};
17150
17151static struct hda_verb alc272_init_verbs[] = {
17152 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17153 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17154 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17155 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17156 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17157 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17158 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17159 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17160 { }
17161};
17162
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017163static struct hda_verb alc662_sue_init_verbs[] = {
17164 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17165 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017166 {}
17167};
17168
17169static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17170 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17171 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17172 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017173};
17174
Kailang Yang8c427222008-01-10 13:03:59 +010017175/* Set Unsolicited Event*/
17176static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17177 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17178 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17179 {}
17180};
17181
Kailang Yang6dda9f42008-05-27 12:05:31 +020017182static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17184 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017185 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17186 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017187 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017190 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17191 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17192 {}
17193};
17194
Kailang Yangf1d4e282008-08-26 14:03:29 +020017195static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17196 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17197 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17198 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17199 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17201 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17202 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17203 {}
17204};
17205
17206static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17207 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17208 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17209 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17210 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17213 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17214 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17215 {}
17216};
17217
17218static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17221 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17224 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17225 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17226 {}
17227};
17228
17229static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17230 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17231 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17232 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17233 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17236 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17239 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17240 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17241 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17242 {}
17243};
17244
17245static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17246 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17247 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17248 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17249 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17250 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17252 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17255 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17256 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17257 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17258 {}
17259};
17260
Kailang Yang6dda9f42008-05-27 12:05:31 +020017261static struct hda_verb alc663_g71v_init_verbs[] = {
17262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17263 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17264 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17265
17266 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17267 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17268 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17269
17270 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17271 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17272 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17273 {}
17274};
17275
17276static struct hda_verb alc663_g50v_init_verbs[] = {
17277 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17278 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17279 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17280
17281 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17282 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17283 {}
17284};
17285
Kailang Yangf1d4e282008-08-26 14:03:29 +020017286static struct hda_verb alc662_ecs_init_verbs[] = {
17287 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17289 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17290 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17291 {}
17292};
17293
Kailang Yang622e84c2009-04-21 07:39:04 +020017294static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17295 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17296 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17298 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17299 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17300 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17301 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17304 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17305 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17306 {}
17307};
17308
17309static struct hda_verb alc272_dell_init_verbs[] = {
17310 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17311 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17312 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17313 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17314 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17315 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17316 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17319 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17320 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17321 {}
17322};
17323
Kailang Yangebb83ee2009-12-17 12:23:00 +010017324static struct hda_verb alc663_mode7_init_verbs[] = {
17325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17326 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17327 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17328 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17329 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17330 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17331 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17332 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17333 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17334 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17335 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17336 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17337 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17338 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17339 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17340 {}
17341};
17342
17343static struct hda_verb alc663_mode8_init_verbs[] = {
17344 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17345 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17346 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17347 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17348 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17349 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17350 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17351 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17352 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17353 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17354 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17357 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17358 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17359 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17360 {}
17361};
17362
Kailang Yangf1d4e282008-08-26 14:03:29 +020017363static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17364 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17365 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17366 { } /* end */
17367};
17368
Kailang Yang622e84c2009-04-21 07:39:04 +020017369static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17370 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17371 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17372 { } /* end */
17373};
17374
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017375static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17376{
17377 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017378 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017379
Wu Fengguang864f92b2009-11-18 12:38:02 +080017380 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017381 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017382
Takashi Iwai47fd8302007-08-10 17:11:07 +020017383 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17384 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017385}
17386
17387static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17388{
17389 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017390 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017391
Wu Fengguang864f92b2009-11-18 12:38:02 +080017392 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017393 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017394
Takashi Iwai47fd8302007-08-10 17:11:07 +020017395 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17396 HDA_AMP_MUTE, bits);
17397 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17398 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017399}
17400
17401static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17402 unsigned int res)
17403{
17404 if ((res >> 26) == ALC880_HP_EVENT)
17405 alc662_lenovo_101e_all_automute(codec);
17406 if ((res >> 26) == ALC880_FRONT_EVENT)
17407 alc662_lenovo_101e_ispeaker_automute(codec);
17408}
17409
Kailang Yang291702f2007-10-16 14:28:03 +020017410/* unsolicited event for HP jack sensing */
17411static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17412 unsigned int res)
17413{
Kailang Yang291702f2007-10-16 14:28:03 +020017414 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017415 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017416 else
17417 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017418}
17419
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017420static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017421{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017422 struct alc_spec *spec = codec->spec;
17423
17424 alc262_hippo1_setup(codec);
17425 spec->ext_mic.pin = 0x18;
17426 spec->ext_mic.mux_idx = 0;
17427 spec->int_mic.pin = 0x19;
17428 spec->int_mic.mux_idx = 1;
17429 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017430}
17431
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017432static void alc662_eeepc_inithook(struct hda_codec *codec)
17433{
17434 alc262_hippo_automute(codec);
17435 alc_mic_automute(codec);
17436}
17437
17438static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017439{
Takashi Iwai42171c12009-05-08 14:11:43 +020017440 struct alc_spec *spec = codec->spec;
17441
17442 spec->autocfg.hp_pins[0] = 0x14;
17443 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017444}
17445
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017446#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17447
Kailang Yang6dda9f42008-05-27 12:05:31 +020017448static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17449{
17450 unsigned int present;
17451 unsigned char bits;
17452
Wu Fengguang864f92b2009-11-18 12:38:02 +080017453 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017454 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017455 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017456 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017457 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017458 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017459}
17460
17461static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17462{
17463 unsigned int present;
17464 unsigned char bits;
17465
Wu Fengguang864f92b2009-11-18 12:38:02 +080017466 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017467 bits = present ? HDA_AMP_MUTE : 0;
17468 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017469 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017470 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017471 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017472 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017473 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017474 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017475 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017476}
17477
17478static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17479{
17480 unsigned int present;
17481 unsigned char bits;
17482
Wu Fengguang864f92b2009-11-18 12:38:02 +080017483 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017484 bits = present ? HDA_AMP_MUTE : 0;
17485 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017486 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017487 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017488 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017489 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017490 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017491 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017492 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017493}
17494
17495static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17496{
17497 unsigned int present;
17498 unsigned char bits;
17499
Wu Fengguang864f92b2009-11-18 12:38:02 +080017500 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017501 bits = present ? 0 : PIN_OUT;
17502 snd_hda_codec_write(codec, 0x14, 0,
17503 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17504}
17505
17506static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17507{
17508 unsigned int present1, present2;
17509
Wu Fengguang864f92b2009-11-18 12:38:02 +080017510 present1 = snd_hda_jack_detect(codec, 0x21);
17511 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017512
17513 if (present1 || present2) {
17514 snd_hda_codec_write_cache(codec, 0x14, 0,
17515 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17516 } else {
17517 snd_hda_codec_write_cache(codec, 0x14, 0,
17518 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17519 }
17520}
17521
17522static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17523{
17524 unsigned int present1, present2;
17525
Wu Fengguang864f92b2009-11-18 12:38:02 +080017526 present1 = snd_hda_jack_detect(codec, 0x1b);
17527 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017528
17529 if (present1 || present2) {
17530 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017531 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017532 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017533 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017534 } else {
17535 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017536 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017537 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017538 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017539 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017540}
17541
Kailang Yangebb83ee2009-12-17 12:23:00 +010017542static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17543{
17544 unsigned int present1, present2;
17545
17546 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17547 AC_VERB_GET_PIN_SENSE, 0)
17548 & AC_PINSENSE_PRESENCE;
17549 present2 = snd_hda_codec_read(codec, 0x21, 0,
17550 AC_VERB_GET_PIN_SENSE, 0)
17551 & AC_PINSENSE_PRESENCE;
17552
17553 if (present1 || present2) {
17554 snd_hda_codec_write_cache(codec, 0x14, 0,
17555 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17556 snd_hda_codec_write_cache(codec, 0x17, 0,
17557 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17558 } else {
17559 snd_hda_codec_write_cache(codec, 0x14, 0,
17560 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17561 snd_hda_codec_write_cache(codec, 0x17, 0,
17562 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17563 }
17564}
17565
17566static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17567{
17568 unsigned int present1, present2;
17569
17570 present1 = snd_hda_codec_read(codec, 0x21, 0,
17571 AC_VERB_GET_PIN_SENSE, 0)
17572 & AC_PINSENSE_PRESENCE;
17573 present2 = snd_hda_codec_read(codec, 0x15, 0,
17574 AC_VERB_GET_PIN_SENSE, 0)
17575 & AC_PINSENSE_PRESENCE;
17576
17577 if (present1 || present2) {
17578 snd_hda_codec_write_cache(codec, 0x14, 0,
17579 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17580 snd_hda_codec_write_cache(codec, 0x17, 0,
17581 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17582 } else {
17583 snd_hda_codec_write_cache(codec, 0x14, 0,
17584 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17585 snd_hda_codec_write_cache(codec, 0x17, 0,
17586 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17587 }
17588}
17589
Kailang Yang6dda9f42008-05-27 12:05:31 +020017590static void alc663_m51va_unsol_event(struct hda_codec *codec,
17591 unsigned int res)
17592{
17593 switch (res >> 26) {
17594 case ALC880_HP_EVENT:
17595 alc663_m51va_speaker_automute(codec);
17596 break;
17597 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017598 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017599 break;
17600 }
17601}
17602
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017603static void alc663_m51va_setup(struct hda_codec *codec)
17604{
17605 struct alc_spec *spec = codec->spec;
17606 spec->ext_mic.pin = 0x18;
17607 spec->ext_mic.mux_idx = 0;
17608 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017609 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017610 spec->auto_mic = 1;
17611}
17612
Kailang Yang6dda9f42008-05-27 12:05:31 +020017613static void alc663_m51va_inithook(struct hda_codec *codec)
17614{
17615 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017616 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017617}
17618
Kailang Yangf1d4e282008-08-26 14:03:29 +020017619/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017620#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017621
17622static void alc663_mode1_setup(struct hda_codec *codec)
17623{
17624 struct alc_spec *spec = codec->spec;
17625 spec->ext_mic.pin = 0x18;
17626 spec->ext_mic.mux_idx = 0;
17627 spec->int_mic.pin = 0x19;
17628 spec->int_mic.mux_idx = 1;
17629 spec->auto_mic = 1;
17630}
17631
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017632#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017633
Kailang Yangf1d4e282008-08-26 14:03:29 +020017634/* ***************** Mode2 ******************************/
17635static void alc662_mode2_unsol_event(struct hda_codec *codec,
17636 unsigned int res)
17637{
17638 switch (res >> 26) {
17639 case ALC880_HP_EVENT:
17640 alc662_f5z_speaker_automute(codec);
17641 break;
17642 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017643 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017644 break;
17645 }
17646}
17647
Kailang Yangebb83ee2009-12-17 12:23:00 +010017648#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017649
Kailang Yangf1d4e282008-08-26 14:03:29 +020017650static void alc662_mode2_inithook(struct hda_codec *codec)
17651{
17652 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017653 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017654}
17655/* ***************** Mode3 ******************************/
17656static void alc663_mode3_unsol_event(struct hda_codec *codec,
17657 unsigned int res)
17658{
17659 switch (res >> 26) {
17660 case ALC880_HP_EVENT:
17661 alc663_two_hp_m1_speaker_automute(codec);
17662 break;
17663 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017664 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017665 break;
17666 }
17667}
17668
Kailang Yangebb83ee2009-12-17 12:23:00 +010017669#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017670
Kailang Yangf1d4e282008-08-26 14:03:29 +020017671static void alc663_mode3_inithook(struct hda_codec *codec)
17672{
17673 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017674 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017675}
17676/* ***************** Mode4 ******************************/
17677static void alc663_mode4_unsol_event(struct hda_codec *codec,
17678 unsigned int res)
17679{
17680 switch (res >> 26) {
17681 case ALC880_HP_EVENT:
17682 alc663_21jd_two_speaker_automute(codec);
17683 break;
17684 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017685 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017686 break;
17687 }
17688}
17689
Kailang Yangebb83ee2009-12-17 12:23:00 +010017690#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017691
Kailang Yangf1d4e282008-08-26 14:03:29 +020017692static void alc663_mode4_inithook(struct hda_codec *codec)
17693{
17694 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017695 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017696}
17697/* ***************** Mode5 ******************************/
17698static void alc663_mode5_unsol_event(struct hda_codec *codec,
17699 unsigned int res)
17700{
17701 switch (res >> 26) {
17702 case ALC880_HP_EVENT:
17703 alc663_15jd_two_speaker_automute(codec);
17704 break;
17705 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017706 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017707 break;
17708 }
17709}
17710
Kailang Yangebb83ee2009-12-17 12:23:00 +010017711#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017712
Kailang Yangf1d4e282008-08-26 14:03:29 +020017713static void alc663_mode5_inithook(struct hda_codec *codec)
17714{
17715 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017716 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017717}
17718/* ***************** Mode6 ******************************/
17719static void alc663_mode6_unsol_event(struct hda_codec *codec,
17720 unsigned int res)
17721{
17722 switch (res >> 26) {
17723 case ALC880_HP_EVENT:
17724 alc663_two_hp_m2_speaker_automute(codec);
17725 break;
17726 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017727 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017728 break;
17729 }
17730}
17731
Kailang Yangebb83ee2009-12-17 12:23:00 +010017732#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017733
Kailang Yangf1d4e282008-08-26 14:03:29 +020017734static void alc663_mode6_inithook(struct hda_codec *codec)
17735{
17736 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017737 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017738}
17739
Kailang Yangebb83ee2009-12-17 12:23:00 +010017740/* ***************** Mode7 ******************************/
17741static void alc663_mode7_unsol_event(struct hda_codec *codec,
17742 unsigned int res)
17743{
17744 switch (res >> 26) {
17745 case ALC880_HP_EVENT:
17746 alc663_two_hp_m7_speaker_automute(codec);
17747 break;
17748 case ALC880_MIC_EVENT:
17749 alc_mic_automute(codec);
17750 break;
17751 }
17752}
17753
17754#define alc663_mode7_setup alc663_mode1_setup
17755
17756static void alc663_mode7_inithook(struct hda_codec *codec)
17757{
17758 alc663_two_hp_m7_speaker_automute(codec);
17759 alc_mic_automute(codec);
17760}
17761
17762/* ***************** Mode8 ******************************/
17763static void alc663_mode8_unsol_event(struct hda_codec *codec,
17764 unsigned int res)
17765{
17766 switch (res >> 26) {
17767 case ALC880_HP_EVENT:
17768 alc663_two_hp_m8_speaker_automute(codec);
17769 break;
17770 case ALC880_MIC_EVENT:
17771 alc_mic_automute(codec);
17772 break;
17773 }
17774}
17775
17776#define alc663_mode8_setup alc663_m51va_setup
17777
17778static void alc663_mode8_inithook(struct hda_codec *codec)
17779{
17780 alc663_two_hp_m8_speaker_automute(codec);
17781 alc_mic_automute(codec);
17782}
17783
Kailang Yang6dda9f42008-05-27 12:05:31 +020017784static void alc663_g71v_hp_automute(struct hda_codec *codec)
17785{
17786 unsigned int present;
17787 unsigned char bits;
17788
Wu Fengguang864f92b2009-11-18 12:38:02 +080017789 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017790 bits = present ? HDA_AMP_MUTE : 0;
17791 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17792 HDA_AMP_MUTE, bits);
17793 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17794 HDA_AMP_MUTE, bits);
17795}
17796
17797static void alc663_g71v_front_automute(struct hda_codec *codec)
17798{
17799 unsigned int present;
17800 unsigned char bits;
17801
Wu Fengguang864f92b2009-11-18 12:38:02 +080017802 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017803 bits = present ? HDA_AMP_MUTE : 0;
17804 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17805 HDA_AMP_MUTE, bits);
17806}
17807
17808static void alc663_g71v_unsol_event(struct hda_codec *codec,
17809 unsigned int res)
17810{
17811 switch (res >> 26) {
17812 case ALC880_HP_EVENT:
17813 alc663_g71v_hp_automute(codec);
17814 break;
17815 case ALC880_FRONT_EVENT:
17816 alc663_g71v_front_automute(codec);
17817 break;
17818 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017819 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017820 break;
17821 }
17822}
17823
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017824#define alc663_g71v_setup alc663_m51va_setup
17825
Kailang Yang6dda9f42008-05-27 12:05:31 +020017826static void alc663_g71v_inithook(struct hda_codec *codec)
17827{
17828 alc663_g71v_front_automute(codec);
17829 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017830 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017831}
17832
17833static void alc663_g50v_unsol_event(struct hda_codec *codec,
17834 unsigned int res)
17835{
17836 switch (res >> 26) {
17837 case ALC880_HP_EVENT:
17838 alc663_m51va_speaker_automute(codec);
17839 break;
17840 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017841 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017842 break;
17843 }
17844}
17845
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017846#define alc663_g50v_setup alc663_m51va_setup
17847
Kailang Yang6dda9f42008-05-27 12:05:31 +020017848static void alc663_g50v_inithook(struct hda_codec *codec)
17849{
17850 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017851 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017852}
17853
Kailang Yangf1d4e282008-08-26 14:03:29 +020017854static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17855 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017856 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017857
17858 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17859 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17860 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17861
17862 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17863 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17864 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17865 { } /* end */
17866};
17867
Chris Pockelé9541ba12009-05-12 08:08:53 +020017868static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17869 /* Master Playback automatically created from Speaker and Headphone */
17870 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17871 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17872 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17873 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17874
17875 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17876 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17877 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17878
17879 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17880 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17881 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17882 { } /* end */
17883};
17884
Takashi Iwaicb53c622007-08-10 17:21:45 +020017885#ifdef CONFIG_SND_HDA_POWER_SAVE
17886#define alc662_loopbacks alc880_loopbacks
17887#endif
17888
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017889
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017890/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017891#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17892#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17893#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17894#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17895
17896/*
17897 * configuration and preset
17898 */
17899static const char *alc662_models[ALC662_MODEL_LAST] = {
17900 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17901 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17902 [ALC662_3ST_6ch] = "3stack-6ch",
17903 [ALC662_5ST_DIG] = "6stack-dig",
17904 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017905 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017906 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017907 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017908 [ALC663_ASUS_M51VA] = "m51va",
17909 [ALC663_ASUS_G71V] = "g71v",
17910 [ALC663_ASUS_H13] = "h13",
17911 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017912 [ALC663_ASUS_MODE1] = "asus-mode1",
17913 [ALC662_ASUS_MODE2] = "asus-mode2",
17914 [ALC663_ASUS_MODE3] = "asus-mode3",
17915 [ALC663_ASUS_MODE4] = "asus-mode4",
17916 [ALC663_ASUS_MODE5] = "asus-mode5",
17917 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017918 [ALC663_ASUS_MODE7] = "asus-mode7",
17919 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017920 [ALC272_DELL] = "dell",
17921 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017922 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017923 [ALC662_AUTO] = "auto",
17924};
17925
17926static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017927 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017928 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17929 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017930 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17931 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017932 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017933 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17934 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17935 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17936 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017937 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17938 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017939 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017940 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17941 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17942 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17943 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17944 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017945 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017946 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17947 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017948 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17949 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17950 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17951 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017952 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017953 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17954 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17955 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017956 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17957 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17958 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17959 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017960 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017961 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17962 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017963 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017964 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17965 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17966 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017967 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017968 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017969 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17970 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017971 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17972 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17973 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017974 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017975 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17976 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017977 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017978 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017979 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017980 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17981 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17982 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017983 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017984 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17985 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017986 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017987 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017988 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017989 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017990 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17991 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017992 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017993 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017994 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17995 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017996 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017997 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017998 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017999 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018000 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018001 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018002 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18003 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018004 {}
18005};
18006
18007static struct alc_config_preset alc662_presets[] = {
18008 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018009 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018010 .init_verbs = { alc662_init_verbs },
18011 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18012 .dac_nids = alc662_dac_nids,
18013 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018014 .dig_in_nid = ALC662_DIGIN_NID,
18015 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18016 .channel_mode = alc662_3ST_2ch_modes,
18017 .input_mux = &alc662_capture_source,
18018 },
18019 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018020 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018021 .init_verbs = { alc662_init_verbs },
18022 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18023 .dac_nids = alc662_dac_nids,
18024 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018025 .dig_in_nid = ALC662_DIGIN_NID,
18026 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18027 .channel_mode = alc662_3ST_6ch_modes,
18028 .need_dac_fix = 1,
18029 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018030 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018031 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018032 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018033 .init_verbs = { alc662_init_verbs },
18034 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18035 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018036 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18037 .channel_mode = alc662_3ST_6ch_modes,
18038 .need_dac_fix = 1,
18039 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018040 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018041 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018042 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018043 .init_verbs = { alc662_init_verbs },
18044 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18045 .dac_nids = alc662_dac_nids,
18046 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018047 .dig_in_nid = ALC662_DIGIN_NID,
18048 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18049 .channel_mode = alc662_5stack_modes,
18050 .input_mux = &alc662_capture_source,
18051 },
18052 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018053 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018054 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18055 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18056 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018057 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18058 .channel_mode = alc662_3ST_2ch_modes,
18059 .input_mux = &alc662_lenovo_101e_capture_source,
18060 .unsol_event = alc662_lenovo_101e_unsol_event,
18061 .init_hook = alc662_lenovo_101e_all_automute,
18062 },
Kailang Yang291702f2007-10-16 14:28:03 +020018063 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018064 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018065 .init_verbs = { alc662_init_verbs,
18066 alc662_eeepc_sue_init_verbs },
18067 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18068 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018069 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18070 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018071 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018072 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018073 .init_hook = alc662_eeepc_inithook,
18074 },
Kailang Yang8c427222008-01-10 13:03:59 +010018075 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018076 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018077 alc662_chmode_mixer },
18078 .init_verbs = { alc662_init_verbs,
18079 alc662_eeepc_ep20_sue_init_verbs },
18080 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18081 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018082 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18083 .channel_mode = alc662_3ST_6ch_modes,
18084 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018085 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018086 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018087 .init_hook = alc662_eeepc_ep20_inithook,
18088 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018089 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018090 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018091 .init_verbs = { alc662_init_verbs,
18092 alc662_ecs_init_verbs },
18093 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18094 .dac_nids = alc662_dac_nids,
18095 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18096 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018097 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018098 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018099 .init_hook = alc662_eeepc_inithook,
18100 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018101 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018102 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018103 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18104 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18105 .dac_nids = alc662_dac_nids,
18106 .dig_out_nid = ALC662_DIGOUT_NID,
18107 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18108 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018109 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018110 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018111 .init_hook = alc663_m51va_inithook,
18112 },
18113 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018114 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018115 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18116 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18117 .dac_nids = alc662_dac_nids,
18118 .dig_out_nid = ALC662_DIGOUT_NID,
18119 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18120 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018121 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018122 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018123 .init_hook = alc663_g71v_inithook,
18124 },
18125 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018126 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018127 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18128 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18129 .dac_nids = alc662_dac_nids,
18130 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18131 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018132 .unsol_event = alc663_m51va_unsol_event,
18133 .init_hook = alc663_m51va_inithook,
18134 },
18135 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018136 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018137 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18138 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18139 .dac_nids = alc662_dac_nids,
18140 .dig_out_nid = ALC662_DIGOUT_NID,
18141 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18142 .channel_mode = alc662_3ST_6ch_modes,
18143 .input_mux = &alc663_capture_source,
18144 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018145 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018146 .init_hook = alc663_g50v_inithook,
18147 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018148 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018149 .mixers = { alc663_m51va_mixer },
18150 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018151 .init_verbs = { alc662_init_verbs,
18152 alc663_21jd_amic_init_verbs },
18153 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18154 .hp_nid = 0x03,
18155 .dac_nids = alc662_dac_nids,
18156 .dig_out_nid = ALC662_DIGOUT_NID,
18157 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18158 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018159 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018160 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018161 .init_hook = alc663_mode1_inithook,
18162 },
18163 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018164 .mixers = { alc662_1bjd_mixer },
18165 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018166 .init_verbs = { alc662_init_verbs,
18167 alc662_1bjd_amic_init_verbs },
18168 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18169 .dac_nids = alc662_dac_nids,
18170 .dig_out_nid = ALC662_DIGOUT_NID,
18171 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18172 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018173 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018174 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018175 .init_hook = alc662_mode2_inithook,
18176 },
18177 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018178 .mixers = { alc663_two_hp_m1_mixer },
18179 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018180 .init_verbs = { alc662_init_verbs,
18181 alc663_two_hp_amic_m1_init_verbs },
18182 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18183 .hp_nid = 0x03,
18184 .dac_nids = alc662_dac_nids,
18185 .dig_out_nid = ALC662_DIGOUT_NID,
18186 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18187 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018188 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018189 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018190 .init_hook = alc663_mode3_inithook,
18191 },
18192 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018193 .mixers = { alc663_asus_21jd_clfe_mixer },
18194 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018195 .init_verbs = { alc662_init_verbs,
18196 alc663_21jd_amic_init_verbs},
18197 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18198 .hp_nid = 0x03,
18199 .dac_nids = alc662_dac_nids,
18200 .dig_out_nid = ALC662_DIGOUT_NID,
18201 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18202 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018203 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018204 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018205 .init_hook = alc663_mode4_inithook,
18206 },
18207 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018208 .mixers = { alc663_asus_15jd_clfe_mixer },
18209 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018210 .init_verbs = { alc662_init_verbs,
18211 alc663_15jd_amic_init_verbs },
18212 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18213 .hp_nid = 0x03,
18214 .dac_nids = alc662_dac_nids,
18215 .dig_out_nid = ALC662_DIGOUT_NID,
18216 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18217 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018218 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018219 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018220 .init_hook = alc663_mode5_inithook,
18221 },
18222 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018223 .mixers = { alc663_two_hp_m2_mixer },
18224 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018225 .init_verbs = { alc662_init_verbs,
18226 alc663_two_hp_amic_m2_init_verbs },
18227 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18228 .hp_nid = 0x03,
18229 .dac_nids = alc662_dac_nids,
18230 .dig_out_nid = ALC662_DIGOUT_NID,
18231 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18232 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018233 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018234 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018235 .init_hook = alc663_mode6_inithook,
18236 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018237 [ALC663_ASUS_MODE7] = {
18238 .mixers = { alc663_mode7_mixer },
18239 .cap_mixer = alc662_auto_capture_mixer,
18240 .init_verbs = { alc662_init_verbs,
18241 alc663_mode7_init_verbs },
18242 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18243 .hp_nid = 0x03,
18244 .dac_nids = alc662_dac_nids,
18245 .dig_out_nid = ALC662_DIGOUT_NID,
18246 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18247 .channel_mode = alc662_3ST_2ch_modes,
18248 .unsol_event = alc663_mode7_unsol_event,
18249 .setup = alc663_mode7_setup,
18250 .init_hook = alc663_mode7_inithook,
18251 },
18252 [ALC663_ASUS_MODE8] = {
18253 .mixers = { alc663_mode8_mixer },
18254 .cap_mixer = alc662_auto_capture_mixer,
18255 .init_verbs = { alc662_init_verbs,
18256 alc663_mode8_init_verbs },
18257 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18258 .hp_nid = 0x03,
18259 .dac_nids = alc662_dac_nids,
18260 .dig_out_nid = ALC662_DIGOUT_NID,
18261 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18262 .channel_mode = alc662_3ST_2ch_modes,
18263 .unsol_event = alc663_mode8_unsol_event,
18264 .setup = alc663_mode8_setup,
18265 .init_hook = alc663_mode8_inithook,
18266 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018267 [ALC272_DELL] = {
18268 .mixers = { alc663_m51va_mixer },
18269 .cap_mixer = alc272_auto_capture_mixer,
18270 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18271 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18272 .dac_nids = alc662_dac_nids,
18273 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18274 .adc_nids = alc272_adc_nids,
18275 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18276 .capsrc_nids = alc272_capsrc_nids,
18277 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018278 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018279 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018280 .init_hook = alc663_m51va_inithook,
18281 },
18282 [ALC272_DELL_ZM1] = {
18283 .mixers = { alc663_m51va_mixer },
18284 .cap_mixer = alc662_auto_capture_mixer,
18285 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18286 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18287 .dac_nids = alc662_dac_nids,
18288 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18289 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018290 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018291 .capsrc_nids = alc662_capsrc_nids,
18292 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018293 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018294 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018295 .init_hook = alc663_m51va_inithook,
18296 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018297 [ALC272_SAMSUNG_NC10] = {
18298 .mixers = { alc272_nc10_mixer },
18299 .init_verbs = { alc662_init_verbs,
18300 alc663_21jd_amic_init_verbs },
18301 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18302 .dac_nids = alc272_dac_nids,
18303 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18304 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018305 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018306 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018307 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018308 .init_hook = alc663_mode4_inithook,
18309 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018310};
18311
18312
18313/*
18314 * BIOS auto configuration
18315 */
18316
Takashi Iwai7085ec12009-10-02 09:03:58 +020018317/* convert from MIX nid to DAC */
18318static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18319{
18320 if (nid == 0x0f)
18321 return 0x02;
18322 else if (nid >= 0x0c && nid <= 0x0e)
18323 return nid - 0x0c + 0x02;
18324 else
18325 return 0;
18326}
18327
18328/* get MIX nid connected to the given pin targeted to DAC */
18329static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18330 hda_nid_t dac)
18331{
18332 hda_nid_t mix[4];
18333 int i, num;
18334
18335 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18336 for (i = 0; i < num; i++) {
18337 if (alc662_mix_to_dac(mix[i]) == dac)
18338 return mix[i];
18339 }
18340 return 0;
18341}
18342
18343/* look for an empty DAC slot */
18344static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18345{
18346 struct alc_spec *spec = codec->spec;
18347 hda_nid_t srcs[5];
18348 int i, j, num;
18349
18350 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18351 if (num < 0)
18352 return 0;
18353 for (i = 0; i < num; i++) {
18354 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18355 if (!nid)
18356 continue;
18357 for (j = 0; j < spec->multiout.num_dacs; j++)
18358 if (spec->multiout.dac_nids[j] == nid)
18359 break;
18360 if (j >= spec->multiout.num_dacs)
18361 return nid;
18362 }
18363 return 0;
18364}
18365
18366/* fill in the dac_nids table from the parsed pin configuration */
18367static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18368 const struct auto_pin_cfg *cfg)
18369{
18370 struct alc_spec *spec = codec->spec;
18371 int i;
18372 hda_nid_t dac;
18373
18374 spec->multiout.dac_nids = spec->private_dac_nids;
18375 for (i = 0; i < cfg->line_outs; i++) {
18376 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18377 if (!dac)
18378 continue;
18379 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18380 }
18381 return 0;
18382}
18383
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018384static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018385 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018386{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018387 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018388 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18389}
18390
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018391static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018392 hda_nid_t nid, unsigned int chs)
18393{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018394 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018395 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18396}
18397
18398#define alc662_add_stereo_vol(spec, pfx, nid) \
18399 alc662_add_vol_ctl(spec, pfx, nid, 3)
18400#define alc662_add_stereo_sw(spec, pfx, nid) \
18401 alc662_add_sw_ctl(spec, pfx, nid, 3)
18402
18403/* add playback controls from the parsed DAC table */
18404static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18405 const struct auto_pin_cfg *cfg)
18406{
18407 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018408 static const char *chname[4] = {
18409 "Front", "Surround", NULL /*CLFE*/, "Side"
18410 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018411 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018412 int i, err;
18413
18414 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018415 nid = spec->multiout.dac_nids[i];
18416 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018417 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018418 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18419 if (!mix)
18420 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018421 if (i == 2) {
18422 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018423 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018424 if (err < 0)
18425 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018426 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018427 if (err < 0)
18428 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018429 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018430 if (err < 0)
18431 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018432 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018433 if (err < 0)
18434 return err;
18435 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018436 const char *pfx;
18437 if (cfg->line_outs == 1 &&
18438 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018439 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018440 pfx = "Speaker";
18441 else
18442 pfx = "PCM";
18443 } else
18444 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018445 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018446 if (err < 0)
18447 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018448 if (cfg->line_outs == 1 &&
18449 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18450 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018451 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018452 if (err < 0)
18453 return err;
18454 }
18455 }
18456 return 0;
18457}
18458
18459/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018460/* return DAC nid if any new DAC is assigned */
18461static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018462 const char *pfx)
18463{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018464 struct alc_spec *spec = codec->spec;
18465 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018466 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018467
18468 if (!pin)
18469 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018470 nid = alc662_look_for_dac(codec, pin);
18471 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018472 /* the corresponding DAC is already occupied */
18473 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18474 return 0; /* no way */
18475 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018476 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018477 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18478 }
18479
18480 mix = alc662_dac_to_mix(codec, pin, nid);
18481 if (!mix)
18482 return 0;
18483 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18484 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018485 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018486 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18487 if (err < 0)
18488 return err;
18489 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018490}
18491
18492/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018493#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018494 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018495
18496static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18497 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018498 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018499{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018500 int i, num;
18501 hda_nid_t srcs[4];
18502
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018503 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018504 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018505 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18506 if (num <= 1)
18507 return;
18508 for (i = 0; i < num; i++) {
18509 if (alc662_mix_to_dac(srcs[i]) != dac)
18510 continue;
18511 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18512 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018513 }
18514}
18515
18516static void alc662_auto_init_multi_out(struct hda_codec *codec)
18517{
18518 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018519 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018520 int i;
18521
18522 for (i = 0; i <= HDA_SIDE; i++) {
18523 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18524 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018525 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018526 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018527 }
18528}
18529
18530static void alc662_auto_init_hp_out(struct hda_codec *codec)
18531{
18532 struct alc_spec *spec = codec->spec;
18533 hda_nid_t pin;
18534
18535 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018536 if (pin)
18537 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18538 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018539 pin = spec->autocfg.speaker_pins[0];
18540 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018541 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18542 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018543}
18544
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018545#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18546
18547static void alc662_auto_init_analog_input(struct hda_codec *codec)
18548{
18549 struct alc_spec *spec = codec->spec;
18550 int i;
18551
18552 for (i = 0; i < AUTO_PIN_LAST; i++) {
18553 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018554 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018555 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018556 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018557 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018558 snd_hda_codec_write(codec, nid, 0,
18559 AC_VERB_SET_AMP_GAIN_MUTE,
18560 AMP_OUT_MUTE);
18561 }
18562 }
18563}
18564
Takashi Iwaif511b012008-08-15 16:46:42 +020018565#define alc662_auto_init_input_src alc882_auto_init_input_src
18566
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018567static int alc662_parse_auto_config(struct hda_codec *codec)
18568{
18569 struct alc_spec *spec = codec->spec;
18570 int err;
18571 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18572
18573 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18574 alc662_ignore);
18575 if (err < 0)
18576 return err;
18577 if (!spec->autocfg.line_outs)
18578 return 0; /* can't find valid BIOS pin config */
18579
Takashi Iwai7085ec12009-10-02 09:03:58 +020018580 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018581 if (err < 0)
18582 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018583 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018584 if (err < 0)
18585 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018586 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018587 spec->autocfg.speaker_pins[0],
18588 "Speaker");
18589 if (err < 0)
18590 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018591 if (err)
18592 spec->multiout.extra_out_nid[0] = err;
18593 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018594 "Headphone");
18595 if (err < 0)
18596 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018597 if (err)
18598 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018599 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018600 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018601 return err;
18602
18603 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18604
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018605 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018606 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18607
Takashi Iwai603c4012008-07-30 15:01:44 +020018608 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018609 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018610
18611 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018612 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018613
Kailang Yangcec27c82010-02-04 14:18:18 +010018614 add_verb(spec, alc662_init_verbs);
18615 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18616 codec->vendor_id == 0x10ec0665)
18617 add_verb(spec, alc663_init_verbs);
18618
18619 if (codec->vendor_id == 0x10ec0272)
18620 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018621
18622 err = alc_auto_add_mic_boost(codec);
18623 if (err < 0)
18624 return err;
18625
Kailang Yang6227cdc2010-02-25 08:36:52 +010018626 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18627 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18628 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18629 else
18630 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018631
Takashi Iwai8c872862007-06-19 12:11:16 +020018632 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018633}
18634
18635/* additional initialization for auto-configuration model */
18636static void alc662_auto_init(struct hda_codec *codec)
18637{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018638 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018639 alc662_auto_init_multi_out(codec);
18640 alc662_auto_init_hp_out(codec);
18641 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018642 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018643 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018644 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018645}
18646
18647static int patch_alc662(struct hda_codec *codec)
18648{
18649 struct alc_spec *spec;
18650 int err, board_config;
18651
18652 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18653 if (!spec)
18654 return -ENOMEM;
18655
18656 codec->spec = spec;
18657
Kailang Yangda00c242010-03-19 11:23:45 +010018658 alc_auto_parse_customize_define(codec);
18659
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018660 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18661
Kailang Yangc027ddc2010-03-19 11:33:06 +010018662 if (alc_read_coef_idx(codec, 0) == 0x8020)
18663 alc_codec_rename(codec, "ALC661");
18664 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18665 codec->bus->pci->subsystem_vendor == 0x1025 &&
18666 spec->cdefine.platform_type == 1)
18667 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010018668
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018669 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18670 alc662_models,
18671 alc662_cfg_tbl);
18672 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018673 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18674 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018675 board_config = ALC662_AUTO;
18676 }
18677
18678 if (board_config == ALC662_AUTO) {
18679 /* automatic parse from the BIOS config */
18680 err = alc662_parse_auto_config(codec);
18681 if (err < 0) {
18682 alc_free(codec);
18683 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020018684 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018685 printk(KERN_INFO
18686 "hda_codec: Cannot set up configuration "
18687 "from BIOS. Using base mode...\n");
18688 board_config = ALC662_3ST_2ch_DIG;
18689 }
18690 }
18691
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018692 err = snd_hda_attach_beep_device(codec, 0x1);
18693 if (err < 0) {
18694 alc_free(codec);
18695 return err;
18696 }
18697
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018698 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018699 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018700
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018701 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18702 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18703
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018704 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18705 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18706
Takashi Iwaidd704692009-08-11 08:45:11 +020018707 if (!spec->adc_nids) {
18708 spec->adc_nids = alc662_adc_nids;
18709 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18710 }
18711 if (!spec->capsrc_nids)
18712 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018713
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018714 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018715 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018716
Kailang Yangda00c242010-03-19 11:23:45 +010018717 if (spec->cdefine.enable_pcbeep) {
18718 switch (codec->vendor_id) {
18719 case 0x10ec0662:
18720 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18721 break;
18722 case 0x10ec0272:
18723 case 0x10ec0663:
18724 case 0x10ec0665:
18725 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18726 break;
18727 case 0x10ec0273:
18728 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18729 break;
18730 }
Kailang Yangcec27c82010-02-04 14:18:18 +010018731 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018732 spec->vmaster_nid = 0x02;
18733
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018734 codec->patch_ops = alc_patch_ops;
18735 if (board_config == ALC662_AUTO)
18736 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018737#ifdef CONFIG_SND_HDA_POWER_SAVE
18738 if (!spec->loopback.amplist)
18739 spec->loopback.amplist = alc662_loopbacks;
18740#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018741
18742 return 0;
18743}
18744
Kailang Yang274693f2009-12-03 10:07:50 +010018745static int patch_alc888(struct hda_codec *codec)
18746{
18747 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18748 kfree(codec->chip_name);
18749 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018750 if (!codec->chip_name) {
18751 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018752 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018753 }
18754 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018755 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018756 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018757}
18758
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018759/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018760 * patch entries
18761 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018762static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018763 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018764 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018765 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018766 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018767 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018768 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018769 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018770 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018771 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018772 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018773 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18774 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18775 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018776 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai49535502009-06-30 15:28:30 +020018777 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018778 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18779 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018780 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018781 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018782 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018783 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018784 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020018785 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018786 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020018787 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018788 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020018789 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018790 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020018791 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018792 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai49535502009-06-30 15:28:30 +020018793 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018794 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai49535502009-06-30 15:28:30 +020018795 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018796 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018797 {} /* terminator */
18798};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018799
18800MODULE_ALIAS("snd-hda-codec-id:10ec*");
18801
18802MODULE_LICENSE("GPL");
18803MODULE_DESCRIPTION("Realtek HD-audio codec");
18804
18805static struct hda_codec_preset_list realtek_list = {
18806 .preset = snd_hda_preset_realtek,
18807 .owner = THIS_MODULE,
18808};
18809
18810static int __init patch_realtek_init(void)
18811{
18812 return snd_hda_add_codec_preset(&realtek_list);
18813}
18814
18815static void __exit patch_realtek_exit(void)
18816{
18817 snd_hda_delete_codec_preset(&realtek_list);
18818}
18819
18820module_init(patch_realtek_init)
18821module_exit(patch_realtek_exit)