blob: f266c544ac69bc1cafed3bb708d1000b4dd8dc69 [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 Iwai4953550a2009-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 Iwai4953550a2009-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 Kluin4b35d2ca2009-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 */
2622 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2623 if (!kctl)
2624 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2625 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002626 hda_nid_t *nids = spec->capsrc_nids;
2627 if (!nids)
2628 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002629 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002630 if (err < 0)
2631 return err;
2632 }
2633 if (spec->cap_mixer) {
2634 const char *kname = kctl ? kctl->id.name : NULL;
2635 for (knew = spec->cap_mixer; knew->name; knew++) {
2636 if (kname && strcmp(knew->name, kname) == 0)
2637 continue;
2638 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2639 for (i = 0; kctl && i < kctl->count; i++) {
2640 err = snd_hda_add_nid(codec, kctl, i,
2641 spec->adc_nids[i]);
2642 if (err < 0)
2643 return err;
2644 }
2645 }
2646 }
2647
2648 /* other nid->control mapping */
2649 for (i = 0; i < spec->num_mixers; i++) {
2650 for (knew = spec->mixers[i]; knew->name; knew++) {
2651 if (knew->iface != NID_MAPPING)
2652 continue;
2653 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2654 if (kctl == NULL)
2655 continue;
2656 u = knew->subdevice;
2657 for (j = 0; j < 4; j++, u >>= 8) {
2658 nid = u & 0x3f;
2659 if (nid == 0)
2660 continue;
2661 switch (u & 0xc0) {
2662 case SUBDEV_SPEAKER_:
2663 nid = spec->autocfg.speaker_pins[nid];
2664 break;
2665 case SUBDEV_LINE_:
2666 nid = spec->autocfg.line_out_pins[nid];
2667 break;
2668 case SUBDEV_HP_:
2669 nid = spec->autocfg.hp_pins[nid];
2670 break;
2671 default:
2672 continue;
2673 }
2674 err = snd_hda_add_nid(codec, kctl, 0, nid);
2675 if (err < 0)
2676 return err;
2677 }
2678 u = knew->private_value;
2679 for (j = 0; j < 4; j++, u >>= 8) {
2680 nid = u & 0xff;
2681 if (nid == 0)
2682 continue;
2683 err = snd_hda_add_nid(codec, kctl, 0, nid);
2684 if (err < 0)
2685 return err;
2686 }
2687 }
2688 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002689
2690 alc_free_kctls(codec); /* no longer needed */
2691
Linus Torvalds1da177e2005-04-16 15:20:36 -07002692 return 0;
2693}
2694
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002695
Linus Torvalds1da177e2005-04-16 15:20:36 -07002696/*
2697 * initialize the codec volumes, etc
2698 */
2699
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700/*
2701 * generic initialization of ADC, input mixers and output mixers
2702 */
2703static struct hda_verb alc880_volume_init_verbs[] = {
2704 /*
2705 * Unmute ADC0-2 and set the default input to mic-in
2706 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002707 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002709 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002711 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002714 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2715 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002716 * Note: PASD motherboards uses the Line In 2 as the input for front
2717 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002719 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002728 /*
2729 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002731 /* set vol=0 to output mixers */
2732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2733 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2735 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2736 /* set up input amps for analog loopback */
2737 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002744 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2745 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002746
2747 { }
2748};
2749
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002750/*
2751 * 3-stack pin configuration:
2752 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2753 */
2754static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2755 /*
2756 * preset connection lists of input pins
2757 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2758 */
2759 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2760 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2761 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2762
2763 /*
2764 * Set pin mode and muting
2765 */
2766 /* set front pin widgets 0x14 for output */
2767 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2769 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2770 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2771 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2772 /* Mic2 (as headphone out) for HP output */
2773 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2774 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2775 /* Line In pin widget for input */
2776 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2777 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2778 /* Line2 (as front mic) pin widget for input and vref at 80% */
2779 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2780 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2781 /* CD pin widget for input */
2782 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2783
2784 { }
2785};
2786
2787/*
2788 * 5-stack pin configuration:
2789 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2790 * line-in/side = 0x1a, f-mic = 0x1b
2791 */
2792static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2793 /*
2794 * preset connection lists of input pins
2795 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2796 */
2797 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2798 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2799
2800 /*
2801 * Set pin mode and muting
2802 */
2803 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2806 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002808 /* unmute pins for output (no gain on this amp) */
2809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2813
Linus Torvalds1da177e2005-04-16 15:20:36 -07002814 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2817 /* Mic2 (as headphone out) for HP output */
2818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002820 /* Line In pin widget for input */
2821 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2823 /* Line2 (as front mic) pin widget for input and vref at 80% */
2824 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2825 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2826 /* CD pin widget for input */
2827 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002828
2829 { }
2830};
2831
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002832/*
2833 * W810 pin configuration:
2834 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2835 */
2836static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002837 /* hphone/speaker input selector: front DAC */
2838 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2839
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2844 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2845 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2846
2847 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002848 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002849
Linus Torvalds1da177e2005-04-16 15:20:36 -07002850 { }
2851};
2852
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002853/*
2854 * Z71V pin configuration:
2855 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2856 */
2857static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002858 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002859 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002860 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002862
Takashi Iwai16ded522005-06-10 19:58:24 +02002863 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002864 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002865 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002866 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002867
2868 { }
2869};
2870
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002871/*
2872 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002873 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2874 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002875 */
2876static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2877 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2878
Takashi Iwai16ded522005-06-10 19:58:24 +02002879 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002881 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002883 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002884 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002885 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002886 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2887
Takashi Iwai16ded522005-06-10 19:58:24 +02002888 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002889 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002890 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002892 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002893 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002894 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002895 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002896 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002897
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898 { }
2899};
Takashi Iwai16ded522005-06-10 19:58:24 +02002900
Kailang Yangccc656c2006-10-17 12:32:26 +02002901/*
2902 * Uniwill pin configuration:
2903 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2904 * line = 0x1a
2905 */
2906static struct hda_verb alc880_uniwill_init_verbs[] = {
2907 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2908
2909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2913 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2916 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2923
2924 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2925 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2926 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2927 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2928 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2930 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2931 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2932 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2933
2934 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2935 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2936
2937 { }
2938};
2939
2940/*
2941* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002942* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002943 */
2944static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2945 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2946
2947 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2948 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2949 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2950 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2951 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2952 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2953 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2955 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2957 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2958 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2959
2960 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2961 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2962 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2963 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2964 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2965 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2966
2967 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2968 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2969
2970 { }
2971};
2972
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002973static struct hda_verb alc880_beep_init_verbs[] = {
2974 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2975 { }
2976};
2977
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002978/* auto-toggle front mic */
2979static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2980{
2981 unsigned int present;
2982 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002983
Wu Fengguang864f92b2009-11-18 12:38:02 +08002984 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002985 bits = present ? HDA_AMP_MUTE : 0;
2986 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002987}
2988
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002989static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002990{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002991 struct alc_spec *spec = codec->spec;
2992
2993 spec->autocfg.hp_pins[0] = 0x14;
2994 spec->autocfg.speaker_pins[0] = 0x15;
2995 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002996}
2997
2998static void alc880_uniwill_init_hook(struct hda_codec *codec)
2999{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003000 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003001 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003002}
3003
3004static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3005 unsigned int res)
3006{
3007 /* Looks like the unsol event is incompatible with the standard
3008 * definition. 4bit tag is placed at 28 bit!
3009 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003010 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003011 case ALC880_MIC_EVENT:
3012 alc880_uniwill_mic_automute(codec);
3013 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003014 default:
3015 alc_automute_amp_unsol_event(codec, res);
3016 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003017 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003018}
3019
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003020static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003021{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003022 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003023
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003024 spec->autocfg.hp_pins[0] = 0x14;
3025 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003026}
3027
3028static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3029{
3030 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003031
Kailang Yangccc656c2006-10-17 12:32:26 +02003032 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003033 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3034 present &= HDA_AMP_VOLMASK;
3035 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3036 HDA_AMP_VOLMASK, present);
3037 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3038 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003039}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003040
Kailang Yangccc656c2006-10-17 12:32:26 +02003041static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3042 unsigned int res)
3043{
3044 /* Looks like the unsol event is incompatible with the standard
3045 * definition. 4bit tag is placed at 28 bit!
3046 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003047 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003048 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003049 else
3050 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003051}
3052
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003053/*
3054 * F1734 pin configuration:
3055 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3056 */
3057static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003058 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003059 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3060 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3061 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3062 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3063
3064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3065 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3068
3069 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3070 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003071 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003072 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3073 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3074 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3075 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3076 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3077 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003078
Takashi Iwai937b4162008-02-11 14:52:36 +01003079 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3080 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3081
Takashi Iwai16ded522005-06-10 19:58:24 +02003082 { }
3083};
3084
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085/*
3086 * ASUS pin configuration:
3087 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3088 */
3089static struct hda_verb alc880_pin_asus_init_verbs[] = {
3090 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3091 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3092 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3093 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3094
3095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3096 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3098 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3099 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3100 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3101 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3102 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3103
3104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3105 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3106 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3107 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3108 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3109 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3110 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3111 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3112 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003113
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003114 { }
3115};
3116
3117/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003118#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3119#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003120#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003121
Kailang Yangdf694da2005-12-05 19:42:22 +01003122/* Clevo m520g init */
3123static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3124 /* headphone output */
3125 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3126 /* line-out */
3127 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3128 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3129 /* Line-in */
3130 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3131 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3132 /* CD */
3133 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3134 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3135 /* Mic1 (rear panel) */
3136 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3137 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3138 /* Mic2 (front panel) */
3139 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3141 /* headphone */
3142 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3143 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3144 /* change to EAPD mode */
3145 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3146 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3147
3148 { }
3149};
3150
3151static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003152 /* change to EAPD mode */
3153 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3154 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3155
Kailang Yangdf694da2005-12-05 19:42:22 +01003156 /* Headphone output */
3157 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3158 /* Front output*/
3159 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3160 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3161
3162 /* Line In pin widget for input */
3163 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3164 /* CD pin widget for input */
3165 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3166 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3167 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3168
3169 /* change to EAPD mode */
3170 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3171 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3172
3173 { }
3174};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003175
3176/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003177 * LG m1 express dual
3178 *
3179 * Pin assignment:
3180 * Rear Line-In/Out (blue): 0x14
3181 * Build-in Mic-In: 0x15
3182 * Speaker-out: 0x17
3183 * HP-Out (green): 0x1b
3184 * Mic-In/Out (red): 0x19
3185 * SPDIF-Out: 0x1e
3186 */
3187
3188/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3189static hda_nid_t alc880_lg_dac_nids[3] = {
3190 0x05, 0x02, 0x03
3191};
3192
3193/* seems analog CD is not working */
3194static struct hda_input_mux alc880_lg_capture_source = {
3195 .num_items = 3,
3196 .items = {
3197 { "Mic", 0x1 },
3198 { "Line", 0x5 },
3199 { "Internal Mic", 0x6 },
3200 },
3201};
3202
3203/* 2,4,6 channel modes */
3204static struct hda_verb alc880_lg_ch2_init[] = {
3205 /* set line-in and mic-in to input */
3206 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3207 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3208 { }
3209};
3210
3211static struct hda_verb alc880_lg_ch4_init[] = {
3212 /* set line-in to out and mic-in to input */
3213 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3214 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3215 { }
3216};
3217
3218static struct hda_verb alc880_lg_ch6_init[] = {
3219 /* set line-in and mic-in to output */
3220 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3221 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3222 { }
3223};
3224
3225static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3226 { 2, alc880_lg_ch2_init },
3227 { 4, alc880_lg_ch4_init },
3228 { 6, alc880_lg_ch6_init },
3229};
3230
3231static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003232 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3233 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003234 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3235 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3236 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3237 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3238 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3239 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3244 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3245 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3246 {
3247 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3248 .name = "Channel Mode",
3249 .info = alc_ch_mode_info,
3250 .get = alc_ch_mode_get,
3251 .put = alc_ch_mode_put,
3252 },
3253 { } /* end */
3254};
3255
3256static struct hda_verb alc880_lg_init_verbs[] = {
3257 /* set capture source to mic-in */
3258 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3259 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3260 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3261 /* mute all amp mixer inputs */
3262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003265 /* line-in to input */
3266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3267 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3268 /* built-in mic */
3269 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3270 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3271 /* speaker-out */
3272 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3273 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3274 /* mic-in to input */
3275 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3276 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3277 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3278 /* HP-out */
3279 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3280 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3281 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3282 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003283 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003284 { }
3285};
3286
3287/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003288static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003289{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003290 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003291
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003292 spec->autocfg.hp_pins[0] = 0x1b;
3293 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003294}
3295
3296/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003297 * LG LW20
3298 *
3299 * Pin assignment:
3300 * Speaker-out: 0x14
3301 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003302 * Built-in Mic-In: 0x19
3303 * Line-In: 0x1b
3304 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003305 * SPDIF-Out: 0x1e
3306 */
3307
Takashi Iwaid6815182006-03-23 16:06:23 +01003308static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003309 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003310 .items = {
3311 { "Mic", 0x0 },
3312 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003313 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003314 },
3315};
3316
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003317#define alc880_lg_lw_modes alc880_threestack_modes
3318
Takashi Iwaid6815182006-03-23 16:06:23 +01003319static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003320 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3321 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3322 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3323 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3324 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3325 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3326 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3327 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3328 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3329 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3332 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3333 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003334 {
3335 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3336 .name = "Channel Mode",
3337 .info = alc_ch_mode_info,
3338 .get = alc_ch_mode_get,
3339 .put = alc_ch_mode_put,
3340 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003341 { } /* end */
3342};
3343
3344static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003345 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3346 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3347 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3348
Takashi Iwaid6815182006-03-23 16:06:23 +01003349 /* set capture source to mic-in */
3350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3351 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3352 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003353 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003354 /* speaker-out */
3355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3357 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003358 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3359 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3360 /* mic-in to input */
3361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3362 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3363 /* built-in mic */
3364 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3365 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3366 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003367 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003368 { }
3369};
3370
3371/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003372static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003373{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003374 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003375
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003376 spec->autocfg.hp_pins[0] = 0x1b;
3377 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003378}
3379
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003380static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3381 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3382 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3383 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3384 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3385 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3386 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3387 { } /* end */
3388};
3389
3390static struct hda_input_mux alc880_medion_rim_capture_source = {
3391 .num_items = 2,
3392 .items = {
3393 { "Mic", 0x0 },
3394 { "Internal Mic", 0x1 },
3395 },
3396};
3397
3398static struct hda_verb alc880_medion_rim_init_verbs[] = {
3399 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3400
3401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3402 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3403
3404 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3405 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3406 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3407 /* Mic2 (as headphone out) for HP output */
3408 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3409 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3410 /* Internal Speaker */
3411 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3412 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3413
3414 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3415 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3416
3417 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3418 { }
3419};
3420
3421/* toggle speaker-output according to the hp-jack state */
3422static void alc880_medion_rim_automute(struct hda_codec *codec)
3423{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003424 struct alc_spec *spec = codec->spec;
3425 alc_automute_amp(codec);
3426 /* toggle EAPD */
3427 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003428 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3429 else
3430 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3431}
3432
3433static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3434 unsigned int res)
3435{
3436 /* Looks like the unsol event is incompatible with the standard
3437 * definition. 4bit tag is placed at 28 bit!
3438 */
3439 if ((res >> 28) == ALC880_HP_EVENT)
3440 alc880_medion_rim_automute(codec);
3441}
3442
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003443static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003444{
3445 struct alc_spec *spec = codec->spec;
3446
3447 spec->autocfg.hp_pins[0] = 0x14;
3448 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003449}
3450
Takashi Iwaicb53c622007-08-10 17:21:45 +02003451#ifdef CONFIG_SND_HDA_POWER_SAVE
3452static struct hda_amp_list alc880_loopbacks[] = {
3453 { 0x0b, HDA_INPUT, 0 },
3454 { 0x0b, HDA_INPUT, 1 },
3455 { 0x0b, HDA_INPUT, 2 },
3456 { 0x0b, HDA_INPUT, 3 },
3457 { 0x0b, HDA_INPUT, 4 },
3458 { } /* end */
3459};
3460
3461static struct hda_amp_list alc880_lg_loopbacks[] = {
3462 { 0x0b, HDA_INPUT, 1 },
3463 { 0x0b, HDA_INPUT, 6 },
3464 { 0x0b, HDA_INPUT, 7 },
3465 { } /* end */
3466};
3467#endif
3468
Takashi Iwaid6815182006-03-23 16:06:23 +01003469/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003470 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003471 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003472
Linus Torvalds1da177e2005-04-16 15:20:36 -07003473static int alc_init(struct hda_codec *codec)
3474{
3475 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003476 unsigned int i;
3477
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003478 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003479 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003480
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003481 for (i = 0; i < spec->num_init_verbs; i++)
3482 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003483
3484 if (spec->init_hook)
3485 spec->init_hook(codec);
3486
Takashi Iwaiad358792010-03-30 18:00:59 +02003487#ifdef CONFIG_SND_HDA_POWER_SAVE
3488 if (codec->patch_ops.check_power_status)
3489 codec->patch_ops.check_power_status(codec, 0x01);
3490#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003491 return 0;
3492}
3493
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003494static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3495{
3496 struct alc_spec *spec = codec->spec;
3497
3498 if (spec->unsol_event)
3499 spec->unsol_event(codec, res);
3500}
3501
Takashi Iwaicb53c622007-08-10 17:21:45 +02003502#ifdef CONFIG_SND_HDA_POWER_SAVE
3503static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3504{
3505 struct alc_spec *spec = codec->spec;
3506 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3507}
3508#endif
3509
Linus Torvalds1da177e2005-04-16 15:20:36 -07003510/*
3511 * Analog playback callbacks
3512 */
3513static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3514 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003515 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003516{
3517 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003518 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3519 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003520}
3521
3522static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3523 struct hda_codec *codec,
3524 unsigned int stream_tag,
3525 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003526 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003527{
3528 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003529 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3530 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003531}
3532
3533static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3534 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003535 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003536{
3537 struct alc_spec *spec = codec->spec;
3538 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3539}
3540
3541/*
3542 * Digital out
3543 */
3544static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3545 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003546 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003547{
3548 struct alc_spec *spec = codec->spec;
3549 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3550}
3551
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003552static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3553 struct hda_codec *codec,
3554 unsigned int stream_tag,
3555 unsigned int format,
3556 struct snd_pcm_substream *substream)
3557{
3558 struct alc_spec *spec = codec->spec;
3559 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3560 stream_tag, format, substream);
3561}
3562
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003563static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3564 struct hda_codec *codec,
3565 struct snd_pcm_substream *substream)
3566{
3567 struct alc_spec *spec = codec->spec;
3568 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3569}
3570
Linus Torvalds1da177e2005-04-16 15:20:36 -07003571static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3572 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003573 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003574{
3575 struct alc_spec *spec = codec->spec;
3576 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3577}
3578
3579/*
3580 * Analog capture
3581 */
Takashi Iwai63300792008-01-24 15:31:36 +01003582static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003583 struct hda_codec *codec,
3584 unsigned int stream_tag,
3585 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003586 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003587{
3588 struct alc_spec *spec = codec->spec;
3589
Takashi Iwai63300792008-01-24 15:31:36 +01003590 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003591 stream_tag, 0, format);
3592 return 0;
3593}
3594
Takashi Iwai63300792008-01-24 15:31:36 +01003595static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003596 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003597 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003598{
3599 struct alc_spec *spec = codec->spec;
3600
Takashi Iwai888afa12008-03-18 09:57:50 +01003601 snd_hda_codec_cleanup_stream(codec,
3602 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003603 return 0;
3604}
3605
3606
3607/*
3608 */
3609static struct hda_pcm_stream alc880_pcm_analog_playback = {
3610 .substreams = 1,
3611 .channels_min = 2,
3612 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003613 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003614 .ops = {
3615 .open = alc880_playback_pcm_open,
3616 .prepare = alc880_playback_pcm_prepare,
3617 .cleanup = alc880_playback_pcm_cleanup
3618 },
3619};
3620
3621static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003622 .substreams = 1,
3623 .channels_min = 2,
3624 .channels_max = 2,
3625 /* NID is set in alc_build_pcms */
3626};
3627
3628static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3629 .substreams = 1,
3630 .channels_min = 2,
3631 .channels_max = 2,
3632 /* NID is set in alc_build_pcms */
3633};
3634
3635static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3636 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003637 .channels_min = 2,
3638 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003639 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003640 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003641 .prepare = alc880_alt_capture_pcm_prepare,
3642 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003643 },
3644};
3645
3646static struct hda_pcm_stream alc880_pcm_digital_playback = {
3647 .substreams = 1,
3648 .channels_min = 2,
3649 .channels_max = 2,
3650 /* NID is set in alc_build_pcms */
3651 .ops = {
3652 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003653 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003654 .prepare = alc880_dig_playback_pcm_prepare,
3655 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003656 },
3657};
3658
3659static struct hda_pcm_stream alc880_pcm_digital_capture = {
3660 .substreams = 1,
3661 .channels_min = 2,
3662 .channels_max = 2,
3663 /* NID is set in alc_build_pcms */
3664};
3665
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003666/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003667static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003668 .substreams = 0,
3669 .channels_min = 0,
3670 .channels_max = 0,
3671};
3672
Linus Torvalds1da177e2005-04-16 15:20:36 -07003673static int alc_build_pcms(struct hda_codec *codec)
3674{
3675 struct alc_spec *spec = codec->spec;
3676 struct hda_pcm *info = spec->pcm_rec;
3677 int i;
3678
3679 codec->num_pcms = 1;
3680 codec->pcm_info = info;
3681
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003682 if (spec->no_analog)
3683 goto skip_analog;
3684
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003685 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3686 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003687 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003688
Takashi Iwai4a471b72005-12-07 13:56:29 +01003689 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003690 if (snd_BUG_ON(!spec->multiout.dac_nids))
3691 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003692 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3693 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3694 }
3695 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003696 if (snd_BUG_ON(!spec->adc_nids))
3697 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003698 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3699 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3700 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003701
Takashi Iwai4a471b72005-12-07 13:56:29 +01003702 if (spec->channel_mode) {
3703 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3704 for (i = 0; i < spec->num_channel_mode; i++) {
3705 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3706 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3707 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003708 }
3709 }
3710
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003711 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003712 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003713 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003714 snprintf(spec->stream_name_digital,
3715 sizeof(spec->stream_name_digital),
3716 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003717 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003718 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003719 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003720 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003721 if (spec->dig_out_type)
3722 info->pcm_type = spec->dig_out_type;
3723 else
3724 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003725 if (spec->multiout.dig_out_nid &&
3726 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003727 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3728 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3729 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003730 if (spec->dig_in_nid &&
3731 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003732 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3733 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3734 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003735 /* FIXME: do we need this for all Realtek codec models? */
3736 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003737 }
3738
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003739 if (spec->no_analog)
3740 return 0;
3741
Takashi Iwaie08a0072006-09-07 17:52:14 +02003742 /* If the use of more than one ADC is requested for the current
3743 * model, configure a second analog capture-only PCM.
3744 */
3745 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003746 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3747 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003748 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003749 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003750 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003751 if (spec->alt_dac_nid) {
3752 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3753 *spec->stream_analog_alt_playback;
3754 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3755 spec->alt_dac_nid;
3756 } else {
3757 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3758 alc_pcm_null_stream;
3759 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3760 }
3761 if (spec->num_adc_nids > 1) {
3762 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3763 *spec->stream_analog_alt_capture;
3764 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3765 spec->adc_nids[1];
3766 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3767 spec->num_adc_nids - 1;
3768 } else {
3769 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3770 alc_pcm_null_stream;
3771 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003772 }
3773 }
3774
Linus Torvalds1da177e2005-04-16 15:20:36 -07003775 return 0;
3776}
3777
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003778static inline void alc_shutup(struct hda_codec *codec)
3779{
3780 snd_hda_shutup_pins(codec);
3781}
3782
Takashi Iwai603c4012008-07-30 15:01:44 +02003783static void alc_free_kctls(struct hda_codec *codec)
3784{
3785 struct alc_spec *spec = codec->spec;
3786
3787 if (spec->kctls.list) {
3788 struct snd_kcontrol_new *kctl = spec->kctls.list;
3789 int i;
3790 for (i = 0; i < spec->kctls.used; i++)
3791 kfree(kctl[i].name);
3792 }
3793 snd_array_free(&spec->kctls);
3794}
3795
Linus Torvalds1da177e2005-04-16 15:20:36 -07003796static void alc_free(struct hda_codec *codec)
3797{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003798 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003799
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003800 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003801 return;
3802
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003803 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003804 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003805 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003806 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003807}
3808
Hector Martinf5de24b2009-12-20 22:51:31 +01003809#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003810static void alc_power_eapd(struct hda_codec *codec)
3811{
3812 /* We currently only handle front, HP */
3813 switch (codec->vendor_id) {
3814 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003815 set_eapd(codec, 0x0f, 0);
3816 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003817 break;
3818 case 0x10ec0262:
3819 case 0x10ec0267:
3820 case 0x10ec0268:
3821 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003822 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003823 case 0x10ec0272:
3824 case 0x10ec0660:
3825 case 0x10ec0662:
3826 case 0x10ec0663:
3827 case 0x10ec0862:
3828 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003829 set_eapd(codec, 0x14, 0);
3830 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003831 break;
3832 }
3833}
3834
Hector Martinf5de24b2009-12-20 22:51:31 +01003835static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3836{
3837 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003838 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003839 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003840 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003841 return 0;
3842}
3843#endif
3844
Takashi Iwaie044c392008-10-27 16:56:24 +01003845#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003846static int alc_resume(struct hda_codec *codec)
3847{
Takashi Iwaie044c392008-10-27 16:56:24 +01003848 codec->patch_ops.init(codec);
3849 snd_hda_codec_resume_amp(codec);
3850 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02003851#ifdef CONFIG_SND_HDA_POWER_SAVE
3852 if (codec->patch_ops.check_power_status)
3853 codec->patch_ops.check_power_status(codec, 0x01);
3854#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003855 return 0;
3856}
Takashi Iwaie044c392008-10-27 16:56:24 +01003857#endif
3858
Linus Torvalds1da177e2005-04-16 15:20:36 -07003859/*
3860 */
3861static struct hda_codec_ops alc_patch_ops = {
3862 .build_controls = alc_build_controls,
3863 .build_pcms = alc_build_pcms,
3864 .init = alc_init,
3865 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003866 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003867#ifdef SND_HDA_NEEDS_RESUME
3868 .resume = alc_resume,
3869#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003870#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003871 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003872 .check_power_status = alc_check_power_status,
3873#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003874 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003875};
3876
Kailang Yangc027ddc2010-03-19 11:33:06 +01003877/* replace the codec chip_name with the given string */
3878static int alc_codec_rename(struct hda_codec *codec, const char *name)
3879{
3880 kfree(codec->chip_name);
3881 codec->chip_name = kstrdup(name, GFP_KERNEL);
3882 if (!codec->chip_name) {
3883 alc_free(codec);
3884 return -ENOMEM;
3885 }
3886 return 0;
3887}
3888
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003889/*
3890 * Test configuration for debugging
3891 *
3892 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3893 * enum controls.
3894 */
3895#ifdef CONFIG_SND_DEBUG
3896static hda_nid_t alc880_test_dac_nids[4] = {
3897 0x02, 0x03, 0x04, 0x05
3898};
3899
3900static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003901 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003902 .items = {
3903 { "In-1", 0x0 },
3904 { "In-2", 0x1 },
3905 { "In-3", 0x2 },
3906 { "In-4", 0x3 },
3907 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003908 { "Front", 0x5 },
3909 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003910 },
3911};
3912
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003913static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003914 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003915 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003916 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003917 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003918};
3919
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003920static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3921 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003922{
3923 static char *texts[] = {
3924 "N/A", "Line Out", "HP Out",
3925 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3926 };
3927 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3928 uinfo->count = 1;
3929 uinfo->value.enumerated.items = 8;
3930 if (uinfo->value.enumerated.item >= 8)
3931 uinfo->value.enumerated.item = 7;
3932 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3933 return 0;
3934}
3935
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003936static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3937 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003938{
3939 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3940 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3941 unsigned int pin_ctl, item = 0;
3942
3943 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3944 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3945 if (pin_ctl & AC_PINCTL_OUT_EN) {
3946 if (pin_ctl & AC_PINCTL_HP_EN)
3947 item = 2;
3948 else
3949 item = 1;
3950 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3951 switch (pin_ctl & AC_PINCTL_VREFEN) {
3952 case AC_PINCTL_VREF_HIZ: item = 3; break;
3953 case AC_PINCTL_VREF_50: item = 4; break;
3954 case AC_PINCTL_VREF_GRD: item = 5; break;
3955 case AC_PINCTL_VREF_80: item = 6; break;
3956 case AC_PINCTL_VREF_100: item = 7; break;
3957 }
3958 }
3959 ucontrol->value.enumerated.item[0] = item;
3960 return 0;
3961}
3962
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003963static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3964 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003965{
3966 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3967 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3968 static unsigned int ctls[] = {
3969 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3970 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3971 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3972 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3973 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3974 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3975 };
3976 unsigned int old_ctl, new_ctl;
3977
3978 old_ctl = snd_hda_codec_read(codec, nid, 0,
3979 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3980 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3981 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003982 int val;
3983 snd_hda_codec_write_cache(codec, nid, 0,
3984 AC_VERB_SET_PIN_WIDGET_CONTROL,
3985 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003986 val = ucontrol->value.enumerated.item[0] >= 3 ?
3987 HDA_AMP_MUTE : 0;
3988 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3989 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003990 return 1;
3991 }
3992 return 0;
3993}
3994
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003995static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3996 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003997{
3998 static char *texts[] = {
3999 "Front", "Surround", "CLFE", "Side"
4000 };
4001 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4002 uinfo->count = 1;
4003 uinfo->value.enumerated.items = 4;
4004 if (uinfo->value.enumerated.item >= 4)
4005 uinfo->value.enumerated.item = 3;
4006 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4007 return 0;
4008}
4009
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004010static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4011 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004012{
4013 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4014 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4015 unsigned int sel;
4016
4017 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4018 ucontrol->value.enumerated.item[0] = sel & 3;
4019 return 0;
4020}
4021
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004022static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4023 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004024{
4025 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4026 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4027 unsigned int sel;
4028
4029 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4030 if (ucontrol->value.enumerated.item[0] != sel) {
4031 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004032 snd_hda_codec_write_cache(codec, nid, 0,
4033 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004034 return 1;
4035 }
4036 return 0;
4037}
4038
4039#define PIN_CTL_TEST(xname,nid) { \
4040 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4041 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004042 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004043 .info = alc_test_pin_ctl_info, \
4044 .get = alc_test_pin_ctl_get, \
4045 .put = alc_test_pin_ctl_put, \
4046 .private_value = nid \
4047 }
4048
4049#define PIN_SRC_TEST(xname,nid) { \
4050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4051 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004052 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004053 .info = alc_test_pin_src_info, \
4054 .get = alc_test_pin_src_get, \
4055 .put = alc_test_pin_src_put, \
4056 .private_value = nid \
4057 }
4058
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004059static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004060 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4061 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4062 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4063 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004064 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4065 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4066 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4067 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004068 PIN_CTL_TEST("Front Pin Mode", 0x14),
4069 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4070 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4071 PIN_CTL_TEST("Side Pin Mode", 0x17),
4072 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4073 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4074 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4075 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4076 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4077 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4078 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4079 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4080 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4081 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4082 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4083 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4084 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4085 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4086 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4087 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4088 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4089 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004090 {
4091 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4092 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004093 .info = alc_ch_mode_info,
4094 .get = alc_ch_mode_get,
4095 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004096 },
4097 { } /* end */
4098};
4099
4100static struct hda_verb alc880_test_init_verbs[] = {
4101 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004102 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4104 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4105 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4106 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4107 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4108 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4109 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004110 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004111 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4112 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4113 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4114 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004115 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004116 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4118 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4119 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004120 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004121 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4123 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4124 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004125 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004126 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4127 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004128 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4130 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004131 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004132 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4133 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4134 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4135 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004136 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004138 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004140 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004141 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004142 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004143 /* Analog input/passthru */
4144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004149 { }
4150};
4151#endif
4152
Linus Torvalds1da177e2005-04-16 15:20:36 -07004153/*
4154 */
4155
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004156static const char *alc880_models[ALC880_MODEL_LAST] = {
4157 [ALC880_3ST] = "3stack",
4158 [ALC880_TCL_S700] = "tcl",
4159 [ALC880_3ST_DIG] = "3stack-digout",
4160 [ALC880_CLEVO] = "clevo",
4161 [ALC880_5ST] = "5stack",
4162 [ALC880_5ST_DIG] = "5stack-digout",
4163 [ALC880_W810] = "w810",
4164 [ALC880_Z71V] = "z71v",
4165 [ALC880_6ST] = "6stack",
4166 [ALC880_6ST_DIG] = "6stack-digout",
4167 [ALC880_ASUS] = "asus",
4168 [ALC880_ASUS_W1V] = "asus-w1v",
4169 [ALC880_ASUS_DIG] = "asus-dig",
4170 [ALC880_ASUS_DIG2] = "asus-dig2",
4171 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004172 [ALC880_UNIWILL_P53] = "uniwill-p53",
4173 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004174 [ALC880_F1734] = "F1734",
4175 [ALC880_LG] = "lg",
4176 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004177 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004178#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004179 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004180#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004181 [ALC880_AUTO] = "auto",
4182};
4183
4184static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004185 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004186 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4187 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4188 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4189 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4190 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4191 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4192 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4193 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004194 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4195 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004196 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4197 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4198 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4199 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4200 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4201 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4202 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4203 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4204 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4205 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004206 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004207 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4208 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4209 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004210 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004211 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004212 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4213 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004214 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4215 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004216 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4217 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4218 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4219 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004220 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4221 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004222 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004223 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004224 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004225 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004226 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4227 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004228 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004229 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004230 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004231 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004232 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004233 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004234 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004235 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004236 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004237 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4238 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004239 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004240 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4241 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4242 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4243 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004244 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4245 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004246 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004247 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004248 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4249 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004250 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4251 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4252 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004253 /* default Intel */
4254 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004255 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4256 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004257 {}
4258};
4259
Takashi Iwai16ded522005-06-10 19:58:24 +02004260/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004261 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004262 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004263static struct alc_config_preset alc880_presets[] = {
4264 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004266 .init_verbs = { alc880_volume_init_verbs,
4267 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004268 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004269 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004270 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4271 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004272 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004273 .input_mux = &alc880_capture_source,
4274 },
4275 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004276 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004277 .init_verbs = { alc880_volume_init_verbs,
4278 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004279 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004280 .dac_nids = alc880_dac_nids,
4281 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004282 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4283 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004284 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004285 .input_mux = &alc880_capture_source,
4286 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004287 [ALC880_TCL_S700] = {
4288 .mixers = { alc880_tcl_s700_mixer },
4289 .init_verbs = { alc880_volume_init_verbs,
4290 alc880_pin_tcl_S700_init_verbs,
4291 alc880_gpio2_init_verbs },
4292 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4293 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004294 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4295 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004296 .hp_nid = 0x03,
4297 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4298 .channel_mode = alc880_2_jack_modes,
4299 .input_mux = &alc880_capture_source,
4300 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004301 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004302 .mixers = { alc880_three_stack_mixer,
4303 alc880_five_stack_mixer},
4304 .init_verbs = { alc880_volume_init_verbs,
4305 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004306 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4307 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004308 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4309 .channel_mode = alc880_fivestack_modes,
4310 .input_mux = &alc880_capture_source,
4311 },
4312 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004313 .mixers = { alc880_three_stack_mixer,
4314 alc880_five_stack_mixer },
4315 .init_verbs = { alc880_volume_init_verbs,
4316 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004317 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4318 .dac_nids = alc880_dac_nids,
4319 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004320 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4321 .channel_mode = alc880_fivestack_modes,
4322 .input_mux = &alc880_capture_source,
4323 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004324 [ALC880_6ST] = {
4325 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004326 .init_verbs = { alc880_volume_init_verbs,
4327 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004328 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4329 .dac_nids = alc880_6st_dac_nids,
4330 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4331 .channel_mode = alc880_sixstack_modes,
4332 .input_mux = &alc880_6stack_capture_source,
4333 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004334 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004335 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004336 .init_verbs = { alc880_volume_init_verbs,
4337 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004338 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4339 .dac_nids = alc880_6st_dac_nids,
4340 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004341 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4342 .channel_mode = alc880_sixstack_modes,
4343 .input_mux = &alc880_6stack_capture_source,
4344 },
4345 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004346 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004347 .init_verbs = { alc880_volume_init_verbs,
4348 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004349 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004350 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4351 .dac_nids = alc880_w810_dac_nids,
4352 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004353 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4354 .channel_mode = alc880_w810_modes,
4355 .input_mux = &alc880_capture_source,
4356 },
4357 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004358 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004359 .init_verbs = { alc880_volume_init_verbs,
4360 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004361 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4362 .dac_nids = alc880_z71v_dac_nids,
4363 .dig_out_nid = ALC880_DIGOUT_NID,
4364 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004365 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4366 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004367 .input_mux = &alc880_capture_source,
4368 },
4369 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004370 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004371 .init_verbs = { alc880_volume_init_verbs,
4372 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004373 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4374 .dac_nids = alc880_f1734_dac_nids,
4375 .hp_nid = 0x02,
4376 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4377 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004378 .input_mux = &alc880_f1734_capture_source,
4379 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004380 .setup = alc880_uniwill_p53_setup,
4381 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004382 },
4383 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004384 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004385 .init_verbs = { alc880_volume_init_verbs,
4386 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004387 alc880_gpio1_init_verbs },
4388 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4389 .dac_nids = alc880_asus_dac_nids,
4390 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4391 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004392 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004393 .input_mux = &alc880_capture_source,
4394 },
4395 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004396 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004397 .init_verbs = { alc880_volume_init_verbs,
4398 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004399 alc880_gpio1_init_verbs },
4400 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4401 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004402 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004403 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4404 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004405 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004406 .input_mux = &alc880_capture_source,
4407 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004408 [ALC880_ASUS_DIG2] = {
4409 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004410 .init_verbs = { alc880_volume_init_verbs,
4411 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004412 alc880_gpio2_init_verbs }, /* use GPIO2 */
4413 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4414 .dac_nids = alc880_asus_dac_nids,
4415 .dig_out_nid = ALC880_DIGOUT_NID,
4416 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4417 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004418 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004419 .input_mux = &alc880_capture_source,
4420 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004421 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004423 .init_verbs = { alc880_volume_init_verbs,
4424 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004425 alc880_gpio1_init_verbs },
4426 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4427 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004428 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4430 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004431 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004432 .input_mux = &alc880_capture_source,
4433 },
4434 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004435 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004436 .init_verbs = { alc880_volume_init_verbs,
4437 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004438 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4439 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004440 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004441 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4442 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004443 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004444 .input_mux = &alc880_capture_source,
4445 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004446 [ALC880_UNIWILL] = {
4447 .mixers = { alc880_uniwill_mixer },
4448 .init_verbs = { alc880_volume_init_verbs,
4449 alc880_uniwill_init_verbs },
4450 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4451 .dac_nids = alc880_asus_dac_nids,
4452 .dig_out_nid = ALC880_DIGOUT_NID,
4453 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4454 .channel_mode = alc880_threestack_modes,
4455 .need_dac_fix = 1,
4456 .input_mux = &alc880_capture_source,
4457 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004458 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004459 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004460 },
4461 [ALC880_UNIWILL_P53] = {
4462 .mixers = { alc880_uniwill_p53_mixer },
4463 .init_verbs = { alc880_volume_init_verbs,
4464 alc880_uniwill_p53_init_verbs },
4465 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4466 .dac_nids = alc880_asus_dac_nids,
4467 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004468 .channel_mode = alc880_threestack_modes,
4469 .input_mux = &alc880_capture_source,
4470 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004471 .setup = alc880_uniwill_p53_setup,
4472 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004473 },
4474 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004475 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004476 .init_verbs = { alc880_volume_init_verbs,
4477 alc880_uniwill_p53_init_verbs,
4478 alc880_beep_init_verbs },
4479 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4480 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004481 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004482 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4483 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004484 .input_mux = &alc880_capture_source,
4485 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004486 .setup = alc880_uniwill_p53_setup,
4487 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004488 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004489 [ALC880_CLEVO] = {
4490 .mixers = { alc880_three_stack_mixer },
4491 .init_verbs = { alc880_volume_init_verbs,
4492 alc880_pin_clevo_init_verbs },
4493 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4494 .dac_nids = alc880_dac_nids,
4495 .hp_nid = 0x03,
4496 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4497 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004498 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004499 .input_mux = &alc880_capture_source,
4500 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004501 [ALC880_LG] = {
4502 .mixers = { alc880_lg_mixer },
4503 .init_verbs = { alc880_volume_init_verbs,
4504 alc880_lg_init_verbs },
4505 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4506 .dac_nids = alc880_lg_dac_nids,
4507 .dig_out_nid = ALC880_DIGOUT_NID,
4508 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4509 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004510 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004511 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004512 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004513 .setup = alc880_lg_setup,
4514 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004515#ifdef CONFIG_SND_HDA_POWER_SAVE
4516 .loopbacks = alc880_lg_loopbacks,
4517#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004518 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004519 [ALC880_LG_LW] = {
4520 .mixers = { alc880_lg_lw_mixer },
4521 .init_verbs = { alc880_volume_init_verbs,
4522 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004523 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004524 .dac_nids = alc880_dac_nids,
4525 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004526 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4527 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004528 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004529 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004530 .setup = alc880_lg_lw_setup,
4531 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004532 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004533 [ALC880_MEDION_RIM] = {
4534 .mixers = { alc880_medion_rim_mixer },
4535 .init_verbs = { alc880_volume_init_verbs,
4536 alc880_medion_rim_init_verbs,
4537 alc_gpio2_init_verbs },
4538 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4539 .dac_nids = alc880_dac_nids,
4540 .dig_out_nid = ALC880_DIGOUT_NID,
4541 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4542 .channel_mode = alc880_2_jack_modes,
4543 .input_mux = &alc880_medion_rim_capture_source,
4544 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004545 .setup = alc880_medion_rim_setup,
4546 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004547 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004548#ifdef CONFIG_SND_DEBUG
4549 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004550 .mixers = { alc880_test_mixer },
4551 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004552 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4553 .dac_nids = alc880_test_dac_nids,
4554 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004555 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4556 .channel_mode = alc880_test_modes,
4557 .input_mux = &alc880_test_capture_source,
4558 },
4559#endif
4560};
4561
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004562/*
4563 * Automatic parse of I/O pins from the BIOS configuration
4564 */
4565
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004566enum {
4567 ALC_CTL_WIDGET_VOL,
4568 ALC_CTL_WIDGET_MUTE,
4569 ALC_CTL_BIND_MUTE,
4570};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004571static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004572 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4573 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004574 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004575};
4576
4577/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004578static int add_control(struct alc_spec *spec, int type, const char *name,
4579 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004580{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004581 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004582
Takashi Iwai603c4012008-07-30 15:01:44 +02004583 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4584 knew = snd_array_new(&spec->kctls);
4585 if (!knew)
4586 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004587 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004588 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004589 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004590 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004591 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004592 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004593 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004594 return 0;
4595}
4596
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004597static int add_control_with_pfx(struct alc_spec *spec, int type,
4598 const char *pfx, const char *dir,
4599 const char *sfx, unsigned long val)
4600{
4601 char name[32];
4602 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4603 return add_control(spec, type, name, val);
4604}
4605
4606#define add_pb_vol_ctrl(spec, type, pfx, val) \
4607 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4608#define add_pb_sw_ctrl(spec, type, pfx, val) \
4609 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4610
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004611#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4612#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4613#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4614#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004615#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4616#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4617#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4618#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4619#define ALC880_PIN_CD_NID 0x1c
4620
4621/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004622static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4623 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004624{
4625 hda_nid_t nid;
4626 int assigned[4];
4627 int i, j;
4628
4629 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004630 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004631
4632 /* check the pins hardwired to audio widget */
4633 for (i = 0; i < cfg->line_outs; i++) {
4634 nid = cfg->line_out_pins[i];
4635 if (alc880_is_fixed_pin(nid)) {
4636 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004637 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004638 assigned[idx] = 1;
4639 }
4640 }
4641 /* left pins can be connect to any audio widget */
4642 for (i = 0; i < cfg->line_outs; i++) {
4643 nid = cfg->line_out_pins[i];
4644 if (alc880_is_fixed_pin(nid))
4645 continue;
4646 /* search for an empty channel */
4647 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004648 if (!assigned[j]) {
4649 spec->multiout.dac_nids[i] =
4650 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004651 assigned[j] = 1;
4652 break;
4653 }
4654 }
4655 }
4656 spec->multiout.num_dacs = cfg->line_outs;
4657 return 0;
4658}
4659
4660/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004661static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4662 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004663{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004664 static const char *chname[4] = {
4665 "Front", "Surround", NULL /*CLFE*/, "Side"
4666 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004667 hda_nid_t nid;
4668 int i, err;
4669
4670 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004671 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004672 continue;
4673 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4674 if (i == 2) {
4675 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004676 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4677 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004678 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4679 HDA_OUTPUT));
4680 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004681 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004682 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4683 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004684 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4685 HDA_OUTPUT));
4686 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004687 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004688 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4689 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004690 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4691 HDA_INPUT));
4692 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004693 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004694 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4695 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004696 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4697 HDA_INPUT));
4698 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004699 return err;
4700 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004701 const char *pfx;
4702 if (cfg->line_outs == 1 &&
4703 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4704 pfx = "Speaker";
4705 else
4706 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004707 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004708 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4709 HDA_OUTPUT));
4710 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004711 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004712 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004713 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4714 HDA_INPUT));
4715 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004716 return err;
4717 }
4718 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004719 return 0;
4720}
4721
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004722/* add playback controls for speaker and HP outputs */
4723static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4724 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004725{
4726 hda_nid_t nid;
4727 int err;
4728
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004729 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004730 return 0;
4731
4732 if (alc880_is_fixed_pin(pin)) {
4733 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004734 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004735 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004736 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004737 else
4738 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004739 /* control HP volume/switch on the output mixer amp */
4740 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004741 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4743 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004744 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004745 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004746 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4747 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004748 return err;
4749 } else if (alc880_is_multi_pin(pin)) {
4750 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004751 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004752 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004753 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4754 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004755 return err;
4756 }
4757 return 0;
4758}
4759
4760/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004761static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4762 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004763 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004764{
Kailang Yangdf694da2005-12-05 19:42:22 +01004765 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004766
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004767 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004768 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4769 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004770 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004771 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004772 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4773 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004774 return err;
4775 return 0;
4776}
4777
Takashi Iwai05f5f472009-08-25 13:10:18 +02004778static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004779{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004780 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4781 return (pincap & AC_PINCAP_IN) != 0;
4782}
4783
4784/* create playback/capture controls for input pins */
4785static int alc_auto_create_input_ctls(struct hda_codec *codec,
4786 const struct auto_pin_cfg *cfg,
4787 hda_nid_t mixer,
4788 hda_nid_t cap1, hda_nid_t cap2)
4789{
4790 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004791 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004792 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004793
4794 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004795 hda_nid_t pin;
4796
4797 pin = cfg->input_pins[i];
4798 if (!alc_is_input_pin(codec, pin))
4799 continue;
4800
4801 if (mixer) {
4802 idx = get_connection_index(codec, mixer, pin);
4803 if (idx >= 0) {
4804 err = new_analog_input(spec, pin,
4805 auto_pin_cfg_labels[i],
4806 idx, mixer);
4807 if (err < 0)
4808 return err;
4809 }
4810 }
4811
4812 if (!cap1)
4813 continue;
4814 idx = get_connection_index(codec, cap1, pin);
4815 if (idx < 0 && cap2)
4816 idx = get_connection_index(codec, cap2, pin);
4817 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004818 imux->items[imux->num_items].label =
4819 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004820 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004821 imux->num_items++;
4822 }
4823 }
4824 return 0;
4825}
4826
Takashi Iwai05f5f472009-08-25 13:10:18 +02004827static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4828 const struct auto_pin_cfg *cfg)
4829{
4830 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4831}
4832
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004833static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4834 unsigned int pin_type)
4835{
4836 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4837 pin_type);
4838 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004839 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4840 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004841}
4842
Kailang Yangdf694da2005-12-05 19:42:22 +01004843static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4844 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845 int dac_idx)
4846{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004847 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004848 /* need the manual connection? */
4849 if (alc880_is_multi_pin(nid)) {
4850 struct alc_spec *spec = codec->spec;
4851 int idx = alc880_multi_pin_idx(nid);
4852 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4853 AC_VERB_SET_CONNECT_SEL,
4854 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4855 }
4856}
4857
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004858static int get_pin_type(int line_out_type)
4859{
4860 if (line_out_type == AUTO_PIN_HP_OUT)
4861 return PIN_HP;
4862 else
4863 return PIN_OUT;
4864}
4865
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004866static void alc880_auto_init_multi_out(struct hda_codec *codec)
4867{
4868 struct alc_spec *spec = codec->spec;
4869 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004870
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004871 for (i = 0; i < spec->autocfg.line_outs; i++) {
4872 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004873 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4874 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004875 }
4876}
4877
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004878static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004879{
4880 struct alc_spec *spec = codec->spec;
4881 hda_nid_t pin;
4882
Takashi Iwai82bc9552006-03-21 11:24:42 +01004883 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004884 if (pin) /* connect to front */
4885 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004886 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004887 if (pin) /* connect to front */
4888 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4889}
4890
4891static void alc880_auto_init_analog_input(struct hda_codec *codec)
4892{
4893 struct alc_spec *spec = codec->spec;
4894 int i;
4895
4896 for (i = 0; i < AUTO_PIN_LAST; i++) {
4897 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004898 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004899 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004900 if (nid != ALC880_PIN_CD_NID &&
4901 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004902 snd_hda_codec_write(codec, nid, 0,
4903 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004904 AMP_OUT_MUTE);
4905 }
4906 }
4907}
4908
Takashi Iwai7f311a42010-04-09 17:32:23 +02004909static void alc880_auto_init_input_src(struct hda_codec *codec)
4910{
4911 struct alc_spec *spec = codec->spec;
4912 int c;
4913
4914 for (c = 0; c < spec->num_adc_nids; c++) {
4915 unsigned int mux_idx;
4916 const struct hda_input_mux *imux;
4917 mux_idx = c >= spec->num_mux_defs ? 0 : c;
4918 imux = &spec->input_mux[mux_idx];
4919 if (!imux->num_items && mux_idx > 0)
4920 imux = &spec->input_mux[0];
4921 if (imux)
4922 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
4923 AC_VERB_SET_CONNECT_SEL,
4924 imux->items[0].index);
4925 }
4926}
4927
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004928/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004929/* return 1 if successful, 0 if the proper config is not found,
4930 * or a negative error code
4931 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004932static int alc880_parse_auto_config(struct hda_codec *codec)
4933{
4934 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004935 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004936 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004937
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004938 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4939 alc880_ignore);
4940 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004941 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004942 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004943 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004944
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004945 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4946 if (err < 0)
4947 return err;
4948 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4949 if (err < 0)
4950 return err;
4951 err = alc880_auto_create_extra_out(spec,
4952 spec->autocfg.speaker_pins[0],
4953 "Speaker");
4954 if (err < 0)
4955 return err;
4956 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4957 "Headphone");
4958 if (err < 0)
4959 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004960 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004961 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004962 return err;
4963
4964 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4965
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004966 /* check multiple SPDIF-out (for recent codecs) */
4967 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4968 hda_nid_t dig_nid;
4969 err = snd_hda_get_connections(codec,
4970 spec->autocfg.dig_out_pins[i],
4971 &dig_nid, 1);
4972 if (err < 0)
4973 continue;
4974 if (!i)
4975 spec->multiout.dig_out_nid = dig_nid;
4976 else {
4977 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004978 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004979 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004980 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004981 }
4982 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004983 if (spec->autocfg.dig_in_pin)
4984 spec->dig_in_nid = ALC880_DIGIN_NID;
4985
Takashi Iwai603c4012008-07-30 15:01:44 +02004986 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004987 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004988
Takashi Iwaid88897e2008-10-31 15:01:37 +01004989 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004990
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004991 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004992 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004993
Kailang Yang6227cdc2010-02-25 08:36:52 +01004994 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004995
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996 return 1;
4997}
4998
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004999/* additional initialization for auto-configuration model */
5000static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005001{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005002 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005003 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005004 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005005 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005006 alc880_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005007 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005008 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005009}
5010
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005011/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5012 * one of two digital mic pins, e.g. on ALC272
5013 */
5014static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005015{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005016 struct alc_spec *spec = codec->spec;
5017 int i;
5018
5019 for (i = 0; i < spec->num_adc_nids; i++) {
5020 hda_nid_t cap = spec->capsrc_nids ?
5021 spec->capsrc_nids[i] : spec->adc_nids[i];
5022 int iidx, eidx;
5023
5024 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5025 if (iidx < 0)
5026 continue;
5027 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5028 if (eidx < 0)
5029 continue;
5030 spec->int_mic.mux_idx = iidx;
5031 spec->ext_mic.mux_idx = eidx;
5032 if (spec->capsrc_nids)
5033 spec->capsrc_nids += i;
5034 spec->adc_nids += i;
5035 spec->num_adc_nids = 1;
5036 return;
5037 }
5038 snd_printd(KERN_INFO "hda_codec: %s: "
5039 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5040 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5041 spec->auto_mic = 0; /* disable auto-mic to be sure */
5042}
5043
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005044/* choose the ADC/MUX containing the input pin and initialize the setup */
5045static void fixup_single_adc(struct hda_codec *codec)
5046{
5047 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01005048 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005049 int i;
5050
5051 /* search for the input pin; there must be only one */
5052 for (i = 0; i < AUTO_PIN_LAST; i++) {
5053 if (spec->autocfg.input_pins[i]) {
5054 pin = spec->autocfg.input_pins[i];
5055 break;
5056 }
5057 }
5058 if (!pin)
5059 return;
5060
5061 /* set the default connection to that pin */
5062 for (i = 0; i < spec->num_adc_nids; i++) {
5063 hda_nid_t cap = spec->capsrc_nids ?
5064 spec->capsrc_nids[i] : spec->adc_nids[i];
5065 int idx;
5066
5067 idx = get_connection_index(codec, cap, pin);
5068 if (idx < 0)
5069 continue;
5070 /* use only this ADC */
5071 if (spec->capsrc_nids)
5072 spec->capsrc_nids += i;
5073 spec->adc_nids += i;
5074 spec->num_adc_nids = 1;
5075 /* select or unmute this route */
5076 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5077 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5078 HDA_AMP_MUTE, 0);
5079 } else {
5080 snd_hda_codec_write_cache(codec, cap, 0,
5081 AC_VERB_SET_CONNECT_SEL, idx);
5082 }
5083 return;
5084 }
5085}
5086
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005087static void set_capture_mixer(struct hda_codec *codec)
5088{
5089 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005090 static struct snd_kcontrol_new *caps[2][3] = {
5091 { alc_capture_mixer_nosrc1,
5092 alc_capture_mixer_nosrc2,
5093 alc_capture_mixer_nosrc3 },
5094 { alc_capture_mixer1,
5095 alc_capture_mixer2,
5096 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005097 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005098 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005099 int mux = 0;
5100 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005101 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005102 else if (spec->input_mux) {
5103 if (spec->input_mux->num_items > 1)
5104 mux = 1;
5105 else if (spec->input_mux->num_items == 1)
5106 fixup_single_adc(codec);
5107 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01005108 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
5109 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005110}
5111
Takashi Iwai66946352010-03-29 17:21:45 +02005112/* fill adc_nids (and capsrc_nids) containing all active input pins */
5113static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5114 int num_nids)
5115{
5116 struct alc_spec *spec = codec->spec;
5117 int n;
5118 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5119
5120 for (n = 0; n < num_nids; n++) {
5121 hda_nid_t adc, cap;
5122 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5123 int nconns, i, j;
5124
5125 adc = nids[n];
5126 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5127 continue;
5128 cap = adc;
5129 nconns = snd_hda_get_connections(codec, cap, conn,
5130 ARRAY_SIZE(conn));
5131 if (nconns == 1) {
5132 cap = conn[0];
5133 nconns = snd_hda_get_connections(codec, cap, conn,
5134 ARRAY_SIZE(conn));
5135 }
5136 if (nconns <= 0)
5137 continue;
5138 if (!fallback_adc) {
5139 fallback_adc = adc;
5140 fallback_cap = cap;
5141 }
5142 for (i = 0; i < AUTO_PIN_LAST; i++) {
5143 hda_nid_t nid = spec->autocfg.input_pins[i];
5144 if (!nid)
5145 continue;
5146 for (j = 0; j < nconns; j++) {
5147 if (conn[j] == nid)
5148 break;
5149 }
5150 if (j >= nconns)
5151 break;
5152 }
5153 if (i >= AUTO_PIN_LAST) {
5154 int num_adcs = spec->num_adc_nids;
5155 spec->private_adc_nids[num_adcs] = adc;
5156 spec->private_capsrc_nids[num_adcs] = cap;
5157 spec->num_adc_nids++;
5158 spec->adc_nids = spec->private_adc_nids;
5159 if (adc != cap)
5160 spec->capsrc_nids = spec->private_capsrc_nids;
5161 }
5162 }
5163 if (!spec->num_adc_nids) {
5164 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005165 " using fallback 0x%x\n",
5166 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005167 spec->private_adc_nids[0] = fallback_adc;
5168 spec->adc_nids = spec->private_adc_nids;
5169 if (fallback_adc != fallback_cap) {
5170 spec->private_capsrc_nids[0] = fallback_cap;
5171 spec->capsrc_nids = spec->private_adc_nids;
5172 }
5173 }
5174}
5175
Takashi Iwai67d634c2009-11-16 15:35:59 +01005176#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005177#define set_beep_amp(spec, nid, idx, dir) \
5178 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01005179#else
5180#define set_beep_amp(spec, nid, idx, dir) /* NOP */
5181#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005182
5183/*
5184 * OK, here we have finally the patch for ALC880
5185 */
5186
Linus Torvalds1da177e2005-04-16 15:20:36 -07005187static int patch_alc880(struct hda_codec *codec)
5188{
5189 struct alc_spec *spec;
5190 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005191 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005192
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005193 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005194 if (spec == NULL)
5195 return -ENOMEM;
5196
5197 codec->spec = spec;
5198
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005199 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5200 alc880_models,
5201 alc880_cfg_tbl);
5202 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005203 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5204 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005205 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005206 }
5207
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005208 if (board_config == ALC880_AUTO) {
5209 /* automatic parse from the BIOS config */
5210 err = alc880_parse_auto_config(codec);
5211 if (err < 0) {
5212 alc_free(codec);
5213 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005214 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005215 printk(KERN_INFO
5216 "hda_codec: Cannot set up configuration "
5217 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005218 board_config = ALC880_3ST;
5219 }
5220 }
5221
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005222 err = snd_hda_attach_beep_device(codec, 0x1);
5223 if (err < 0) {
5224 alc_free(codec);
5225 return err;
5226 }
5227
Kailang Yangdf694da2005-12-05 19:42:22 +01005228 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005229 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005230
Linus Torvalds1da177e2005-04-16 15:20:36 -07005231 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5232 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005233 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005234
Linus Torvalds1da177e2005-04-16 15:20:36 -07005235 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5236 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5237
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005238 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005239 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005240 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005241 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005242 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005243 if (wcap != AC_WID_AUD_IN) {
5244 spec->adc_nids = alc880_adc_nids_alt;
5245 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005246 } else {
5247 spec->adc_nids = alc880_adc_nids;
5248 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005249 }
5250 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005251 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005252 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005253
Takashi Iwai2134ea42008-01-10 16:53:55 +01005254 spec->vmaster_nid = 0x0c;
5255
Linus Torvalds1da177e2005-04-16 15:20:36 -07005256 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005257 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005258 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005259#ifdef CONFIG_SND_HDA_POWER_SAVE
5260 if (!spec->loopback.amplist)
5261 spec->loopback.amplist = alc880_loopbacks;
5262#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005263
5264 return 0;
5265}
5266
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005267
Linus Torvalds1da177e2005-04-16 15:20:36 -07005268/*
5269 * ALC260 support
5270 */
5271
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005272static hda_nid_t alc260_dac_nids[1] = {
5273 /* front */
5274 0x02,
5275};
5276
5277static hda_nid_t alc260_adc_nids[1] = {
5278 /* ADC0 */
5279 0x04,
5280};
5281
Kailang Yangdf694da2005-12-05 19:42:22 +01005282static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005283 /* ADC1 */
5284 0x05,
5285};
5286
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005287/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5288 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5289 */
5290static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005291 /* ADC0, ADC1 */
5292 0x04, 0x05
5293};
5294
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005295#define ALC260_DIGOUT_NID 0x03
5296#define ALC260_DIGIN_NID 0x06
5297
5298static struct hda_input_mux alc260_capture_source = {
5299 .num_items = 4,
5300 .items = {
5301 { "Mic", 0x0 },
5302 { "Front Mic", 0x1 },
5303 { "Line", 0x2 },
5304 { "CD", 0x4 },
5305 },
5306};
5307
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005308/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005309 * headphone jack and the internal CD lines since these are the only pins at
5310 * which audio can appear. For flexibility, also allow the option of
5311 * recording the mixer output on the second ADC (ADC0 doesn't have a
5312 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005313 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005314static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5315 {
5316 .num_items = 3,
5317 .items = {
5318 { "Mic/Line", 0x0 },
5319 { "CD", 0x4 },
5320 { "Headphone", 0x2 },
5321 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005322 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005323 {
5324 .num_items = 4,
5325 .items = {
5326 { "Mic/Line", 0x0 },
5327 { "CD", 0x4 },
5328 { "Headphone", 0x2 },
5329 { "Mixer", 0x5 },
5330 },
5331 },
5332
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005333};
5334
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005335/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5336 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005337 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005338static struct hda_input_mux alc260_acer_capture_sources[2] = {
5339 {
5340 .num_items = 4,
5341 .items = {
5342 { "Mic", 0x0 },
5343 { "Line", 0x2 },
5344 { "CD", 0x4 },
5345 { "Headphone", 0x5 },
5346 },
5347 },
5348 {
5349 .num_items = 5,
5350 .items = {
5351 { "Mic", 0x0 },
5352 { "Line", 0x2 },
5353 { "CD", 0x4 },
5354 { "Headphone", 0x6 },
5355 { "Mixer", 0x5 },
5356 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005357 },
5358};
Michael Schwingencc959482009-02-22 18:58:45 +01005359
5360/* Maxdata Favorit 100XS */
5361static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5362 {
5363 .num_items = 2,
5364 .items = {
5365 { "Line/Mic", 0x0 },
5366 { "CD", 0x4 },
5367 },
5368 },
5369 {
5370 .num_items = 3,
5371 .items = {
5372 { "Line/Mic", 0x0 },
5373 { "CD", 0x4 },
5374 { "Mixer", 0x5 },
5375 },
5376 },
5377};
5378
Linus Torvalds1da177e2005-04-16 15:20:36 -07005379/*
5380 * This is just place-holder, so there's something for alc_build_pcms to look
5381 * at when it calculates the maximum number of channels. ALC260 has no mixer
5382 * element which allows changing the channel mode, so the verb list is
5383 * never used.
5384 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005385static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005386 { 2, NULL },
5387};
5388
Kailang Yangdf694da2005-12-05 19:42:22 +01005389
5390/* Mixer combinations
5391 *
5392 * basic: base_output + input + pc_beep + capture
5393 * HP: base_output + input + capture_alt
5394 * HP_3013: hp_3013 + input + capture
5395 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005396 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005397 */
5398
5399static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005400 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005401 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005402 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5403 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5404 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5405 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5406 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005407};
Kailang Yangdf694da2005-12-05 19:42:22 +01005408
5409static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005410 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5411 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5412 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5413 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5415 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5416 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5417 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005418 { } /* end */
5419};
5420
Takashi Iwaibec15c32008-01-28 18:16:30 +01005421/* update HP, line and mono out pins according to the master switch */
5422static void alc260_hp_master_update(struct hda_codec *codec,
5423 hda_nid_t hp, hda_nid_t line,
5424 hda_nid_t mono)
5425{
5426 struct alc_spec *spec = codec->spec;
5427 unsigned int val = spec->master_sw ? PIN_HP : 0;
5428 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005429 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005430 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005431 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005432 val);
5433 /* mono (speaker) depending on the HP jack sense */
5434 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005435 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005436 val);
5437}
5438
5439static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5440 struct snd_ctl_elem_value *ucontrol)
5441{
5442 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5443 struct alc_spec *spec = codec->spec;
5444 *ucontrol->value.integer.value = spec->master_sw;
5445 return 0;
5446}
5447
5448static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5449 struct snd_ctl_elem_value *ucontrol)
5450{
5451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5452 struct alc_spec *spec = codec->spec;
5453 int val = !!*ucontrol->value.integer.value;
5454 hda_nid_t hp, line, mono;
5455
5456 if (val == spec->master_sw)
5457 return 0;
5458 spec->master_sw = val;
5459 hp = (kcontrol->private_value >> 16) & 0xff;
5460 line = (kcontrol->private_value >> 8) & 0xff;
5461 mono = kcontrol->private_value & 0xff;
5462 alc260_hp_master_update(codec, hp, line, mono);
5463 return 1;
5464}
5465
5466static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5467 {
5468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5469 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005470 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005471 .info = snd_ctl_boolean_mono_info,
5472 .get = alc260_hp_master_sw_get,
5473 .put = alc260_hp_master_sw_put,
5474 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5475 },
5476 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5477 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5478 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5479 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5480 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5481 HDA_OUTPUT),
5482 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5483 { } /* end */
5484};
5485
5486static struct hda_verb alc260_hp_unsol_verbs[] = {
5487 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5488 {},
5489};
5490
5491static void alc260_hp_automute(struct hda_codec *codec)
5492{
5493 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005494
Wu Fengguang864f92b2009-11-18 12:38:02 +08005495 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005496 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5497}
5498
5499static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5500{
5501 if ((res >> 26) == ALC880_HP_EVENT)
5502 alc260_hp_automute(codec);
5503}
5504
Kailang Yangdf694da2005-12-05 19:42:22 +01005505static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005506 {
5507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5508 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005509 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005510 .info = snd_ctl_boolean_mono_info,
5511 .get = alc260_hp_master_sw_get,
5512 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005513 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005514 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005515 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5516 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5517 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5518 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005521 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5522 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005523 { } /* end */
5524};
5525
Kailang Yang3f878302008-08-26 13:02:23 +02005526static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5527 .ops = &snd_hda_bind_vol,
5528 .values = {
5529 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5530 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5531 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5532 0
5533 },
5534};
5535
5536static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5537 .ops = &snd_hda_bind_sw,
5538 .values = {
5539 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5540 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5541 0
5542 },
5543};
5544
5545static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5546 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5547 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5548 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5549 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5550 { } /* end */
5551};
5552
Takashi Iwaibec15c32008-01-28 18:16:30 +01005553static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5554 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5555 {},
5556};
5557
5558static void alc260_hp_3013_automute(struct hda_codec *codec)
5559{
5560 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005561
Wu Fengguang864f92b2009-11-18 12:38:02 +08005562 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005563 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005564}
5565
5566static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5567 unsigned int res)
5568{
5569 if ((res >> 26) == ALC880_HP_EVENT)
5570 alc260_hp_3013_automute(codec);
5571}
5572
Kailang Yang3f878302008-08-26 13:02:23 +02005573static void alc260_hp_3012_automute(struct hda_codec *codec)
5574{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005575 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005576
Kailang Yang3f878302008-08-26 13:02:23 +02005577 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5578 bits);
5579 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5580 bits);
5581 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5582 bits);
5583}
5584
5585static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5586 unsigned int res)
5587{
5588 if ((res >> 26) == ALC880_HP_EVENT)
5589 alc260_hp_3012_automute(codec);
5590}
5591
5592/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005593 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5594 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005595static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005596 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005597 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005598 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005599 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5600 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5601 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5602 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005603 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005604 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5605 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005606 { } /* end */
5607};
5608
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005609/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5610 * versions of the ALC260 don't act on requests to enable mic bias from NID
5611 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5612 * datasheet doesn't mention this restriction. At this stage it's not clear
5613 * whether this behaviour is intentional or is a hardware bug in chip
5614 * revisions available in early 2006. Therefore for now allow the
5615 * "Headphone Jack Mode" control to span all choices, but if it turns out
5616 * that the lack of mic bias for this NID is intentional we could change the
5617 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5618 *
5619 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5620 * don't appear to make the mic bias available from the "line" jack, even
5621 * though the NID used for this jack (0x14) can supply it. The theory is
5622 * that perhaps Acer have included blocking capacitors between the ALC260
5623 * and the output jack. If this turns out to be the case for all such
5624 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5625 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005626 *
5627 * The C20x Tablet series have a mono internal speaker which is controlled
5628 * via the chip's Mono sum widget and pin complex, so include the necessary
5629 * controls for such models. On models without a "mono speaker" the control
5630 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005631 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005632static struct snd_kcontrol_new alc260_acer_mixer[] = {
5633 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5634 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005635 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005636 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005637 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005638 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005639 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005640 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5641 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5643 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5644 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5645 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5646 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5647 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005648 { } /* end */
5649};
5650
Michael Schwingencc959482009-02-22 18:58:45 +01005651/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5652 */
5653static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5654 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5655 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5656 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5657 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5658 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5659 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5660 { } /* end */
5661};
5662
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005663/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5664 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5665 */
5666static struct snd_kcontrol_new alc260_will_mixer[] = {
5667 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5668 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5670 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5671 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5672 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5673 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5674 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5675 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5676 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005677 { } /* end */
5678};
5679
5680/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5681 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5682 */
5683static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5684 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5685 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5686 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5687 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5688 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5689 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5690 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5691 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5692 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5693 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5694 { } /* end */
5695};
5696
Kailang Yangdf694da2005-12-05 19:42:22 +01005697/*
5698 * initialization verbs
5699 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005700static struct hda_verb alc260_init_verbs[] = {
5701 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005703 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005704 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005705 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005706 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005707 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005708 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005709 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005711 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005712 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005713 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005714 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005715 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005716 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005717 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005718 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5719 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005720 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005721 /* set connection select to line in (default select for this ADC) */
5722 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005723 /* mute capture amp left and right */
5724 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5725 /* set connection select to line in (default select for this ADC) */
5726 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005727 /* set vol=0 Line-Out mixer amp left and right */
5728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5729 /* unmute pin widget amp left and right (no gain on this amp) */
5730 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5731 /* set vol=0 HP mixer amp left and right */
5732 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5733 /* unmute pin widget amp left and right (no gain on this amp) */
5734 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5735 /* set vol=0 Mono mixer amp left and right */
5736 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5737 /* unmute pin widget amp left and right (no gain on this amp) */
5738 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5739 /* unmute LINE-2 out pin */
5740 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005741 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5742 * Line In 2 = 0x03
5743 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005744 /* mute analog inputs */
5745 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005750 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005751 /* mute Front out path */
5752 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5754 /* mute Headphone out path */
5755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5756 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5757 /* mute Mono out path */
5758 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5759 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005760 { }
5761};
5762
Takashi Iwai474167d2006-05-17 17:17:43 +02005763#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005764static struct hda_verb alc260_hp_init_verbs[] = {
5765 /* Headphone and output */
5766 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5767 /* mono output */
5768 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5769 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5770 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5771 /* Mic2 (front panel) pin widget for input and vref at 80% */
5772 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5773 /* Line In pin widget for input */
5774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5775 /* Line-2 pin widget for output */
5776 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5777 /* CD pin widget for input */
5778 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5779 /* unmute amp left and right */
5780 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5781 /* set connection select to line in (default select for this ADC) */
5782 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5783 /* unmute Line-Out mixer amp left and right (volume = 0) */
5784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5785 /* mute pin widget amp left and right (no gain on this amp) */
5786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5787 /* unmute HP mixer amp left and right (volume = 0) */
5788 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5789 /* mute pin widget amp left and right (no gain on this amp) */
5790 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005791 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5792 * Line In 2 = 0x03
5793 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005794 /* mute analog inputs */
5795 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005800 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5801 /* Unmute Front out path */
5802 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5804 /* Unmute Headphone out path */
5805 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5806 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5807 /* Unmute Mono out path */
5808 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5809 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5810 { }
5811};
Takashi Iwai474167d2006-05-17 17:17:43 +02005812#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005813
5814static struct hda_verb alc260_hp_3013_init_verbs[] = {
5815 /* Line out and output */
5816 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5817 /* mono output */
5818 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5819 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5820 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5821 /* Mic2 (front panel) pin widget for input and vref at 80% */
5822 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5823 /* Line In pin widget for input */
5824 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5825 /* Headphone pin widget for output */
5826 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5827 /* CD pin widget for input */
5828 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5829 /* unmute amp left and right */
5830 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5831 /* set connection select to line in (default select for this ADC) */
5832 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5833 /* unmute Line-Out mixer amp left and right (volume = 0) */
5834 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5835 /* mute pin widget amp left and right (no gain on this amp) */
5836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5837 /* unmute HP mixer amp left and right (volume = 0) */
5838 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5839 /* mute pin widget amp left and right (no gain on this amp) */
5840 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005841 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5842 * Line In 2 = 0x03
5843 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005844 /* mute analog inputs */
5845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005850 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5851 /* Unmute Front out path */
5852 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5854 /* Unmute Headphone out path */
5855 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5857 /* Unmute Mono out path */
5858 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5859 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5860 { }
5861};
5862
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005863/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005864 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5865 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005866 */
5867static struct hda_verb alc260_fujitsu_init_verbs[] = {
5868 /* Disable all GPIOs */
5869 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5870 /* Internal speaker is connected to headphone pin */
5871 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5872 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005874 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5875 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5876 /* Ensure all other unused pins are disabled and muted. */
5877 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5878 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005879 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005880 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005881 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005882 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005885
Jonathan Woithef7ace402006-02-28 11:46:14 +01005886 /* Disable digital (SPDIF) pins */
5887 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5888 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005889
Kailang Yangea1fb292008-08-26 12:58:38 +02005890 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005891 * when acting as an output.
5892 */
5893 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5894
5895 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005896 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5898 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5899 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5900 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5902 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005905
Jonathan Woithef7ace402006-02-28 11:46:14 +01005906 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5907 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5908 /* Unmute Line1 pin widget output buffer since it starts as an output.
5909 * If the pin mode is changed by the user the pin mode control will
5910 * take care of enabling the pin's input/output buffers as needed.
5911 * Therefore there's no need to enable the input buffer at this
5912 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005913 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005915 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005916 * mixer ctrl)
5917 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005918 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005919
Jonathan Woithef7ace402006-02-28 11:46:14 +01005920 /* Mute capture amp left and right */
5921 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005922 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005923 * in (on mic1 pin)
5924 */
5925 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005926
Jonathan Woithef7ace402006-02-28 11:46:14 +01005927 /* Do the same for the second ADC: mute capture input amp and
5928 * set ADC connection to line in (on mic1 pin)
5929 */
5930 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5931 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005932
Jonathan Woithef7ace402006-02-28 11:46:14 +01005933 /* Mute all inputs to mixer widget (even unconnected ones) */
5934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005942
5943 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005944};
5945
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005946/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5947 * similar laptops (adapted from Fujitsu init verbs).
5948 */
5949static struct hda_verb alc260_acer_init_verbs[] = {
5950 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5951 * the headphone jack. Turn this on and rely on the standard mute
5952 * methods whenever the user wants to turn these outputs off.
5953 */
5954 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5955 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5956 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5957 /* Internal speaker/Headphone jack is connected to Line-out pin */
5958 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5959 /* Internal microphone/Mic jack is connected to Mic1 pin */
5960 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5961 /* Line In jack is connected to Line1 pin */
5962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005963 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5964 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005965 /* Ensure all other unused pins are disabled and muted. */
5966 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5967 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005968 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5969 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5972 /* Disable digital (SPDIF) pins */
5973 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5974 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5975
Kailang Yangea1fb292008-08-26 12:58:38 +02005976 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005977 * bus when acting as outputs.
5978 */
5979 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5980 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5981
5982 /* Start with output sum widgets muted and their output gains at min */
5983 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5986 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5989 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5990 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5991 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5992
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005993 /* Unmute Line-out pin widget amp left and right
5994 * (no equiv mixer ctrl)
5995 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005996 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005997 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5998 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005999 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6000 * inputs. If the pin mode is changed by the user the pin mode control
6001 * will take care of enabling the pin's input/output buffers as needed.
6002 * Therefore there's no need to enable the input buffer at this
6003 * stage.
6004 */
6005 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6007
6008 /* Mute capture amp left and right */
6009 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6010 /* Set ADC connection select to match default mixer setting - mic
6011 * (on mic1 pin)
6012 */
6013 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6014
6015 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006016 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006017 */
6018 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006019 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006020
6021 /* Mute all inputs to mixer widget (even unconnected ones) */
6022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6030
6031 { }
6032};
6033
Michael Schwingencc959482009-02-22 18:58:45 +01006034/* Initialisation sequence for Maxdata Favorit 100XS
6035 * (adapted from Acer init verbs).
6036 */
6037static struct hda_verb alc260_favorit100_init_verbs[] = {
6038 /* GPIO 0 enables the output jack.
6039 * Turn this on and rely on the standard mute
6040 * methods whenever the user wants to turn these outputs off.
6041 */
6042 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6043 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6044 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6045 /* Line/Mic input jack is connected to Mic1 pin */
6046 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6047 /* Ensure all other unused pins are disabled and muted. */
6048 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6049 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6050 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6051 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6052 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6053 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6054 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6055 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6056 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6058 /* Disable digital (SPDIF) pins */
6059 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6060 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6061
6062 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6063 * bus when acting as outputs.
6064 */
6065 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6066 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6067
6068 /* Start with output sum widgets muted and their output gains at min */
6069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6075 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6076 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6077 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6078
6079 /* Unmute Line-out pin widget amp left and right
6080 * (no equiv mixer ctrl)
6081 */
6082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6083 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6084 * inputs. If the pin mode is changed by the user the pin mode control
6085 * will take care of enabling the pin's input/output buffers as needed.
6086 * Therefore there's no need to enable the input buffer at this
6087 * stage.
6088 */
6089 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6090
6091 /* Mute capture amp left and right */
6092 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6093 /* Set ADC connection select to match default mixer setting - mic
6094 * (on mic1 pin)
6095 */
6096 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6097
6098 /* Do similar with the second ADC: mute capture input amp and
6099 * set ADC connection to mic to match ALSA's default state.
6100 */
6101 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6102 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6103
6104 /* Mute all inputs to mixer widget (even unconnected ones) */
6105 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6106 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6107 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6113
6114 { }
6115};
6116
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006117static struct hda_verb alc260_will_verbs[] = {
6118 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6119 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6120 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6121 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6122 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6123 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6124 {}
6125};
6126
6127static struct hda_verb alc260_replacer_672v_verbs[] = {
6128 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6129 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6130 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6131
6132 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6133 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6134 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6135
6136 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6137 {}
6138};
6139
6140/* toggle speaker-output according to the hp-jack state */
6141static void alc260_replacer_672v_automute(struct hda_codec *codec)
6142{
6143 unsigned int present;
6144
6145 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006146 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006147 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006148 snd_hda_codec_write_cache(codec, 0x01, 0,
6149 AC_VERB_SET_GPIO_DATA, 1);
6150 snd_hda_codec_write_cache(codec, 0x0f, 0,
6151 AC_VERB_SET_PIN_WIDGET_CONTROL,
6152 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006153 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006154 snd_hda_codec_write_cache(codec, 0x01, 0,
6155 AC_VERB_SET_GPIO_DATA, 0);
6156 snd_hda_codec_write_cache(codec, 0x0f, 0,
6157 AC_VERB_SET_PIN_WIDGET_CONTROL,
6158 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006159 }
6160}
6161
6162static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6163 unsigned int res)
6164{
6165 if ((res >> 26) == ALC880_HP_EVENT)
6166 alc260_replacer_672v_automute(codec);
6167}
6168
Kailang Yang3f878302008-08-26 13:02:23 +02006169static struct hda_verb alc260_hp_dc7600_verbs[] = {
6170 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6171 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6172 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6173 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6174 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6175 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6176 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6177 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6178 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6179 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6180 {}
6181};
6182
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006183/* Test configuration for debugging, modelled after the ALC880 test
6184 * configuration.
6185 */
6186#ifdef CONFIG_SND_DEBUG
6187static hda_nid_t alc260_test_dac_nids[1] = {
6188 0x02,
6189};
6190static hda_nid_t alc260_test_adc_nids[2] = {
6191 0x04, 0x05,
6192};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006193/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006194 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006195 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006196 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006197static struct hda_input_mux alc260_test_capture_sources[2] = {
6198 {
6199 .num_items = 7,
6200 .items = {
6201 { "MIC1 pin", 0x0 },
6202 { "MIC2 pin", 0x1 },
6203 { "LINE1 pin", 0x2 },
6204 { "LINE2 pin", 0x3 },
6205 { "CD pin", 0x4 },
6206 { "LINE-OUT pin", 0x5 },
6207 { "HP-OUT pin", 0x6 },
6208 },
6209 },
6210 {
6211 .num_items = 8,
6212 .items = {
6213 { "MIC1 pin", 0x0 },
6214 { "MIC2 pin", 0x1 },
6215 { "LINE1 pin", 0x2 },
6216 { "LINE2 pin", 0x3 },
6217 { "CD pin", 0x4 },
6218 { "Mixer", 0x5 },
6219 { "LINE-OUT pin", 0x6 },
6220 { "HP-OUT pin", 0x7 },
6221 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006222 },
6223};
6224static struct snd_kcontrol_new alc260_test_mixer[] = {
6225 /* Output driver widgets */
6226 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6227 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6228 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6229 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6230 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6231 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6232
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006233 /* Modes for retasking pin widgets
6234 * Note: the ALC260 doesn't seem to act on requests to enable mic
6235 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6236 * mention this restriction. At this stage it's not clear whether
6237 * this behaviour is intentional or is a hardware bug in chip
6238 * revisions available at least up until early 2006. Therefore for
6239 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6240 * choices, but if it turns out that the lack of mic bias for these
6241 * NIDs is intentional we could change their modes from
6242 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6243 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006244 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6245 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6246 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6247 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6248 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6249 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6250
6251 /* Loopback mixer controls */
6252 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6253 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6254 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6255 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6256 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6257 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6258 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6259 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6260 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6261 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006262 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6263 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6264 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6265 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006266
6267 /* Controls for GPIO pins, assuming they are configured as outputs */
6268 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6269 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6270 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6271 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6272
Jonathan Woithe92621f12006-02-28 11:47:47 +01006273 /* Switches to allow the digital IO pins to be enabled. The datasheet
6274 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006275 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006276 */
6277 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6278 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6279
Jonathan Woithef8225f62008-01-08 12:16:54 +01006280 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6281 * this output to turn on an external amplifier.
6282 */
6283 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6284 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6285
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006286 { } /* end */
6287};
6288static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006289 /* Enable all GPIOs as outputs with an initial value of 0 */
6290 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6291 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6292 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6293
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006294 /* Enable retasking pins as output, initially without power amp */
6295 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6296 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6299 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6300 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6301
Jonathan Woithe92621f12006-02-28 11:47:47 +01006302 /* Disable digital (SPDIF) pins initially, but users can enable
6303 * them via a mixer switch. In the case of SPDIF-out, this initverb
6304 * payload also sets the generation to 0, output to be in "consumer"
6305 * PCM format, copyright asserted, no pre-emphasis and no validity
6306 * control.
6307 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006308 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6309 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6310
Kailang Yangea1fb292008-08-26 12:58:38 +02006311 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006312 * OUT1 sum bus when acting as an output.
6313 */
6314 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6315 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6316 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6317 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6318
6319 /* Start with output sum widgets muted and their output gains at min */
6320 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6321 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6323 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6324 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6325 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6326 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6327 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6328 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6329
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006330 /* Unmute retasking pin widget output buffers since the default
6331 * state appears to be output. As the pin mode is changed by the
6332 * user the pin mode control will take care of enabling the pin's
6333 * input/output buffers as needed.
6334 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006335 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6336 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6337 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6338 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6339 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6340 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6341 /* Also unmute the mono-out pin widget */
6342 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6343
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006344 /* Mute capture amp left and right */
6345 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006346 /* Set ADC connection select to match default mixer setting (mic1
6347 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006348 */
6349 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6350
6351 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006352 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006353 */
6354 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6355 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6356
6357 /* Mute all inputs to mixer widget (even unconnected ones) */
6358 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6366
6367 { }
6368};
6369#endif
6370
Takashi Iwai63300792008-01-24 15:31:36 +01006371#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6372#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006373
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006374#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6375#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6376
Kailang Yangdf694da2005-12-05 19:42:22 +01006377/*
6378 * for BIOS auto-configuration
6379 */
6380
6381static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006382 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006383{
6384 hda_nid_t nid_vol;
6385 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006386 int err;
6387
6388 if (nid >= 0x0f && nid < 0x11) {
6389 nid_vol = nid - 0x7;
6390 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6391 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6392 } else if (nid == 0x11) {
6393 nid_vol = nid - 0x7;
6394 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6395 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6396 } else if (nid >= 0x12 && nid <= 0x15) {
6397 nid_vol = 0x08;
6398 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6399 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6400 } else
6401 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006402
Takashi Iwai863b4512008-10-21 17:01:47 +02006403 if (!(*vol_bits & (1 << nid_vol))) {
6404 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006405 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006406 if (err < 0)
6407 return err;
6408 *vol_bits |= (1 << nid_vol);
6409 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006410 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006411 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006412 return err;
6413 return 1;
6414}
6415
6416/* add playback controls from the parsed DAC table */
6417static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6418 const struct auto_pin_cfg *cfg)
6419{
6420 hda_nid_t nid;
6421 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006422 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006423
6424 spec->multiout.num_dacs = 1;
6425 spec->multiout.dac_nids = spec->private_dac_nids;
6426 spec->multiout.dac_nids[0] = 0x02;
6427
6428 nid = cfg->line_out_pins[0];
6429 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006430 const char *pfx;
6431 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6432 pfx = "Master";
6433 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6434 pfx = "Speaker";
6435 else
6436 pfx = "Front";
6437 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006438 if (err < 0)
6439 return err;
6440 }
6441
Takashi Iwai82bc9552006-03-21 11:24:42 +01006442 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006443 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006444 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006445 if (err < 0)
6446 return err;
6447 }
6448
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006449 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006450 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006451 err = alc260_add_playback_controls(spec, nid, "Headphone",
6452 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006453 if (err < 0)
6454 return err;
6455 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006456 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006457}
6458
6459/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006460static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006461 const struct auto_pin_cfg *cfg)
6462{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006463 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006464}
6465
6466static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6467 hda_nid_t nid, int pin_type,
6468 int sel_idx)
6469{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006470 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006471 /* need the manual connection? */
6472 if (nid >= 0x12) {
6473 int idx = nid - 0x12;
6474 snd_hda_codec_write(codec, idx + 0x0b, 0,
6475 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006476 }
6477}
6478
6479static void alc260_auto_init_multi_out(struct hda_codec *codec)
6480{
6481 struct alc_spec *spec = codec->spec;
6482 hda_nid_t nid;
6483
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006484 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006485 if (nid) {
6486 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6487 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6488 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006489
Takashi Iwai82bc9552006-03-21 11:24:42 +01006490 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006491 if (nid)
6492 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6493
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006494 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006495 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006496 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006497}
Kailang Yangdf694da2005-12-05 19:42:22 +01006498
6499#define ALC260_PIN_CD_NID 0x16
6500static void alc260_auto_init_analog_input(struct hda_codec *codec)
6501{
6502 struct alc_spec *spec = codec->spec;
6503 int i;
6504
6505 for (i = 0; i < AUTO_PIN_LAST; i++) {
6506 hda_nid_t nid = spec->autocfg.input_pins[i];
6507 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006508 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006509 if (nid != ALC260_PIN_CD_NID &&
6510 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006511 snd_hda_codec_write(codec, nid, 0,
6512 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006513 AMP_OUT_MUTE);
6514 }
6515 }
6516}
6517
Takashi Iwai7f311a42010-04-09 17:32:23 +02006518#define alc260_auto_init_input_src alc880_auto_init_input_src
6519
Kailang Yangdf694da2005-12-05 19:42:22 +01006520/*
6521 * generic initialization of ADC, input mixers and output mixers
6522 */
6523static struct hda_verb alc260_volume_init_verbs[] = {
6524 /*
6525 * Unmute ADC0-1 and set the default input to mic-in
6526 */
6527 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6528 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6529 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6530 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006531
Kailang Yangdf694da2005-12-05 19:42:22 +01006532 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6533 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006534 * Note: PASD motherboards uses the Line In 2 as the input for
6535 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006536 */
6537 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006538 /* mute analog inputs */
6539 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006544
6545 /*
6546 * Set up output mixers (0x08 - 0x0a)
6547 */
6548 /* set vol=0 to output mixers */
6549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6551 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6552 /* set up input amps for analog loopback */
6553 /* Amp Indices: DAC = 0, mixer = 1 */
6554 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6555 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6556 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6557 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6558 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6559 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006560
Kailang Yangdf694da2005-12-05 19:42:22 +01006561 { }
6562};
6563
6564static int alc260_parse_auto_config(struct hda_codec *codec)
6565{
6566 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006567 int err;
6568 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6569
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006570 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6571 alc260_ignore);
6572 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006573 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006574 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6575 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006576 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006577 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006578 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006579 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006580 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006581 return err;
6582
6583 spec->multiout.max_channels = 2;
6584
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006585 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006586 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006587 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006588 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006589
Takashi Iwaid88897e2008-10-31 15:01:37 +01006590 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006591
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006592 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006593 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006594
Kailang Yang6227cdc2010-02-25 08:36:52 +01006595 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006596
Kailang Yangdf694da2005-12-05 19:42:22 +01006597 return 1;
6598}
6599
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006600/* additional initialization for auto-configuration model */
6601static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006602{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006603 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006604 alc260_auto_init_multi_out(codec);
6605 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006606 alc260_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006607 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006608 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006609}
6610
Takashi Iwaicb53c622007-08-10 17:21:45 +02006611#ifdef CONFIG_SND_HDA_POWER_SAVE
6612static struct hda_amp_list alc260_loopbacks[] = {
6613 { 0x07, HDA_INPUT, 0 },
6614 { 0x07, HDA_INPUT, 1 },
6615 { 0x07, HDA_INPUT, 2 },
6616 { 0x07, HDA_INPUT, 3 },
6617 { 0x07, HDA_INPUT, 4 },
6618 { } /* end */
6619};
6620#endif
6621
Kailang Yangdf694da2005-12-05 19:42:22 +01006622/*
6623 * ALC260 configurations
6624 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006625static const char *alc260_models[ALC260_MODEL_LAST] = {
6626 [ALC260_BASIC] = "basic",
6627 [ALC260_HP] = "hp",
6628 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006629 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006630 [ALC260_FUJITSU_S702X] = "fujitsu",
6631 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006632 [ALC260_WILL] = "will",
6633 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006634 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006635#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006636 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006637#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006638 [ALC260_AUTO] = "auto",
6639};
6640
6641static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006642 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006643 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006644 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006645 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006646 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006647 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006648 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006649 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006650 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006651 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6652 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6653 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6654 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6655 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6656 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6657 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6658 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6659 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006660 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006661 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006662 {}
6663};
6664
Kailang Yangdf694da2005-12-05 19:42:22 +01006665static struct alc_config_preset alc260_presets[] = {
6666 [ALC260_BASIC] = {
6667 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006668 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006669 .init_verbs = { alc260_init_verbs },
6670 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6671 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006672 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006673 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006674 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6675 .channel_mode = alc260_modes,
6676 .input_mux = &alc260_capture_source,
6677 },
6678 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006679 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006680 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006681 .init_verbs = { alc260_init_verbs,
6682 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006683 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6684 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006685 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6686 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006687 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6688 .channel_mode = alc260_modes,
6689 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006690 .unsol_event = alc260_hp_unsol_event,
6691 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006692 },
Kailang Yang3f878302008-08-26 13:02:23 +02006693 [ALC260_HP_DC7600] = {
6694 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006695 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006696 .init_verbs = { alc260_init_verbs,
6697 alc260_hp_dc7600_verbs },
6698 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6699 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006700 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6701 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006702 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6703 .channel_mode = alc260_modes,
6704 .input_mux = &alc260_capture_source,
6705 .unsol_event = alc260_hp_3012_unsol_event,
6706 .init_hook = alc260_hp_3012_automute,
6707 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006708 [ALC260_HP_3013] = {
6709 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006710 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006711 .init_verbs = { alc260_hp_3013_init_verbs,
6712 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006713 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6714 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006715 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6716 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006717 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6718 .channel_mode = alc260_modes,
6719 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006720 .unsol_event = alc260_hp_3013_unsol_event,
6721 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006722 },
6723 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006724 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006725 .init_verbs = { alc260_fujitsu_init_verbs },
6726 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6727 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006728 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6729 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006730 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6731 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006732 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6733 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006734 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006735 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006736 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006737 .init_verbs = { alc260_acer_init_verbs },
6738 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6739 .dac_nids = alc260_dac_nids,
6740 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6741 .adc_nids = alc260_dual_adc_nids,
6742 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6743 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006744 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6745 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006746 },
Michael Schwingencc959482009-02-22 18:58:45 +01006747 [ALC260_FAVORIT100] = {
6748 .mixers = { alc260_favorit100_mixer },
6749 .init_verbs = { alc260_favorit100_init_verbs },
6750 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6751 .dac_nids = alc260_dac_nids,
6752 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6753 .adc_nids = alc260_dual_adc_nids,
6754 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6755 .channel_mode = alc260_modes,
6756 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6757 .input_mux = alc260_favorit100_capture_sources,
6758 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006759 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006760 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006761 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6762 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6763 .dac_nids = alc260_dac_nids,
6764 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6765 .adc_nids = alc260_adc_nids,
6766 .dig_out_nid = ALC260_DIGOUT_NID,
6767 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6768 .channel_mode = alc260_modes,
6769 .input_mux = &alc260_capture_source,
6770 },
6771 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006772 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006773 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6774 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6775 .dac_nids = alc260_dac_nids,
6776 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6777 .adc_nids = alc260_adc_nids,
6778 .dig_out_nid = ALC260_DIGOUT_NID,
6779 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6780 .channel_mode = alc260_modes,
6781 .input_mux = &alc260_capture_source,
6782 .unsol_event = alc260_replacer_672v_unsol_event,
6783 .init_hook = alc260_replacer_672v_automute,
6784 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006785#ifdef CONFIG_SND_DEBUG
6786 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006787 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006788 .init_verbs = { alc260_test_init_verbs },
6789 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6790 .dac_nids = alc260_test_dac_nids,
6791 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6792 .adc_nids = alc260_test_adc_nids,
6793 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6794 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006795 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6796 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006797 },
6798#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006799};
6800
Linus Torvalds1da177e2005-04-16 15:20:36 -07006801static int patch_alc260(struct hda_codec *codec)
6802{
6803 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006804 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006805
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006806 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006807 if (spec == NULL)
6808 return -ENOMEM;
6809
6810 codec->spec = spec;
6811
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006812 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6813 alc260_models,
6814 alc260_cfg_tbl);
6815 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006816 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006817 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006818 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006819 }
6820
Kailang Yangdf694da2005-12-05 19:42:22 +01006821 if (board_config == ALC260_AUTO) {
6822 /* automatic parse from the BIOS config */
6823 err = alc260_parse_auto_config(codec);
6824 if (err < 0) {
6825 alc_free(codec);
6826 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006827 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006828 printk(KERN_INFO
6829 "hda_codec: Cannot set up configuration "
6830 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006831 board_config = ALC260_BASIC;
6832 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006833 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006834
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006835 err = snd_hda_attach_beep_device(codec, 0x1);
6836 if (err < 0) {
6837 alc_free(codec);
6838 return err;
6839 }
6840
Kailang Yangdf694da2005-12-05 19:42:22 +01006841 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006842 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006843
Linus Torvalds1da177e2005-04-16 15:20:36 -07006844 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6845 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6846
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006847 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6848 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6849
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006850 if (!spec->adc_nids && spec->input_mux) {
6851 /* check whether NID 0x04 is valid */
6852 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006853 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006854 /* get type */
6855 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6856 spec->adc_nids = alc260_adc_nids_alt;
6857 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6858 } else {
6859 spec->adc_nids = alc260_adc_nids;
6860 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6861 }
6862 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006863 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006864 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006865
Takashi Iwai2134ea42008-01-10 16:53:55 +01006866 spec->vmaster_nid = 0x08;
6867
Linus Torvalds1da177e2005-04-16 15:20:36 -07006868 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006869 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006870 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006871#ifdef CONFIG_SND_HDA_POWER_SAVE
6872 if (!spec->loopback.amplist)
6873 spec->loopback.amplist = alc260_loopbacks;
6874#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006875
6876 return 0;
6877}
6878
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006879
Linus Torvalds1da177e2005-04-16 15:20:36 -07006880/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006881 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006882 *
6883 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6884 * configuration. Each pin widget can choose any input DACs and a mixer.
6885 * Each ADC is connected from a mixer of all inputs. This makes possible
6886 * 6-channel independent captures.
6887 *
6888 * In addition, an independent DAC for the multi-playback (not used in this
6889 * driver yet).
6890 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006891#define ALC882_DIGOUT_NID 0x06
6892#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006893#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6894#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6895#define ALC1200_DIGOUT_NID 0x10
6896
Linus Torvalds1da177e2005-04-16 15:20:36 -07006897
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006898static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006899 { 8, NULL }
6900};
6901
Takashi Iwai4953550a2009-06-30 15:28:30 +02006902/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006903static hda_nid_t alc882_dac_nids[4] = {
6904 /* front, rear, clfe, rear_surr */
6905 0x02, 0x03, 0x04, 0x05
6906};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006907#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006908
Takashi Iwai4953550a2009-06-30 15:28:30 +02006909/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006910#define alc882_adc_nids alc880_adc_nids
6911#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006912#define alc883_adc_nids alc882_adc_nids_alt
6913static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6914static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6915#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006916
Takashi Iwaie1406342008-02-11 18:32:32 +01006917static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6918static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006919#define alc883_capsrc_nids alc882_capsrc_nids_alt
6920static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6921#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006922
Linus Torvalds1da177e2005-04-16 15:20:36 -07006923/* input MUX */
6924/* FIXME: should be a matrix-type input source selection */
6925
6926static struct hda_input_mux alc882_capture_source = {
6927 .num_items = 4,
6928 .items = {
6929 { "Mic", 0x0 },
6930 { "Front Mic", 0x1 },
6931 { "Line", 0x2 },
6932 { "CD", 0x4 },
6933 },
6934};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006935
Takashi Iwai4953550a2009-06-30 15:28:30 +02006936#define alc883_capture_source alc882_capture_source
6937
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006938static struct hda_input_mux alc889_capture_source = {
6939 .num_items = 3,
6940 .items = {
6941 { "Front Mic", 0x0 },
6942 { "Mic", 0x3 },
6943 { "Line", 0x2 },
6944 },
6945};
6946
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006947static struct hda_input_mux mb5_capture_source = {
6948 .num_items = 3,
6949 .items = {
6950 { "Mic", 0x1 },
6951 { "Line", 0x2 },
6952 { "CD", 0x4 },
6953 },
6954};
6955
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006956static struct hda_input_mux macmini3_capture_source = {
6957 .num_items = 2,
6958 .items = {
6959 { "Line", 0x2 },
6960 { "CD", 0x4 },
6961 },
6962};
6963
Takashi Iwai4953550a2009-06-30 15:28:30 +02006964static struct hda_input_mux alc883_3stack_6ch_intel = {
6965 .num_items = 4,
6966 .items = {
6967 { "Mic", 0x1 },
6968 { "Front Mic", 0x0 },
6969 { "Line", 0x2 },
6970 { "CD", 0x4 },
6971 },
6972};
6973
6974static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6975 .num_items = 2,
6976 .items = {
6977 { "Mic", 0x1 },
6978 { "Line", 0x2 },
6979 },
6980};
6981
6982static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6983 .num_items = 4,
6984 .items = {
6985 { "Mic", 0x0 },
6986 { "iMic", 0x1 },
6987 { "Line", 0x2 },
6988 { "CD", 0x4 },
6989 },
6990};
6991
6992static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6993 .num_items = 2,
6994 .items = {
6995 { "Mic", 0x0 },
6996 { "Int Mic", 0x1 },
6997 },
6998};
6999
7000static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7001 .num_items = 3,
7002 .items = {
7003 { "Mic", 0x0 },
7004 { "Front Mic", 0x1 },
7005 { "Line", 0x4 },
7006 },
7007};
7008
7009static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7010 .num_items = 2,
7011 .items = {
7012 { "Mic", 0x0 },
7013 { "Line", 0x2 },
7014 },
7015};
7016
7017static struct hda_input_mux alc889A_mb31_capture_source = {
7018 .num_items = 2,
7019 .items = {
7020 { "Mic", 0x0 },
7021 /* Front Mic (0x01) unused */
7022 { "Line", 0x2 },
7023 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007024 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007025 },
7026};
7027
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007028static struct hda_input_mux alc889A_imac91_capture_source = {
7029 .num_items = 2,
7030 .items = {
7031 { "Mic", 0x01 },
7032 { "Line", 0x2 }, /* Not sure! */
7033 },
7034};
7035
Takashi Iwai4953550a2009-06-30 15:28:30 +02007036/*
7037 * 2ch mode
7038 */
7039static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7040 { 2, NULL }
7041};
7042
Kailang Yangdf694da2005-12-05 19:42:22 +01007043/*
Kailang Yang272a5272007-05-14 11:00:38 +02007044 * 2ch mode
7045 */
7046static struct hda_verb alc882_3ST_ch2_init[] = {
7047 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7048 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7049 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7050 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7051 { } /* end */
7052};
7053
7054/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007055 * 4ch mode
7056 */
7057static struct hda_verb alc882_3ST_ch4_init[] = {
7058 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7059 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7060 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7061 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7062 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7063 { } /* end */
7064};
7065
7066/*
Kailang Yang272a5272007-05-14 11:00:38 +02007067 * 6ch mode
7068 */
7069static struct hda_verb alc882_3ST_ch6_init[] = {
7070 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7071 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7072 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7073 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7074 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7075 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7076 { } /* end */
7077};
7078
Takashi Iwai4953550a2009-06-30 15:28:30 +02007079static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007080 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007081 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007082 { 6, alc882_3ST_ch6_init },
7083};
7084
Takashi Iwai4953550a2009-06-30 15:28:30 +02007085#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7086
Kailang Yang272a5272007-05-14 11:00:38 +02007087/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307088 * 2ch mode
7089 */
7090static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7091 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7092 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7093 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7094 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7095 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7096 { } /* end */
7097};
7098
7099/*
7100 * 4ch mode
7101 */
7102static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7103 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7104 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7105 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7106 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7107 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7108 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7109 { } /* end */
7110};
7111
7112/*
7113 * 6ch mode
7114 */
7115static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7116 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7117 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7118 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7119 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7120 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7121 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7122 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7123 { } /* end */
7124};
7125
7126static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7127 { 2, alc883_3ST_ch2_clevo_init },
7128 { 4, alc883_3ST_ch4_clevo_init },
7129 { 6, alc883_3ST_ch6_clevo_init },
7130};
7131
7132
7133/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007134 * 6ch mode
7135 */
7136static struct hda_verb alc882_sixstack_ch6_init[] = {
7137 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7138 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7139 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7140 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7141 { } /* end */
7142};
7143
7144/*
7145 * 8ch mode
7146 */
7147static struct hda_verb alc882_sixstack_ch8_init[] = {
7148 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7149 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7150 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7151 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7152 { } /* end */
7153};
7154
7155static struct hda_channel_mode alc882_sixstack_modes[2] = {
7156 { 6, alc882_sixstack_ch6_init },
7157 { 8, alc882_sixstack_ch8_init },
7158};
7159
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007160
7161/* Macbook Air 2,1 */
7162
7163static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7164 { 2, NULL },
7165};
7166
Takashi Iwai87350ad2007-08-16 18:19:38 +02007167/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007168 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007169 */
7170
7171/*
7172 * 2ch mode
7173 */
7174static struct hda_verb alc885_mbp_ch2_init[] = {
7175 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7176 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7177 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7178 { } /* end */
7179};
7180
7181/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007182 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007183 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007184static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007185 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7186 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7187 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7188 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7189 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7190 { } /* end */
7191};
7192
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007193static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007194 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007195 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007196};
7197
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007198/*
7199 * 2ch
7200 * Speakers/Woofer/HP = Front
7201 * LineIn = Input
7202 */
7203static struct hda_verb alc885_mb5_ch2_init[] = {
7204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7205 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7206 { } /* end */
7207};
7208
7209/*
7210 * 6ch mode
7211 * Speakers/HP = Front
7212 * Woofer = LFE
7213 * LineIn = Surround
7214 */
7215static struct hda_verb alc885_mb5_ch6_init[] = {
7216 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7217 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7218 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7219 { } /* end */
7220};
7221
7222static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7223 { 2, alc885_mb5_ch2_init },
7224 { 6, alc885_mb5_ch6_init },
7225};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007226
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007227#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007228
7229/*
7230 * 2ch mode
7231 */
7232static struct hda_verb alc883_4ST_ch2_init[] = {
7233 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7234 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7235 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7236 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7237 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7238 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7239 { } /* end */
7240};
7241
7242/*
7243 * 4ch mode
7244 */
7245static struct hda_verb alc883_4ST_ch4_init[] = {
7246 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7247 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7248 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7249 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7250 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7251 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7252 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7253 { } /* end */
7254};
7255
7256/*
7257 * 6ch mode
7258 */
7259static struct hda_verb alc883_4ST_ch6_init[] = {
7260 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7261 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7262 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7263 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7264 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7265 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7266 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7267 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7268 { } /* end */
7269};
7270
7271/*
7272 * 8ch mode
7273 */
7274static struct hda_verb alc883_4ST_ch8_init[] = {
7275 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7276 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7277 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7278 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7279 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7280 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7281 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7282 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7283 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7284 { } /* end */
7285};
7286
7287static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7288 { 2, alc883_4ST_ch2_init },
7289 { 4, alc883_4ST_ch4_init },
7290 { 6, alc883_4ST_ch6_init },
7291 { 8, alc883_4ST_ch8_init },
7292};
7293
7294
7295/*
7296 * 2ch mode
7297 */
7298static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7299 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7300 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7301 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7302 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7303 { } /* end */
7304};
7305
7306/*
7307 * 4ch mode
7308 */
7309static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7310 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7311 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7312 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7313 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7314 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7315 { } /* end */
7316};
7317
7318/*
7319 * 6ch mode
7320 */
7321static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7322 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7323 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7324 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7325 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7326 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7327 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7328 { } /* end */
7329};
7330
7331static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7332 { 2, alc883_3ST_ch2_intel_init },
7333 { 4, alc883_3ST_ch4_intel_init },
7334 { 6, alc883_3ST_ch6_intel_init },
7335};
7336
7337/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007338 * 2ch mode
7339 */
7340static struct hda_verb alc889_ch2_intel_init[] = {
7341 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7342 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7343 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7344 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7345 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7346 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7347 { } /* end */
7348};
7349
7350/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007351 * 6ch mode
7352 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007353static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007354 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7355 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7356 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7357 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7358 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007359 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7360 { } /* end */
7361};
7362
7363/*
7364 * 8ch mode
7365 */
7366static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007367 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7368 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7369 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7370 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7371 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007372 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7373 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007374 { } /* end */
7375};
7376
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007377static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7378 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007379 { 6, alc889_ch6_intel_init },
7380 { 8, alc889_ch8_intel_init },
7381};
7382
7383/*
7384 * 6ch mode
7385 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007386static struct hda_verb alc883_sixstack_ch6_init[] = {
7387 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7388 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7389 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7390 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7391 { } /* end */
7392};
7393
7394/*
7395 * 8ch mode
7396 */
7397static struct hda_verb alc883_sixstack_ch8_init[] = {
7398 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7399 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7400 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7401 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7402 { } /* end */
7403};
7404
7405static struct hda_channel_mode alc883_sixstack_modes[2] = {
7406 { 6, alc883_sixstack_ch6_init },
7407 { 8, alc883_sixstack_ch8_init },
7408};
7409
7410
Linus Torvalds1da177e2005-04-16 15:20:36 -07007411/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7412 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7413 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007414static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007415 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007416 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007417 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007418 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007419 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7420 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007421 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7422 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007423 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007424 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007431 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007434 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007435 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007436 { } /* end */
7437};
7438
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007439/* Macbook Air 2,1 same control for HP and internal Speaker */
7440
7441static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7442 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7443 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7444 { }
7445};
7446
7447
Takashi Iwai87350ad2007-08-16 18:19:38 +02007448static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007449 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7450 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7451 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7452 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7453 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007454 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7455 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7457 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007458 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007459 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7460 { } /* end */
7461};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007462
7463static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007464 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7465 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7466 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7467 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7468 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7469 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307470 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7471 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007472 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7473 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7475 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7476 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7477 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7478 { } /* end */
7479};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007480
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007481static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7482 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7483 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7484 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7485 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7486 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7487 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7488 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7489 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7490 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7491 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7492 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7493 { } /* end */
7494};
7495
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007496static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007497 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7498 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007499 { } /* end */
7500};
7501
7502
Kailang Yangbdd148a2007-05-08 15:19:08 +02007503static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7504 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7505 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7506 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7507 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7508 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7509 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7510 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7511 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7512 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007513 { } /* end */
7514};
7515
Kailang Yang272a5272007-05-14 11:00:38 +02007516static struct snd_kcontrol_new alc882_targa_mixer[] = {
7517 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7518 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7519 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7520 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7521 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7522 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7523 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7525 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007526 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007527 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7528 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007529 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007530 { } /* end */
7531};
7532
7533/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7534 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7535 */
7536static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7537 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7538 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7539 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7540 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7541 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7542 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7543 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7544 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7545 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7546 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7547 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7548 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007549 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007550 { } /* end */
7551};
7552
Takashi Iwai914759b2007-09-06 14:52:04 +02007553static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7554 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7555 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7556 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7557 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7558 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7559 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7560 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7561 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7562 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7563 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007564 { } /* end */
7565};
7566
Kailang Yangdf694da2005-12-05 19:42:22 +01007567static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7568 {
7569 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7570 .name = "Channel Mode",
7571 .info = alc_ch_mode_info,
7572 .get = alc_ch_mode_get,
7573 .put = alc_ch_mode_put,
7574 },
7575 { } /* end */
7576};
7577
Takashi Iwai4953550a2009-06-30 15:28:30 +02007578static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007579 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007580 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7581 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007582 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007585 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007588 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007589 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007591
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007592 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007593 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007594 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007595 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007596 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007599 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007600 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007601 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007602 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007603 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007604 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007605 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007606 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007607 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007608 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007609 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7611 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007612 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007613 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7614 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007615 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007616 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7617 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7618 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7619 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7620 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007621 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007622 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007623
7624 /* FIXME: use matrix-type input source selection */
7625 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007626 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007627 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007628 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007630 /* ADC2: mute amp left and right */
7631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007632 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007633 /* ADC3: mute amp left and right */
7634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007635 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007636
7637 { }
7638};
7639
Takashi Iwai4953550a2009-06-30 15:28:30 +02007640static struct hda_verb alc882_adc1_init_verbs[] = {
7641 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7642 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7643 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7644 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7645 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7646 /* ADC1: mute amp left and right */
7647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7648 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7649 { }
7650};
7651
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007652static struct hda_verb alc882_eapd_verbs[] = {
7653 /* change to EAPD mode */
7654 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007655 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007656 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007657};
7658
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007659static struct hda_verb alc889_eapd_verbs[] = {
7660 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7661 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7662 { }
7663};
7664
Wu Fengguang6732bd02009-07-30 09:19:14 +02007665static struct hda_verb alc_hp15_unsol_verbs[] = {
7666 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7668 {}
7669};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007670
7671static struct hda_verb alc885_init_verbs[] = {
7672 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7674 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007675 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007676 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7677 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007678 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007679 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7680 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007681 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007682 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7683 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007684
7685 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007686 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7688 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7689 /* Front Pin: output 0 (0x0c) */
7690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7692 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7693 /* Rear Pin: output 1 (0x0d) */
7694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7695 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7696 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7697 /* CLFE Pin: output 2 (0x0e) */
7698 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7699 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7700 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7701 /* Side Pin: output 3 (0x0f) */
7702 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7703 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7704 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7705 /* Mic (rear) pin: input vref at 80% */
7706 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7707 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7708 /* Front Mic pin: input vref at 80% */
7709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7710 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7711 /* Line In pin: input */
7712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7714
7715 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7716 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007717 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007718 /* Input mixer2 */
7719 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007720 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007721 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007722 /* ADC2: mute amp left and right */
7723 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7724 /* ADC3: mute amp left and right */
7725 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7726
7727 { }
7728};
7729
7730static struct hda_verb alc885_init_input_verbs[] = {
7731 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7732 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7734 { }
7735};
7736
7737
7738/* Unmute Selector 24h and set the default input to front mic */
7739static struct hda_verb alc889_init_input_verbs[] = {
7740 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7742 { }
7743};
7744
7745
Takashi Iwai4953550a2009-06-30 15:28:30 +02007746#define alc883_init_verbs alc882_base_init_verbs
7747
Tobin Davis9102cd12006-12-15 10:02:12 +01007748/* Mac Pro test */
7749static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7751 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7753 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7754 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007755 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007756 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7757 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007758 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007759 { } /* end */
7760};
7761
7762static struct hda_verb alc882_macpro_init_verbs[] = {
7763 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7767 /* Front Pin: output 0 (0x0c) */
7768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7770 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7771 /* Front Mic pin: input vref at 80% */
7772 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7773 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7774 /* Speaker: output */
7775 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7776 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7777 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7778 /* Headphone output (output 0 - 0x0c) */
7779 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7780 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7781 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7782
7783 /* FIXME: use matrix-type input source selection */
7784 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7785 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7786 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7787 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7790 /* Input mixer2 */
7791 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7792 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7793 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7794 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7795 /* Input mixer3 */
7796 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7797 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7798 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7799 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7800 /* ADC1: mute amp left and right */
7801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7802 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7803 /* ADC2: mute amp left and right */
7804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7805 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7806 /* ADC3: mute amp left and right */
7807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7808 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7809
7810 { }
7811};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007812
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007813/* Macbook 5,1 */
7814static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007815 /* DACs */
7816 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7817 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7818 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7819 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007820 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007824 /* Surround mixer */
7825 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7826 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7827 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7828 /* LFE mixer */
7829 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7830 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7831 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7832 /* HP mixer */
7833 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7834 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7835 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7836 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7838 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007839 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7840 /* LFE Pin (0x0e) */
7841 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7843 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7844 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007847 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307848 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007849 /* Front Mic pin: input vref at 80% */
7850 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7851 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7852 /* Line In pin */
7853 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7855
7856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7860 { }
7861};
7862
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007863/* Macmini 3,1 */
7864static struct hda_verb alc885_macmini3_init_verbs[] = {
7865 /* DACs */
7866 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7867 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7868 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7869 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7870 /* Front mixer */
7871 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7872 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7873 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7874 /* Surround mixer */
7875 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7876 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7877 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7878 /* LFE mixer */
7879 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7880 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7881 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7882 /* HP mixer */
7883 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7884 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7885 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7886 /* Front Pin (0x0c) */
7887 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7888 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7889 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7890 /* LFE Pin (0x0e) */
7891 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7892 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7893 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7894 /* HP Pin (0x0f) */
7895 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7896 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7897 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7898 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7899 /* Line In pin */
7900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7902
7903 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7904 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7905 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7906 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7907 { }
7908};
7909
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007910
7911static struct hda_verb alc885_mba21_init_verbs[] = {
7912 /*Internal and HP Speaker Mixer*/
7913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7916 /*Internal Speaker Pin (0x0c)*/
7917 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7918 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7919 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7920 /* HP Pin: output 0 (0x0e) */
7921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7922 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7923 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7924 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7925 /* Line in (is hp when jack connected)*/
7926 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7927 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7928
7929 { }
7930 };
7931
7932
Takashi Iwai87350ad2007-08-16 18:19:38 +02007933/* Macbook Pro rev3 */
7934static struct hda_verb alc885_mbp3_init_verbs[] = {
7935 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7936 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7937 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7938 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7939 /* Rear mixer */
7940 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7941 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007943 /* HP mixer */
7944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7946 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007947 /* Front Pin: output 0 (0x0c) */
7948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7950 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007951 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007953 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7954 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007955 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7956 /* Mic (rear) pin: input vref at 80% */
7957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7959 /* Front Mic pin: input vref at 80% */
7960 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7961 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7962 /* Line In pin: use output 1 when in LineOut mode */
7963 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7964 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7965 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7966
7967 /* FIXME: use matrix-type input source selection */
7968 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7969 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7971 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7972 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7974 /* Input mixer2 */
7975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7979 /* Input mixer3 */
7980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7984 /* ADC1: mute amp left and right */
7985 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7986 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7987 /* ADC2: mute amp left and right */
7988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7989 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7990 /* ADC3: mute amp left and right */
7991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7992 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7993
7994 { }
7995};
7996
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007997/* iMac 9,1 */
7998static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007999 /* Internal Speaker Pin (0x0c) */
8000 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8002 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8003 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8004 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8005 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8006 /* HP Pin: Rear */
8007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8009 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8010 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8011 /* Line in Rear */
8012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8014 /* Front Mic pin: input vref at 80% */
8015 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8016 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008017 /* Rear mixer */
8018 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8019 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8020 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008021 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8024 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8025 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008030 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8034 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008035 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008040 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008041 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8042 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008043 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008044 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8045 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008046 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008047 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8048 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008049 { }
8050};
8051
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008052/* iMac 24 mixer. */
8053static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8054 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8055 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8056 { } /* end */
8057};
8058
8059/* iMac 24 init verbs. */
8060static struct hda_verb alc885_imac24_init_verbs[] = {
8061 /* Internal speakers: output 0 (0x0c) */
8062 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8063 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8064 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8065 /* Internal speakers: output 0 (0x0c) */
8066 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8067 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8068 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8069 /* Headphone: output 0 (0x0c) */
8070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8071 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8072 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8073 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8074 /* Front Mic: input vref at 80% */
8075 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8077 { }
8078};
8079
8080/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008081static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008082{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008083 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008084
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008085 spec->autocfg.hp_pins[0] = 0x14;
8086 spec->autocfg.speaker_pins[0] = 0x18;
8087 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008088}
8089
Takashi Iwai9d54f082010-02-22 08:34:40 +01008090#define alc885_mb5_setup alc885_imac24_setup
8091#define alc885_macmini3_setup alc885_imac24_setup
8092
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008093/* Macbook Air 2,1 */
8094static void alc885_mba21_setup(struct hda_codec *codec)
8095{
8096 struct alc_spec *spec = codec->spec;
8097
8098 spec->autocfg.hp_pins[0] = 0x14;
8099 spec->autocfg.speaker_pins[0] = 0x18;
8100}
8101
8102
8103
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008104static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008105{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008106 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008107
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008108 spec->autocfg.hp_pins[0] = 0x15;
8109 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008110}
8111
Takashi Iwai9d54f082010-02-22 08:34:40 +01008112static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308113{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008114 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308115
Takashi Iwai9d54f082010-02-22 08:34:40 +01008116 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008117 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008118 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008119}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008120
Kailang Yang272a5272007-05-14 11:00:38 +02008121static struct hda_verb alc882_targa_verbs[] = {
8122 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8123 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8124
8125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8126 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008127
Kailang Yang272a5272007-05-14 11:00:38 +02008128 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8129 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8130 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8131
8132 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008133 { } /* end */
8134};
8135
8136/* toggle speaker-output according to the hp-jack state */
8137static void alc882_targa_automute(struct hda_codec *codec)
8138{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008139 struct alc_spec *spec = codec->spec;
8140 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008141 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008142 spec->jack_present ? 1 : 3);
8143}
8144
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008145static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008146{
8147 struct alc_spec *spec = codec->spec;
8148
8149 spec->autocfg.hp_pins[0] = 0x14;
8150 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008151}
8152
8153static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8154{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008155 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008156 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008157}
8158
8159static struct hda_verb alc882_asus_a7j_verbs[] = {
8160 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8162
8163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8165 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008166
Kailang Yang272a5272007-05-14 11:00:38 +02008167 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8168 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8169 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8170
8171 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8172 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8173 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8174 { } /* end */
8175};
8176
Takashi Iwai914759b2007-09-06 14:52:04 +02008177static struct hda_verb alc882_asus_a7m_verbs[] = {
8178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8180
8181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008184
Takashi Iwai914759b2007-09-06 14:52:04 +02008185 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8187 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8188
8189 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8190 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8191 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8192 { } /* end */
8193};
8194
Tobin Davis9102cd12006-12-15 10:02:12 +01008195static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8196{
8197 unsigned int gpiostate, gpiomask, gpiodir;
8198
8199 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8200 AC_VERB_GET_GPIO_DATA, 0);
8201
8202 if (!muted)
8203 gpiostate |= (1 << pin);
8204 else
8205 gpiostate &= ~(1 << pin);
8206
8207 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8208 AC_VERB_GET_GPIO_MASK, 0);
8209 gpiomask |= (1 << pin);
8210
8211 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8212 AC_VERB_GET_GPIO_DIRECTION, 0);
8213 gpiodir |= (1 << pin);
8214
8215
8216 snd_hda_codec_write(codec, codec->afg, 0,
8217 AC_VERB_SET_GPIO_MASK, gpiomask);
8218 snd_hda_codec_write(codec, codec->afg, 0,
8219 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8220
8221 msleep(1);
8222
8223 snd_hda_codec_write(codec, codec->afg, 0,
8224 AC_VERB_SET_GPIO_DATA, gpiostate);
8225}
8226
Takashi Iwai7debbe52007-08-16 15:01:03 +02008227/* set up GPIO at initialization */
8228static void alc885_macpro_init_hook(struct hda_codec *codec)
8229{
8230 alc882_gpio_mute(codec, 0, 0);
8231 alc882_gpio_mute(codec, 1, 0);
8232}
8233
8234/* set up GPIO and update auto-muting at initialization */
8235static void alc885_imac24_init_hook(struct hda_codec *codec)
8236{
8237 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008238 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008239}
8240
Kailang Yangdf694da2005-12-05 19:42:22 +01008241/*
8242 * generic initialization of ADC, input mixers and output mixers
8243 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008244static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008245 /*
8246 * Unmute ADC0-2 and set the default input to mic-in
8247 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008248 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8249 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8250 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252
Kailang Yangdf694da2005-12-05 19:42:22 +01008253 /*
8254 * Set up output mixers (0x0c - 0x0f)
8255 */
8256 /* set vol=0 to output mixers */
8257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8258 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8260 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8261 /* set up input amps for analog loopback */
8262 /* Amp Indices: DAC = 0, mixer = 1 */
8263 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8265 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8266 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8267 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8269 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8270 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8271 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8272 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8273
8274 /* FIXME: use matrix-type input source selection */
8275 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008276 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008278 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008280 { }
8281};
8282
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008283/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8284static struct hda_verb alc889A_mb31_ch2_init[] = {
8285 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8286 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8289 { } /* end */
8290};
8291
8292/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8293static struct hda_verb alc889A_mb31_ch4_init[] = {
8294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8295 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8296 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8297 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8298 { } /* end */
8299};
8300
8301/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8302static struct hda_verb alc889A_mb31_ch5_init[] = {
8303 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8304 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8307 { } /* end */
8308};
8309
8310/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8311static struct hda_verb alc889A_mb31_ch6_init[] = {
8312 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8313 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8314 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8316 { } /* end */
8317};
8318
8319static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8320 { 2, alc889A_mb31_ch2_init },
8321 { 4, alc889A_mb31_ch4_init },
8322 { 5, alc889A_mb31_ch5_init },
8323 { 6, alc889A_mb31_ch6_init },
8324};
8325
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008326static struct hda_verb alc883_medion_eapd_verbs[] = {
8327 /* eanable EAPD on medion laptop */
8328 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8329 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8330 { }
8331};
8332
Takashi Iwai4953550a2009-06-30 15:28:30 +02008333#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008334
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008335static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8336 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8337 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8338 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8339 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8340 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8341 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8342 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8344 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8346 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8347 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008349 { } /* end */
8350};
8351
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008352static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008353 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8354 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8355 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8356 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8358 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8360 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8361 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8362 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008363 { } /* end */
8364};
8365
Jiang zhefb97dc62008-03-06 11:07:11 +01008366static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8367 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8368 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8369 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8370 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8372 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8373 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8374 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8375 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8376 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008377 { } /* end */
8378};
8379
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008380static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8381 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8382 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8384 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8385 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8386 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8387 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008389 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8391 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008392 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008393 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008394 { } /* end */
8395};
8396
8397static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8398 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8399 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8400 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8401 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8402 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8403 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8404 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8405 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8406 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8409 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8410 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008412 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008413 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8414 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008415 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008416 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008417 { } /* end */
8418};
8419
Jiang zhe17bba1b2008-06-04 12:11:07 +02008420static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8421 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8422 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8423 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8424 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8425 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8426 HDA_OUTPUT),
8427 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8428 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8429 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8430 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8431 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8432 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8433 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8434 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8436 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8437 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8438 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8439 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8440 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008441 { } /* end */
8442};
8443
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008444static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8445 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8446 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8448 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8450 HDA_OUTPUT),
8451 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8452 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8453 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8454 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8455 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8457 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8458 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8460 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8462 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8463 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8464 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8465 { } /* end */
8466};
8467
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008468static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008470 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008471 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008472 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8474 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008475 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8476 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008477 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8478 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8479 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8480 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8481 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8482 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008483 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8485 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008486 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008487 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008488 { } /* end */
8489};
8490
Sasha Alexandrc2592492009-06-16 14:52:54 -04008491static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008492 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008493 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008494 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008495 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008496 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8497 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8498 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8499 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8500 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8501 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8502 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8503 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008507 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008508 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008509 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008510};
Kailang Yangccc656c2006-10-17 12:32:26 +02008511
Sasha Alexandrc2592492009-06-16 14:52:54 -04008512static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008513 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008514 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008516 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008517 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8518 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8519 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008520 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008521 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008522 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8523 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8524 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008525 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008526};
Kailang Yangccc656c2006-10-17 12:32:26 +02008527
Takashi Iwaib99dba32009-09-17 18:23:00 +02008528static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8529 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8530 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8531 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8532 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8533 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8534 { } /* end */
8535};
8536
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008537static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8538 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8539 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008540 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8541 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008542 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8543 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8544 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008546 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008547};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008548
Kailang Yang272a5272007-05-14 11:00:38 +02008549static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8550 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8551 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8553 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8554 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8557 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8558 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008559 { } /* end */
8560};
8561
8562static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8563 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8565 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8566 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8567 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8568 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8569 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8570 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8571 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008572 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008573};
Kailang Yang272a5272007-05-14 11:00:38 +02008574
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008575static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8576 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8577 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8578 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8579 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8580 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8581 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8582 { } /* end */
8583};
8584
8585static struct hda_verb alc883_medion_wim2160_verbs[] = {
8586 /* Unmute front mixer */
8587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8589
8590 /* Set speaker pin to front mixer */
8591 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8592
8593 /* Init headphone pin */
8594 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8595 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8596 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8597 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8598
8599 { } /* end */
8600};
8601
8602/* toggle speaker-output according to the hp-jack state */
8603static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8604{
8605 struct alc_spec *spec = codec->spec;
8606
8607 spec->autocfg.hp_pins[0] = 0x1a;
8608 spec->autocfg.speaker_pins[0] = 0x15;
8609}
8610
Tobin Davis2880a862007-08-07 11:50:26 +02008611static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008612 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8613 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008614 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008615 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8616 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8618 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008620 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008621};
Tobin Davis2880a862007-08-07 11:50:26 +02008622
Tony Vroond2fd4b02009-06-21 00:40:10 +01008623static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008625 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008626 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8627 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008628 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8629 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8631 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8633 { } /* end */
8634};
8635
Kailang Yange2757d52008-08-26 13:17:46 +02008636static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8637 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8638 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8639 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8640 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8641 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8642 0x0d, 1, 0x0, HDA_OUTPUT),
8643 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8644 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8645 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8646 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8647 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008648 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8649 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8650 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8651 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8653 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8654 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8655 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8656 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8657 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008658 { } /* end */
8659};
8660
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008661static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8662 /* Output mixers */
8663 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8664 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8665 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8666 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8667 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8668 HDA_OUTPUT),
8669 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8670 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8671 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8672 /* Output switches */
8673 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8674 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8675 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8676 /* Boost mixers */
8677 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8678 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8679 /* Input mixers */
8680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8682 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8683 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8684 { } /* end */
8685};
8686
Guido Günther3e1647c2009-06-05 00:47:26 +02008687static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8688 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8689 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8690 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8692 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8694 { } /* end */
8695};
8696
Kailang Yange2757d52008-08-26 13:17:46 +02008697static struct hda_bind_ctls alc883_bind_cap_vol = {
8698 .ops = &snd_hda_bind_vol,
8699 .values = {
8700 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8701 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8702 0
8703 },
8704};
8705
8706static struct hda_bind_ctls alc883_bind_cap_switch = {
8707 .ops = &snd_hda_bind_sw,
8708 .values = {
8709 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8710 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8711 0
8712 },
8713};
8714
8715static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8716 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8717 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8719 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8720 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8722 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008724 { } /* end */
8725};
8726
8727static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008728 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8729 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8730 {
8731 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8732 /* .name = "Capture Source", */
8733 .name = "Input Source",
8734 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008735 .info = alc_mux_enum_info,
8736 .get = alc_mux_enum_get,
8737 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008738 },
8739 { } /* end */
8740};
8741
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008742static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8743 {
8744 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8745 .name = "Channel Mode",
8746 .info = alc_ch_mode_info,
8747 .get = alc_ch_mode_get,
8748 .put = alc_ch_mode_put,
8749 },
8750 { } /* end */
8751};
8752
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008753/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008754static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008755{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008756 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008757
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008758 spec->autocfg.hp_pins[0] = 0x15;
8759 spec->autocfg.speaker_pins[0] = 0x14;
8760 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008761}
8762
8763/* auto-toggle front mic */
8764/*
8765static void alc883_mitac_mic_automute(struct hda_codec *codec)
8766{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008767 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008768
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008769 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8770}
8771*/
8772
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008773static struct hda_verb alc883_mitac_verbs[] = {
8774 /* HP */
8775 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8776 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8777 /* Subwoofer */
8778 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8779 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8780
8781 /* enable unsolicited event */
8782 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8783 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8784
8785 { } /* end */
8786};
8787
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308788static struct hda_verb alc883_clevo_m540r_verbs[] = {
8789 /* HP */
8790 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8792 /* Int speaker */
8793 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8794
8795 /* enable unsolicited event */
8796 /*
8797 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8798 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8799 */
8800
8801 { } /* end */
8802};
8803
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008804static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008805 /* HP */
8806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8808 /* Int speaker */
8809 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8811
8812 /* enable unsolicited event */
8813 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008814 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008815
8816 { } /* end */
8817};
8818
Jiang zhefb97dc62008-03-06 11:07:11 +01008819static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8820 /* HP */
8821 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8823 /* Subwoofer */
8824 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8826
8827 /* enable unsolicited event */
8828 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8829
8830 { } /* end */
8831};
8832
Sasha Alexandrc2592492009-06-16 14:52:54 -04008833static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8835 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8836
8837 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8838 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008839
David Heidelberger64a8be72009-06-08 16:15:18 +02008840/* Connect Line-Out side jack (SPDIF) to Side */
8841 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8842 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8843 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8844/* Connect Mic jack to CLFE */
8845 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8846 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8847 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8848/* Connect Line-in jack to Surround */
8849 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8850 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8851 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8852/* Connect HP out jack to Front */
8853 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8854 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8855 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008856
8857 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008858
8859 { } /* end */
8860};
8861
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008862static struct hda_verb alc883_lenovo_101e_verbs[] = {
8863 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8864 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8865 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8866 { } /* end */
8867};
8868
Kailang Yang272a5272007-05-14 11:00:38 +02008869static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8870 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8871 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8872 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8874 { } /* end */
8875};
8876
8877static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8878 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8879 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8880 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8881 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8882 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8883 { } /* end */
8884};
8885
Kailang Yang189609a2007-08-20 11:31:23 +02008886static struct hda_verb alc883_haier_w66_verbs[] = {
8887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8889
8890 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8891
8892 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8894 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8895 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8896 { } /* end */
8897};
8898
Kailang Yange2757d52008-08-26 13:17:46 +02008899static struct hda_verb alc888_lenovo_sky_verbs[] = {
8900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8904 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8905 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8906 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8907 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8908 { } /* end */
8909};
8910
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008911static struct hda_verb alc888_6st_dell_verbs[] = {
8912 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8913 { }
8914};
8915
Guido Günther3e1647c2009-06-05 00:47:26 +02008916static struct hda_verb alc883_vaiott_verbs[] = {
8917 /* HP */
8918 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8920
8921 /* enable unsolicited event */
8922 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8923
8924 { } /* end */
8925};
8926
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008927static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008928{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008929 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008930
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008931 spec->autocfg.hp_pins[0] = 0x1b;
8932 spec->autocfg.speaker_pins[0] = 0x14;
8933 spec->autocfg.speaker_pins[1] = 0x16;
8934 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008935}
8936
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008937static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008938 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008939 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8940 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008942 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008943};
8944
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008945/*
8946 * 2ch mode
8947 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008948static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008949 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8951 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8952 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008953 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008954};
8955
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008956/*
8957 * 4ch mode
8958 */
8959static struct hda_verb alc888_3st_hp_4ch_init[] = {
8960 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8961 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8962 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8963 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8964 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8965 { } /* end */
8966};
8967
8968/*
8969 * 6ch mode
8970 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008971static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008972 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8973 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008974 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008975 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8976 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008977 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8978 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008979};
8980
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008981static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008982 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008983 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008984 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008985};
8986
Kailang Yang272a5272007-05-14 11:00:38 +02008987/* toggle front-jack and RCA according to the hp-jack state */
8988static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8989{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008990 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008991
Takashi Iwai47fd8302007-08-10 17:11:07 +02008992 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8993 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8994 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8995 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008996}
8997
8998/* toggle RCA according to the front-jack state */
8999static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9000{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009001 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009002
Takashi Iwai47fd8302007-08-10 17:11:07 +02009003 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9004 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009005}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009006
Kailang Yang272a5272007-05-14 11:00:38 +02009007static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9008 unsigned int res)
9009{
9010 if ((res >> 26) == ALC880_HP_EVENT)
9011 alc888_lenovo_ms7195_front_automute(codec);
9012 if ((res >> 26) == ALC880_FRONT_EVENT)
9013 alc888_lenovo_ms7195_rca_automute(codec);
9014}
9015
9016static struct hda_verb alc883_medion_md2_verbs[] = {
9017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9019
9020 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9021
9022 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9023 { } /* end */
9024};
9025
9026/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009027static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009028{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009029 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009030
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009031 spec->autocfg.hp_pins[0] = 0x14;
9032 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009033}
9034
Kailang Yangccc656c2006-10-17 12:32:26 +02009035/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009036#define alc883_targa_init_hook alc882_targa_init_hook
9037#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009038
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009039static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9040{
9041 unsigned int present;
9042
Takashi Iwaid56757a2009-11-18 08:00:14 +01009043 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009044 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9045 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9046}
9047
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009048static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009049{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009050 struct alc_spec *spec = codec->spec;
9051
9052 spec->autocfg.hp_pins[0] = 0x15;
9053 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009054}
9055
9056static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9057{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009058 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009059 alc883_clevo_m720_mic_automute(codec);
9060}
9061
9062static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009063 unsigned int res)
9064{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009065 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009066 case ALC880_MIC_EVENT:
9067 alc883_clevo_m720_mic_automute(codec);
9068 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009069 default:
9070 alc_automute_amp_unsol_event(codec, res);
9071 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009072 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009073}
9074
Jiang zhefb97dc62008-03-06 11:07:11 +01009075/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009076static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009077{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009078 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009079
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009080 spec->autocfg.hp_pins[0] = 0x14;
9081 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009082}
9083
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009084static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009085{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009086 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009087
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009088 spec->autocfg.hp_pins[0] = 0x1b;
9089 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009090}
9091
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009092static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9093{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009094 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009095
Takashi Iwai47fd8302007-08-10 17:11:07 +02009096 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9097 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009098}
9099
9100static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9101{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009102 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009103
Takashi Iwai47fd8302007-08-10 17:11:07 +02009104 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9105 HDA_AMP_MUTE, bits);
9106 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9107 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009108}
9109
9110static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9111 unsigned int res)
9112{
9113 if ((res >> 26) == ALC880_HP_EVENT)
9114 alc883_lenovo_101e_all_automute(codec);
9115 if ((res >> 26) == ALC880_FRONT_EVENT)
9116 alc883_lenovo_101e_ispeaker_automute(codec);
9117}
9118
Takashi Iwai676a9b52007-08-16 15:23:35 +02009119/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009120static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009121{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009122 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009123
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009124 spec->autocfg.hp_pins[0] = 0x14;
9125 spec->autocfg.speaker_pins[0] = 0x15;
9126 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009127}
9128
Kailang Yangd1a991a2007-08-15 16:21:59 +02009129static struct hda_verb alc883_acer_eapd_verbs[] = {
9130 /* HP Pin: output 0 (0x0c) */
9131 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9132 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9133 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9134 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9136 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009137 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009138 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9139 /* eanable EAPD on medion laptop */
9140 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9141 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009142 /* enable unsolicited event */
9143 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009144 { }
9145};
9146
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009147static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9148 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9149 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9150 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9151 { } /* end */
9152};
9153
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009154static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009155{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009156 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009157
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009158 spec->autocfg.hp_pins[0] = 0x1b;
9159 spec->autocfg.speaker_pins[0] = 0x14;
9160 spec->autocfg.speaker_pins[1] = 0x15;
9161 spec->autocfg.speaker_pins[2] = 0x16;
9162 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009163}
9164
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009165static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009166{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009167 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009168
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009169 spec->autocfg.hp_pins[0] = 0x1b;
9170 spec->autocfg.speaker_pins[0] = 0x14;
9171 spec->autocfg.speaker_pins[1] = 0x15;
9172 spec->autocfg.speaker_pins[2] = 0x16;
9173 spec->autocfg.speaker_pins[3] = 0x17;
9174 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009175}
9176
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009177static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009178{
9179 struct alc_spec *spec = codec->spec;
9180
9181 spec->autocfg.hp_pins[0] = 0x15;
9182 spec->autocfg.speaker_pins[0] = 0x14;
9183 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009184}
9185
Kailang Yange2757d52008-08-26 13:17:46 +02009186static struct hda_verb alc888_asus_m90v_verbs[] = {
9187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9190 /* enable unsolicited event */
9191 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9192 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9193 { } /* end */
9194};
9195
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009196static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009197{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009198 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009199
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009200 spec->autocfg.hp_pins[0] = 0x1b;
9201 spec->autocfg.speaker_pins[0] = 0x14;
9202 spec->autocfg.speaker_pins[1] = 0x15;
9203 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009204 spec->ext_mic.pin = 0x18;
9205 spec->int_mic.pin = 0x19;
9206 spec->ext_mic.mux_idx = 0;
9207 spec->int_mic.mux_idx = 1;
9208 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009209}
9210
9211static struct hda_verb alc888_asus_eee1601_verbs[] = {
9212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9217 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9218 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9219 /* enable unsolicited event */
9220 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9221 { } /* end */
9222};
9223
Kailang Yange2757d52008-08-26 13:17:46 +02009224static void alc883_eee1601_inithook(struct hda_codec *codec)
9225{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009226 struct alc_spec *spec = codec->spec;
9227
9228 spec->autocfg.hp_pins[0] = 0x14;
9229 spec->autocfg.speaker_pins[0] = 0x1b;
9230 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009231}
9232
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009233static struct hda_verb alc889A_mb31_verbs[] = {
9234 /* Init rear pin (used as headphone output) */
9235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9236 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9237 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9238 /* Init line pin (used as output in 4ch and 6ch mode) */
9239 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9240 /* Init line 2 pin (used as headphone out by default) */
9241 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9242 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9243 { } /* end */
9244};
9245
9246/* Mute speakers according to the headphone jack state */
9247static void alc889A_mb31_automute(struct hda_codec *codec)
9248{
9249 unsigned int present;
9250
9251 /* Mute only in 2ch or 4ch mode */
9252 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9253 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009254 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009255 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9256 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9257 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9258 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9259 }
9260}
9261
9262static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9263{
9264 if ((res >> 26) == ALC880_HP_EVENT)
9265 alc889A_mb31_automute(codec);
9266}
9267
Takashi Iwai4953550a2009-06-30 15:28:30 +02009268
Takashi Iwaicb53c622007-08-10 17:21:45 +02009269#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009270#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009271#endif
9272
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009273/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009274#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9275#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9276#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9277#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9278
9279static hda_nid_t alc883_slave_dig_outs[] = {
9280 ALC1200_DIGOUT_NID, 0,
9281};
9282
9283static hda_nid_t alc1200_slave_dig_outs[] = {
9284 ALC883_DIGOUT_NID, 0,
9285};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009286
9287/*
9288 * configuration and preset
9289 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009290static const char *alc882_models[ALC882_MODEL_LAST] = {
9291 [ALC882_3ST_DIG] = "3stack-dig",
9292 [ALC882_6ST_DIG] = "6stack-dig",
9293 [ALC882_ARIMA] = "arima",
9294 [ALC882_W2JC] = "w2jc",
9295 [ALC882_TARGA] = "targa",
9296 [ALC882_ASUS_A7J] = "asus-a7j",
9297 [ALC882_ASUS_A7M] = "asus-a7m",
9298 [ALC885_MACPRO] = "macpro",
9299 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009300 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009301 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009302 [ALC885_MBP3] = "mbp3",
9303 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009304 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009305 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009306 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9307 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009308 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009309 [ALC883_TARGA_DIG] = "targa-dig",
9310 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009311 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009312 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009313 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009314 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009315 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009316 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009317 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009318 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009319 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009320 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009321 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009322 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009323 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9324 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009325 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009326 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009327 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009328 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009329 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309330 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009331 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009332 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009333 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009334 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009335 [ALC889A_INTEL] = "intel-alc889a",
9336 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009337 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009338 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009339 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009340 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009341};
9342
Takashi Iwai4953550a2009-06-30 15:28:30 +02009343static struct snd_pci_quirk alc882_cfg_tbl[] = {
9344 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9345
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009346 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009347 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009348 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009349 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9350 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009351 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009352 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9353 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009354 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009355 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009356 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9357 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009358 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9359 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009360 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9361 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009362 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009363 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009364 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009365 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009366 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9367 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009368 /* default Acer -- disabled as it causes more problems.
9369 * model=auto should work fine now
9370 */
9371 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009372
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009373 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009374
Tobin Davisfebe3372007-06-12 11:27:46 +02009375 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009376 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9377 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009378 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009379 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009380 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009381
9382 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9383 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9384 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009385 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009386 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9387 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9388 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009389 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009390 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009391 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009392 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009393
9394 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009395 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009396 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009397 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009398 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9399 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009400 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009401 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009402 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9403
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009404 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9405 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9406 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009407 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009408 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009409 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009410 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009411 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009412 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9413 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9414 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9415 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9416 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9417 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009418 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009419 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9420 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9421 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009422 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009423 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009424 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9425 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009426 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009427 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009428 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009429 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009430 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009431 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009432 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009433 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009434 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009435
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009436 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009437 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009438 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9439 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309440 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009441 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009442 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009443 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009444 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009445 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009446 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009447 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009448 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009449 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009450 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009451 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9452 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009453 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009454 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009455 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009456 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009457 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009458
Jiang zhe17bba1b2008-06-04 12:11:07 +02009459 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9460 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009461 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009462 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9463 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9464 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009465 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009466
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009467 {}
9468};
9469
Takashi Iwai4953550a2009-06-30 15:28:30 +02009470/* codec SSID table for Intel Mac */
9471static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9472 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9473 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9474 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9475 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9476 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9477 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9478 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009479 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009480 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009481 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9482 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9483 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009484 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009485 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009486 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9487 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009488 */
9489 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009490 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009491 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009492 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009493};
9494
Takashi Iwai4953550a2009-06-30 15:28:30 +02009495static struct alc_config_preset alc882_presets[] = {
9496 [ALC882_3ST_DIG] = {
9497 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009498 .init_verbs = { alc882_base_init_verbs,
9499 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009500 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9501 .dac_nids = alc882_dac_nids,
9502 .dig_out_nid = ALC882_DIGOUT_NID,
9503 .dig_in_nid = ALC882_DIGIN_NID,
9504 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9505 .channel_mode = alc882_ch_modes,
9506 .need_dac_fix = 1,
9507 .input_mux = &alc882_capture_source,
9508 },
9509 [ALC882_6ST_DIG] = {
9510 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009511 .init_verbs = { alc882_base_init_verbs,
9512 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009513 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9514 .dac_nids = alc882_dac_nids,
9515 .dig_out_nid = ALC882_DIGOUT_NID,
9516 .dig_in_nid = ALC882_DIGIN_NID,
9517 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9518 .channel_mode = alc882_sixstack_modes,
9519 .input_mux = &alc882_capture_source,
9520 },
9521 [ALC882_ARIMA] = {
9522 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009523 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9524 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009525 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9526 .dac_nids = alc882_dac_nids,
9527 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9528 .channel_mode = alc882_sixstack_modes,
9529 .input_mux = &alc882_capture_source,
9530 },
9531 [ALC882_W2JC] = {
9532 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009533 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9534 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009535 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9536 .dac_nids = alc882_dac_nids,
9537 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9538 .channel_mode = alc880_threestack_modes,
9539 .need_dac_fix = 1,
9540 .input_mux = &alc882_capture_source,
9541 .dig_out_nid = ALC882_DIGOUT_NID,
9542 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009543 [ALC885_MBA21] = {
9544 .mixers = { alc885_mba21_mixer },
9545 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9546 .num_dacs = 2,
9547 .dac_nids = alc882_dac_nids,
9548 .channel_mode = alc885_mba21_ch_modes,
9549 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9550 .input_mux = &alc882_capture_source,
9551 .unsol_event = alc_automute_amp_unsol_event,
9552 .setup = alc885_mba21_setup,
9553 .init_hook = alc_automute_amp,
9554 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009555 [ALC885_MBP3] = {
9556 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9557 .init_verbs = { alc885_mbp3_init_verbs,
9558 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009559 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009560 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009561 .hp_nid = 0x04,
9562 .channel_mode = alc885_mbp_4ch_modes,
9563 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009564 .input_mux = &alc882_capture_source,
9565 .dig_out_nid = ALC882_DIGOUT_NID,
9566 .dig_in_nid = ALC882_DIGIN_NID,
9567 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009568 .setup = alc885_mbp3_setup,
9569 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009570 },
9571 [ALC885_MB5] = {
9572 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9573 .init_verbs = { alc885_mb5_init_verbs,
9574 alc880_gpio1_init_verbs },
9575 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9576 .dac_nids = alc882_dac_nids,
9577 .channel_mode = alc885_mb5_6ch_modes,
9578 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9579 .input_mux = &mb5_capture_source,
9580 .dig_out_nid = ALC882_DIGOUT_NID,
9581 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009582 .unsol_event = alc_automute_amp_unsol_event,
9583 .setup = alc885_mb5_setup,
9584 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009585 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009586 [ALC885_MACMINI3] = {
9587 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9588 .init_verbs = { alc885_macmini3_init_verbs,
9589 alc880_gpio1_init_verbs },
9590 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9591 .dac_nids = alc882_dac_nids,
9592 .channel_mode = alc885_macmini3_6ch_modes,
9593 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9594 .input_mux = &macmini3_capture_source,
9595 .dig_out_nid = ALC882_DIGOUT_NID,
9596 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009597 .unsol_event = alc_automute_amp_unsol_event,
9598 .setup = alc885_macmini3_setup,
9599 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009600 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009601 [ALC885_MACPRO] = {
9602 .mixers = { alc882_macpro_mixer },
9603 .init_verbs = { alc882_macpro_init_verbs },
9604 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9605 .dac_nids = alc882_dac_nids,
9606 .dig_out_nid = ALC882_DIGOUT_NID,
9607 .dig_in_nid = ALC882_DIGIN_NID,
9608 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9609 .channel_mode = alc882_ch_modes,
9610 .input_mux = &alc882_capture_source,
9611 .init_hook = alc885_macpro_init_hook,
9612 },
9613 [ALC885_IMAC24] = {
9614 .mixers = { alc885_imac24_mixer },
9615 .init_verbs = { alc885_imac24_init_verbs },
9616 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9617 .dac_nids = alc882_dac_nids,
9618 .dig_out_nid = ALC882_DIGOUT_NID,
9619 .dig_in_nid = ALC882_DIGIN_NID,
9620 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9621 .channel_mode = alc882_ch_modes,
9622 .input_mux = &alc882_capture_source,
9623 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009624 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009625 .init_hook = alc885_imac24_init_hook,
9626 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009627 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009628 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009629 .init_verbs = { alc885_imac91_init_verbs,
9630 alc880_gpio1_init_verbs },
9631 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9632 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009633 .channel_mode = alc885_mba21_ch_modes,
9634 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9635 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009636 .dig_out_nid = ALC882_DIGOUT_NID,
9637 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009638 .unsol_event = alc_automute_amp_unsol_event,
9639 .setup = alc885_imac91_setup,
9640 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009641 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009642 [ALC882_TARGA] = {
9643 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009644 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009645 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009646 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9647 .dac_nids = alc882_dac_nids,
9648 .dig_out_nid = ALC882_DIGOUT_NID,
9649 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9650 .adc_nids = alc882_adc_nids,
9651 .capsrc_nids = alc882_capsrc_nids,
9652 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9653 .channel_mode = alc882_3ST_6ch_modes,
9654 .need_dac_fix = 1,
9655 .input_mux = &alc882_capture_source,
9656 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009657 .setup = alc882_targa_setup,
9658 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009659 },
9660 [ALC882_ASUS_A7J] = {
9661 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009662 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9663 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009664 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9665 .dac_nids = alc882_dac_nids,
9666 .dig_out_nid = ALC882_DIGOUT_NID,
9667 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9668 .adc_nids = alc882_adc_nids,
9669 .capsrc_nids = alc882_capsrc_nids,
9670 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9671 .channel_mode = alc882_3ST_6ch_modes,
9672 .need_dac_fix = 1,
9673 .input_mux = &alc882_capture_source,
9674 },
9675 [ALC882_ASUS_A7M] = {
9676 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009677 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9678 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009679 alc882_asus_a7m_verbs },
9680 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9681 .dac_nids = alc882_dac_nids,
9682 .dig_out_nid = ALC882_DIGOUT_NID,
9683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9684 .channel_mode = alc880_threestack_modes,
9685 .need_dac_fix = 1,
9686 .input_mux = &alc882_capture_source,
9687 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009688 [ALC883_3ST_2ch_DIG] = {
9689 .mixers = { alc883_3ST_2ch_mixer },
9690 .init_verbs = { alc883_init_verbs },
9691 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9692 .dac_nids = alc883_dac_nids,
9693 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009694 .dig_in_nid = ALC883_DIGIN_NID,
9695 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9696 .channel_mode = alc883_3ST_2ch_modes,
9697 .input_mux = &alc883_capture_source,
9698 },
9699 [ALC883_3ST_6ch_DIG] = {
9700 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9701 .init_verbs = { alc883_init_verbs },
9702 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9703 .dac_nids = alc883_dac_nids,
9704 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009705 .dig_in_nid = ALC883_DIGIN_NID,
9706 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9707 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009708 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009709 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009710 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009711 [ALC883_3ST_6ch] = {
9712 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9713 .init_verbs = { alc883_init_verbs },
9714 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9715 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009716 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9717 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009718 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009719 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009720 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009721 [ALC883_3ST_6ch_INTEL] = {
9722 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9723 .init_verbs = { alc883_init_verbs },
9724 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9725 .dac_nids = alc883_dac_nids,
9726 .dig_out_nid = ALC883_DIGOUT_NID,
9727 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009728 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009729 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9730 .channel_mode = alc883_3ST_6ch_intel_modes,
9731 .need_dac_fix = 1,
9732 .input_mux = &alc883_3stack_6ch_intel,
9733 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009734 [ALC889A_INTEL] = {
9735 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009736 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9737 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009738 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9739 .dac_nids = alc883_dac_nids,
9740 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9741 .adc_nids = alc889_adc_nids,
9742 .dig_out_nid = ALC883_DIGOUT_NID,
9743 .dig_in_nid = ALC883_DIGIN_NID,
9744 .slave_dig_outs = alc883_slave_dig_outs,
9745 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9746 .channel_mode = alc889_8ch_intel_modes,
9747 .capsrc_nids = alc889_capsrc_nids,
9748 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009749 .setup = alc889_automute_setup,
9750 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009751 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009752 .need_dac_fix = 1,
9753 },
9754 [ALC889_INTEL] = {
9755 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9756 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009757 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009758 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9759 .dac_nids = alc883_dac_nids,
9760 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9761 .adc_nids = alc889_adc_nids,
9762 .dig_out_nid = ALC883_DIGOUT_NID,
9763 .dig_in_nid = ALC883_DIGIN_NID,
9764 .slave_dig_outs = alc883_slave_dig_outs,
9765 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9766 .channel_mode = alc889_8ch_intel_modes,
9767 .capsrc_nids = alc889_capsrc_nids,
9768 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009769 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009770 .init_hook = alc889_intel_init_hook,
9771 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009772 .need_dac_fix = 1,
9773 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009774 [ALC883_6ST_DIG] = {
9775 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9776 .init_verbs = { alc883_init_verbs },
9777 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9778 .dac_nids = alc883_dac_nids,
9779 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009780 .dig_in_nid = ALC883_DIGIN_NID,
9781 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9782 .channel_mode = alc883_sixstack_modes,
9783 .input_mux = &alc883_capture_source,
9784 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009785 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009786 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009787 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9788 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009789 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9790 .dac_nids = alc883_dac_nids,
9791 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009792 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9793 .channel_mode = alc883_3ST_6ch_modes,
9794 .need_dac_fix = 1,
9795 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009796 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009797 .setup = alc882_targa_setup,
9798 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009799 },
9800 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009801 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009802 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9803 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009804 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9805 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009806 .adc_nids = alc883_adc_nids_alt,
9807 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009808 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009809 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009810 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9811 .channel_mode = alc883_3ST_2ch_modes,
9812 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009813 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009814 .setup = alc882_targa_setup,
9815 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009816 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009817 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009818 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9819 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009820 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009821 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009822 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9823 .dac_nids = alc883_dac_nids,
9824 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9825 .adc_nids = alc883_adc_nids_rev,
9826 .capsrc_nids = alc883_capsrc_nids_rev,
9827 .dig_out_nid = ALC883_DIGOUT_NID,
9828 .dig_in_nid = ALC883_DIGIN_NID,
9829 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9830 .channel_mode = alc883_4ST_8ch_modes,
9831 .need_dac_fix = 1,
9832 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009833 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009834 .setup = alc882_targa_setup,
9835 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009836 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009837 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009838 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009839 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9840 * and the headphone jack. Turn this on and rely on the
9841 * standard mute methods whenever the user wants to turn
9842 * these outputs off.
9843 */
9844 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9846 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009847 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9848 .channel_mode = alc883_3ST_2ch_modes,
9849 .input_mux = &alc883_capture_source,
9850 },
Tobin Davis2880a862007-08-07 11:50:26 +02009851 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009852 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009853 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009854 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9855 .dac_nids = alc883_dac_nids,
9856 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009857 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9858 .channel_mode = alc883_3ST_2ch_modes,
9859 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009860 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009861 .setup = alc883_acer_aspire_setup,
9862 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009863 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009864 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009865 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009866 alc883_chmode_mixer },
9867 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9868 alc888_acer_aspire_4930g_verbs },
9869 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9870 .dac_nids = alc883_dac_nids,
9871 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9872 .adc_nids = alc883_adc_nids_rev,
9873 .capsrc_nids = alc883_capsrc_nids_rev,
9874 .dig_out_nid = ALC883_DIGOUT_NID,
9875 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9876 .channel_mode = alc883_3ST_6ch_modes,
9877 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009878 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009879 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009880 ARRAY_SIZE(alc888_2_capture_sources),
9881 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009882 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009883 .setup = alc888_acer_aspire_4930g_setup,
9884 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009885 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009886 [ALC888_ACER_ASPIRE_6530G] = {
9887 .mixers = { alc888_acer_aspire_6530_mixer },
9888 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9889 alc888_acer_aspire_6530g_verbs },
9890 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9891 .dac_nids = alc883_dac_nids,
9892 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9893 .adc_nids = alc883_adc_nids_rev,
9894 .capsrc_nids = alc883_capsrc_nids_rev,
9895 .dig_out_nid = ALC883_DIGOUT_NID,
9896 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9897 .channel_mode = alc883_3ST_2ch_modes,
9898 .num_mux_defs =
9899 ARRAY_SIZE(alc888_2_capture_sources),
9900 .input_mux = alc888_acer_aspire_6530_sources,
9901 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009902 .setup = alc888_acer_aspire_6530g_setup,
9903 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009904 },
Hector Martin3b315d72009-06-02 10:54:19 +02009905 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009906 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009907 alc883_chmode_mixer },
9908 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009909 alc889_acer_aspire_8930g_verbs,
9910 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009911 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9912 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009913 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9914 .adc_nids = alc889_adc_nids,
9915 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009916 .dig_out_nid = ALC883_DIGOUT_NID,
9917 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9918 .channel_mode = alc883_3ST_6ch_modes,
9919 .need_dac_fix = 1,
9920 .const_channel_count = 6,
9921 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009922 ARRAY_SIZE(alc889_capture_sources),
9923 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009924 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009925 .setup = alc889_acer_aspire_8930g_setup,
9926 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009927#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009928 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009929#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009930 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009931 [ALC888_ACER_ASPIRE_7730G] = {
9932 .mixers = { alc883_3ST_6ch_mixer,
9933 alc883_chmode_mixer },
9934 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9935 alc888_acer_aspire_7730G_verbs },
9936 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9937 .dac_nids = alc883_dac_nids,
9938 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9939 .adc_nids = alc883_adc_nids_rev,
9940 .capsrc_nids = alc883_capsrc_nids_rev,
9941 .dig_out_nid = ALC883_DIGOUT_NID,
9942 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9943 .channel_mode = alc883_3ST_6ch_modes,
9944 .need_dac_fix = 1,
9945 .const_channel_count = 6,
9946 .input_mux = &alc883_capture_source,
9947 .unsol_event = alc_automute_amp_unsol_event,
9948 .setup = alc888_acer_aspire_6530g_setup,
9949 .init_hook = alc_automute_amp,
9950 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009951 [ALC883_MEDION] = {
9952 .mixers = { alc883_fivestack_mixer,
9953 alc883_chmode_mixer },
9954 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009955 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009956 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9957 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009958 .adc_nids = alc883_adc_nids_alt,
9959 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009960 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009961 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9962 .channel_mode = alc883_sixstack_modes,
9963 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009964 },
Kailang Yang272a5272007-05-14 11:00:38 +02009965 [ALC883_MEDION_MD2] = {
9966 .mixers = { alc883_medion_md2_mixer},
9967 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9968 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9969 .dac_nids = alc883_dac_nids,
9970 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009971 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9972 .channel_mode = alc883_3ST_2ch_modes,
9973 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009974 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009975 .setup = alc883_medion_md2_setup,
9976 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009977 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009978 [ALC883_MEDION_WIM2160] = {
9979 .mixers = { alc883_medion_wim2160_mixer },
9980 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
9981 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9982 .dac_nids = alc883_dac_nids,
9983 .dig_out_nid = ALC883_DIGOUT_NID,
9984 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9985 .adc_nids = alc883_adc_nids,
9986 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9987 .channel_mode = alc883_3ST_2ch_modes,
9988 .input_mux = &alc883_capture_source,
9989 .unsol_event = alc_automute_amp_unsol_event,
9990 .setup = alc883_medion_wim2160_setup,
9991 .init_hook = alc_automute_amp,
9992 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009993 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009994 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009995 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9996 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9997 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009998 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9999 .channel_mode = alc883_3ST_2ch_modes,
10000 .input_mux = &alc883_capture_source,
10001 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010002 [ALC883_CLEVO_M540R] = {
10003 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10004 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10005 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10006 .dac_nids = alc883_dac_nids,
10007 .dig_out_nid = ALC883_DIGOUT_NID,
10008 .dig_in_nid = ALC883_DIGIN_NID,
10009 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10010 .channel_mode = alc883_3ST_6ch_clevo_modes,
10011 .need_dac_fix = 1,
10012 .input_mux = &alc883_capture_source,
10013 /* This machine has the hardware HP auto-muting, thus
10014 * we need no software mute via unsol event
10015 */
10016 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010017 [ALC883_CLEVO_M720] = {
10018 .mixers = { alc883_clevo_m720_mixer },
10019 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010020 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10021 .dac_nids = alc883_dac_nids,
10022 .dig_out_nid = ALC883_DIGOUT_NID,
10023 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10024 .channel_mode = alc883_3ST_2ch_modes,
10025 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010026 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010027 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010028 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010029 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010030 [ALC883_LENOVO_101E_2ch] = {
10031 .mixers = { alc883_lenovo_101e_2ch_mixer},
10032 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10033 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10034 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010035 .adc_nids = alc883_adc_nids_alt,
10036 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010037 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010038 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10039 .channel_mode = alc883_3ST_2ch_modes,
10040 .input_mux = &alc883_lenovo_101e_capture_source,
10041 .unsol_event = alc883_lenovo_101e_unsol_event,
10042 .init_hook = alc883_lenovo_101e_all_automute,
10043 },
Kailang Yang272a5272007-05-14 11:00:38 +020010044 [ALC883_LENOVO_NB0763] = {
10045 .mixers = { alc883_lenovo_nb0763_mixer },
10046 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10047 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10048 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010049 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10050 .channel_mode = alc883_3ST_2ch_modes,
10051 .need_dac_fix = 1,
10052 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010053 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010054 .setup = alc883_medion_md2_setup,
10055 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010056 },
10057 [ALC888_LENOVO_MS7195_DIG] = {
10058 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10059 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10060 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10061 .dac_nids = alc883_dac_nids,
10062 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010063 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10064 .channel_mode = alc883_3ST_6ch_modes,
10065 .need_dac_fix = 1,
10066 .input_mux = &alc883_capture_source,
10067 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10068 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010069 },
10070 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010071 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010072 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10073 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10074 .dac_nids = alc883_dac_nids,
10075 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010076 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10077 .channel_mode = alc883_3ST_2ch_modes,
10078 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010079 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010080 .setup = alc883_haier_w66_setup,
10081 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010082 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010083 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010084 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010085 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010086 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10087 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010088 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10089 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010090 .need_dac_fix = 1,
10091 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010092 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010093 .setup = alc888_3st_hp_setup,
10094 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010095 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010096 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010097 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010098 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10099 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10100 .dac_nids = alc883_dac_nids,
10101 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010102 .dig_in_nid = ALC883_DIGIN_NID,
10103 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10104 .channel_mode = alc883_sixstack_modes,
10105 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010106 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010107 .setup = alc888_6st_dell_setup,
10108 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010109 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010110 [ALC883_MITAC] = {
10111 .mixers = { alc883_mitac_mixer },
10112 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10113 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10114 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010115 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10116 .channel_mode = alc883_3ST_2ch_modes,
10117 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010118 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010119 .setup = alc883_mitac_setup,
10120 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010121 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010122 [ALC883_FUJITSU_PI2515] = {
10123 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10124 .init_verbs = { alc883_init_verbs,
10125 alc883_2ch_fujitsu_pi2515_verbs},
10126 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10127 .dac_nids = alc883_dac_nids,
10128 .dig_out_nid = ALC883_DIGOUT_NID,
10129 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10130 .channel_mode = alc883_3ST_2ch_modes,
10131 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010132 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010133 .setup = alc883_2ch_fujitsu_pi2515_setup,
10134 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010135 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010136 [ALC888_FUJITSU_XA3530] = {
10137 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10138 .init_verbs = { alc883_init_verbs,
10139 alc888_fujitsu_xa3530_verbs },
10140 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10141 .dac_nids = alc883_dac_nids,
10142 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10143 .adc_nids = alc883_adc_nids_rev,
10144 .capsrc_nids = alc883_capsrc_nids_rev,
10145 .dig_out_nid = ALC883_DIGOUT_NID,
10146 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10147 .channel_mode = alc888_4ST_8ch_intel_modes,
10148 .num_mux_defs =
10149 ARRAY_SIZE(alc888_2_capture_sources),
10150 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010151 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010152 .setup = alc888_fujitsu_xa3530_setup,
10153 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010154 },
Kailang Yange2757d52008-08-26 13:17:46 +020010155 [ALC888_LENOVO_SKY] = {
10156 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10157 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10158 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10159 .dac_nids = alc883_dac_nids,
10160 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010161 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10162 .channel_mode = alc883_sixstack_modes,
10163 .need_dac_fix = 1,
10164 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010165 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010166 .setup = alc888_lenovo_sky_setup,
10167 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010168 },
10169 [ALC888_ASUS_M90V] = {
10170 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10171 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10172 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10173 .dac_nids = alc883_dac_nids,
10174 .dig_out_nid = ALC883_DIGOUT_NID,
10175 .dig_in_nid = ALC883_DIGIN_NID,
10176 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10177 .channel_mode = alc883_3ST_6ch_modes,
10178 .need_dac_fix = 1,
10179 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010180 .unsol_event = alc_sku_unsol_event,
10181 .setup = alc883_mode2_setup,
10182 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010183 },
10184 [ALC888_ASUS_EEE1601] = {
10185 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010186 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010187 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10189 .dac_nids = alc883_dac_nids,
10190 .dig_out_nid = ALC883_DIGOUT_NID,
10191 .dig_in_nid = ALC883_DIGIN_NID,
10192 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10193 .channel_mode = alc883_3ST_2ch_modes,
10194 .need_dac_fix = 1,
10195 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010196 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010197 .init_hook = alc883_eee1601_inithook,
10198 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010199 [ALC1200_ASUS_P5Q] = {
10200 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10201 .init_verbs = { alc883_init_verbs },
10202 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10203 .dac_nids = alc883_dac_nids,
10204 .dig_out_nid = ALC1200_DIGOUT_NID,
10205 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010206 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010207 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10208 .channel_mode = alc883_sixstack_modes,
10209 .input_mux = &alc883_capture_source,
10210 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010211 [ALC889A_MB31] = {
10212 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10213 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10214 alc880_gpio1_init_verbs },
10215 .adc_nids = alc883_adc_nids,
10216 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010217 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010218 .dac_nids = alc883_dac_nids,
10219 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10220 .channel_mode = alc889A_mb31_6ch_modes,
10221 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10222 .input_mux = &alc889A_mb31_capture_source,
10223 .dig_out_nid = ALC883_DIGOUT_NID,
10224 .unsol_event = alc889A_mb31_unsol_event,
10225 .init_hook = alc889A_mb31_automute,
10226 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010227 [ALC883_SONY_VAIO_TT] = {
10228 .mixers = { alc883_vaiott_mixer },
10229 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10230 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10231 .dac_nids = alc883_dac_nids,
10232 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10233 .channel_mode = alc883_3ST_2ch_modes,
10234 .input_mux = &alc883_capture_source,
10235 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010236 .setup = alc883_vaiott_setup,
10237 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010238 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010239};
10240
10241
10242/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010243 * Pin config fixes
10244 */
10245enum {
10246 PINFIX_ABIT_AW9D_MAX
10247};
10248
10249static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10250 { 0x15, 0x01080104 }, /* side */
10251 { 0x16, 0x01011012 }, /* rear */
10252 { 0x17, 0x01016011 }, /* clfe */
10253 { }
10254};
10255
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010256static const struct alc_fixup alc882_fixups[] = {
10257 [PINFIX_ABIT_AW9D_MAX] = {
10258 .pins = alc882_abit_aw9d_pinfix
10259 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010260};
10261
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010262static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010263 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10264 {}
10265};
10266
10267/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010268 * BIOS auto configuration
10269 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010270static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10271 const struct auto_pin_cfg *cfg)
10272{
10273 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10274}
10275
Takashi Iwai4953550a2009-06-30 15:28:30 +020010276static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010277 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010278 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010279{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010280 int idx;
10281
Takashi Iwai489008c2010-04-07 09:06:00 +020010282 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010283 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010284
Takashi Iwai489008c2010-04-07 09:06:00 +020010285 if (dac == 0x25)
10286 idx = 4;
10287 else if (dac >= 0x02 && dac <= 0x05)
10288 idx = dac - 2;
10289 else
10290 return;
10291 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010292}
10293
Takashi Iwai4953550a2009-06-30 15:28:30 +020010294static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010295{
10296 struct alc_spec *spec = codec->spec;
10297 int i;
10298
10299 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010300 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010301 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010302 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010303 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010304 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010305 }
10306}
10307
Takashi Iwai4953550a2009-06-30 15:28:30 +020010308static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010309{
10310 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010311 hda_nid_t pin, dac;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010312
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010313 pin = spec->autocfg.hp_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010314 if (pin) {
10315 dac = spec->multiout.hp_nid;
10316 if (!dac)
10317 dac = spec->multiout.dac_nids[0]; /* to front */
10318 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10319 }
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010320 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010321 if (pin) {
10322 dac = spec->multiout.extra_out_nid[0];
10323 if (!dac)
10324 dac = spec->multiout.dac_nids[0]; /* to front */
10325 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10326 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010327}
10328
Takashi Iwai4953550a2009-06-30 15:28:30 +020010329static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010330{
10331 struct alc_spec *spec = codec->spec;
10332 int i;
10333
10334 for (i = 0; i < AUTO_PIN_LAST; i++) {
10335 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010336 if (!nid)
10337 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010338 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010339 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10340 snd_hda_codec_write(codec, nid, 0,
10341 AC_VERB_SET_AMP_GAIN_MUTE,
10342 AMP_OUT_MUTE);
10343 }
10344}
10345
10346static void alc882_auto_init_input_src(struct hda_codec *codec)
10347{
10348 struct alc_spec *spec = codec->spec;
10349 int c;
10350
10351 for (c = 0; c < spec->num_adc_nids; c++) {
10352 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10353 hda_nid_t nid = spec->capsrc_nids[c];
10354 unsigned int mux_idx;
10355 const struct hda_input_mux *imux;
10356 int conns, mute, idx, item;
10357
10358 conns = snd_hda_get_connections(codec, nid, conn_list,
10359 ARRAY_SIZE(conn_list));
10360 if (conns < 0)
10361 continue;
10362 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10363 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010364 if (!imux->num_items && mux_idx > 0)
10365 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010366 for (idx = 0; idx < conns; idx++) {
10367 /* if the current connection is the selected one,
10368 * unmute it as default - otherwise mute it
10369 */
10370 mute = AMP_IN_MUTE(idx);
10371 for (item = 0; item < imux->num_items; item++) {
10372 if (imux->items[item].index == idx) {
10373 if (spec->cur_mux[c] == item)
10374 mute = AMP_IN_UNMUTE(idx);
10375 break;
10376 }
10377 }
10378 /* check if we have a selector or mixer
10379 * we could check for the widget type instead, but
10380 * just check for Amp-In presence (in case of mixer
10381 * without amp-in there is something wrong, this
10382 * function shouldn't be used or capsrc nid is wrong)
10383 */
10384 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010385 snd_hda_codec_write(codec, nid, 0,
10386 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010387 mute);
10388 else if (mute != AMP_IN_MUTE(idx))
10389 snd_hda_codec_write(codec, nid, 0,
10390 AC_VERB_SET_CONNECT_SEL,
10391 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010392 }
10393 }
10394}
10395
Takashi Iwai4953550a2009-06-30 15:28:30 +020010396/* add mic boosts if needed */
10397static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010398{
10399 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010400 int err;
10401 hda_nid_t nid;
10402
10403 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10404 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10405 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10406 "Mic Boost",
10407 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10408 if (err < 0)
10409 return err;
10410 }
10411 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10412 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10413 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10414 "Front Mic Boost",
10415 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10416 if (err < 0)
10417 return err;
10418 }
10419 return 0;
10420}
10421
10422/* almost identical with ALC880 parser... */
10423static int alc882_parse_auto_config(struct hda_codec *codec)
10424{
10425 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010426 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10427 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010428
Takashi Iwai05f5f472009-08-25 13:10:18 +020010429 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10430 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010431 if (err < 0)
10432 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010433 if (!spec->autocfg.line_outs)
10434 return 0; /* can't find valid BIOS pin config */
10435
10436 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10437 if (err < 0)
10438 return err;
10439 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10440 if (err < 0)
10441 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010442 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10443 "Headphone");
10444 if (err < 0)
10445 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010446 err = alc880_auto_create_extra_out(spec,
10447 spec->autocfg.speaker_pins[0],
10448 "Speaker");
10449 if (err < 0)
10450 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010451 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10452 if (err < 0)
10453 return err;
10454
10455 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10456
10457 /* check multiple SPDIF-out (for recent codecs) */
10458 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10459 hda_nid_t dig_nid;
10460 err = snd_hda_get_connections(codec,
10461 spec->autocfg.dig_out_pins[i],
10462 &dig_nid, 1);
10463 if (err < 0)
10464 continue;
10465 if (!i)
10466 spec->multiout.dig_out_nid = dig_nid;
10467 else {
10468 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010469 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010470 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010471 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010472 }
10473 }
10474 if (spec->autocfg.dig_in_pin)
10475 spec->dig_in_nid = ALC880_DIGIN_NID;
10476
10477 if (spec->kctls.list)
10478 add_mixer(spec, spec->kctls.list);
10479
10480 add_verb(spec, alc883_auto_init_verbs);
10481 /* if ADC 0x07 is available, initialize it, too */
10482 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10483 add_verb(spec, alc882_adc1_init_verbs);
10484
10485 spec->num_mux_defs = 1;
10486 spec->input_mux = &spec->private_imux[0];
10487
Kailang Yang6227cdc2010-02-25 08:36:52 +010010488 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010489
10490 err = alc_auto_add_mic_boost(codec);
10491 if (err < 0)
10492 return err;
10493
Takashi Iwai776e1842007-08-29 15:07:11 +020010494 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010495}
10496
10497/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010498static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010499{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010500 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010501 alc882_auto_init_multi_out(codec);
10502 alc882_auto_init_hp_out(codec);
10503 alc882_auto_init_analog_input(codec);
10504 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010505 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010506 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010507}
10508
Takashi Iwai4953550a2009-06-30 15:28:30 +020010509static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010510{
10511 struct alc_spec *spec;
10512 int err, board_config;
10513
10514 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10515 if (spec == NULL)
10516 return -ENOMEM;
10517
10518 codec->spec = spec;
10519
Kailang Yangda00c242010-03-19 11:23:45 +010010520 alc_auto_parse_customize_define(codec);
10521
Takashi Iwai4953550a2009-06-30 15:28:30 +020010522 switch (codec->vendor_id) {
10523 case 0x10ec0882:
10524 case 0x10ec0885:
10525 break;
10526 default:
10527 /* ALC883 and variants */
10528 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10529 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010530 }
10531
Takashi Iwai4953550a2009-06-30 15:28:30 +020010532 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10533 alc882_models,
10534 alc882_cfg_tbl);
10535
10536 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10537 board_config = snd_hda_check_board_codec_sid_config(codec,
10538 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10539
10540 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010541 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010542 codec->chip_name);
10543 board_config = ALC882_AUTO;
10544 }
10545
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010546 if (board_config == ALC882_AUTO)
10547 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010548
10549 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010550 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010551 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010552 if (err < 0) {
10553 alc_free(codec);
10554 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010555 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010556 printk(KERN_INFO
10557 "hda_codec: Cannot set up configuration "
10558 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010559 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010560 }
10561 }
10562
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010563 err = snd_hda_attach_beep_device(codec, 0x1);
10564 if (err < 0) {
10565 alc_free(codec);
10566 return err;
10567 }
10568
Takashi Iwai4953550a2009-06-30 15:28:30 +020010569 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010570 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010571
Takashi Iwai4953550a2009-06-30 15:28:30 +020010572 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10573 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10574 /* FIXME: setup DAC5 */
10575 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10576 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10577
10578 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10579 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10580
Takashi Iwai4953550a2009-06-30 15:28:30 +020010581 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010582 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010583 spec->num_adc_nids = 0;
10584 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010585 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010586 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010587 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010588 hda_nid_t nid = alc882_adc_nids[i];
10589 unsigned int wcap = get_wcaps(codec, nid);
10590 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010591 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010592 if (wcap != AC_WID_AUD_IN)
10593 continue;
10594 spec->private_adc_nids[spec->num_adc_nids] = nid;
10595 err = snd_hda_get_connections(codec, nid, &cap, 1);
10596 if (err < 0)
10597 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010598 err = snd_hda_get_connections(codec, cap, items,
10599 ARRAY_SIZE(items));
10600 if (err < 0)
10601 continue;
10602 for (j = 0; j < imux->num_items; j++)
10603 if (imux->items[j].index >= err)
10604 break;
10605 if (j < imux->num_items)
10606 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010607 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10608 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010609 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010610 spec->adc_nids = spec->private_adc_nids;
10611 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010612 }
10613
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010614 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010615
10616 if (spec->cdefine.enable_pcbeep)
10617 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010618
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010619 if (board_config == ALC882_AUTO)
10620 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10621
Takashi Iwai2134ea42008-01-10 16:53:55 +010010622 spec->vmaster_nid = 0x0c;
10623
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010624 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010625 if (board_config == ALC882_AUTO)
10626 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010627#ifdef CONFIG_SND_HDA_POWER_SAVE
10628 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010629 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010630#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010631
10632 return 0;
10633}
10634
Takashi Iwai4953550a2009-06-30 15:28:30 +020010635
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010636/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010637 * ALC262 support
10638 */
10639
10640#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10641#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10642
10643#define alc262_dac_nids alc260_dac_nids
10644#define alc262_adc_nids alc882_adc_nids
10645#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010646#define alc262_capsrc_nids alc882_capsrc_nids
10647#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010648
10649#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010650#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010651
Kailang Yang4e555fe2008-08-26 13:05:55 +020010652static hda_nid_t alc262_dmic_adc_nids[1] = {
10653 /* ADC0 */
10654 0x09
10655};
10656
10657static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10658
Kailang Yangdf694da2005-12-05 19:42:22 +010010659static struct snd_kcontrol_new alc262_base_mixer[] = {
10660 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10661 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10665 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010668 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010669 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10670 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010671 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010672 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10673 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10674 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10675 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010676 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010677};
10678
Takashi Iwaice875f02008-01-28 18:17:43 +010010679/* update HP, line and mono-out pins according to the master switch */
10680static void alc262_hp_master_update(struct hda_codec *codec)
10681{
10682 struct alc_spec *spec = codec->spec;
10683 int val = spec->master_sw;
10684
10685 /* HP & line-out */
10686 snd_hda_codec_write_cache(codec, 0x1b, 0,
10687 AC_VERB_SET_PIN_WIDGET_CONTROL,
10688 val ? PIN_HP : 0);
10689 snd_hda_codec_write_cache(codec, 0x15, 0,
10690 AC_VERB_SET_PIN_WIDGET_CONTROL,
10691 val ? PIN_HP : 0);
10692 /* mono (speaker) depending on the HP jack sense */
10693 val = val && !spec->jack_present;
10694 snd_hda_codec_write_cache(codec, 0x16, 0,
10695 AC_VERB_SET_PIN_WIDGET_CONTROL,
10696 val ? PIN_OUT : 0);
10697}
10698
10699static void alc262_hp_bpc_automute(struct hda_codec *codec)
10700{
10701 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010702
10703 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010704 alc262_hp_master_update(codec);
10705}
10706
10707static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10708{
10709 if ((res >> 26) != ALC880_HP_EVENT)
10710 return;
10711 alc262_hp_bpc_automute(codec);
10712}
10713
10714static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10715{
10716 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010717
10718 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010719 alc262_hp_master_update(codec);
10720}
10721
10722static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10723 unsigned int res)
10724{
10725 if ((res >> 26) != ALC880_HP_EVENT)
10726 return;
10727 alc262_hp_wildwest_automute(codec);
10728}
10729
Takashi Iwaib72519b2009-05-08 14:31:55 +020010730#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010731
10732static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10733 struct snd_ctl_elem_value *ucontrol)
10734{
10735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10736 struct alc_spec *spec = codec->spec;
10737 int val = !!*ucontrol->value.integer.value;
10738
10739 if (val == spec->master_sw)
10740 return 0;
10741 spec->master_sw = val;
10742 alc262_hp_master_update(codec);
10743 return 1;
10744}
10745
Takashi Iwaib72519b2009-05-08 14:31:55 +020010746#define ALC262_HP_MASTER_SWITCH \
10747 { \
10748 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10749 .name = "Master Playback Switch", \
10750 .info = snd_ctl_boolean_mono_info, \
10751 .get = alc262_hp_master_sw_get, \
10752 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010753 }, \
10754 { \
10755 .iface = NID_MAPPING, \
10756 .name = "Master Playback Switch", \
10757 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010758 }
10759
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010760
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010761static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010762 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010763 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10764 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10765 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010766 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10767 HDA_OUTPUT),
10768 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10769 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10771 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010772 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010773 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10774 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010775 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010776 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10777 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10778 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10779 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010780 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10781 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10782 { } /* end */
10783};
10784
Kailang Yangcd7509a2007-01-26 18:33:17 +010010785static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010786 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010787 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10788 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10789 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10790 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010791 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10792 HDA_OUTPUT),
10793 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10794 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010795 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010797 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010798 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10799 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10800 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10801 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010802 { } /* end */
10803};
10804
10805static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10806 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10807 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010808 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010809 { } /* end */
10810};
10811
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010812/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010813static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010814{
10815 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010816
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010817 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010818 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010819}
10820
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010821static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010822 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10823 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010824 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10825 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10828 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10829 { } /* end */
10830};
10831
10832static struct hda_verb alc262_hp_t5735_verbs[] = {
10833 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10834 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10835
10836 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10837 { }
10838};
10839
Kailang Yang8c427222008-01-10 13:03:59 +010010840static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010841 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010843 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10844 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10847 { } /* end */
10848};
10849
10850static struct hda_verb alc262_hp_rp5700_verbs[] = {
10851 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10853 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10854 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10855 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10856 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10861 {}
10862};
10863
10864static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10865 .num_items = 1,
10866 .items = {
10867 { "Line", 0x1 },
10868 },
10869};
10870
Takashi Iwai42171c12009-05-08 14:11:43 +020010871/* bind hp and internal speaker mute (with plug check) as master switch */
10872static void alc262_hippo_master_update(struct hda_codec *codec)
10873{
10874 struct alc_spec *spec = codec->spec;
10875 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10876 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10877 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10878 unsigned int mute;
10879
10880 /* HP */
10881 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10882 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10883 HDA_AMP_MUTE, mute);
10884 /* mute internal speaker per jack sense */
10885 if (spec->jack_present)
10886 mute = HDA_AMP_MUTE;
10887 if (line_nid)
10888 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10889 HDA_AMP_MUTE, mute);
10890 if (speaker_nid && speaker_nid != line_nid)
10891 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10892 HDA_AMP_MUTE, mute);
10893}
10894
10895#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10896
10897static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10898 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010899{
10900 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010901 struct alc_spec *spec = codec->spec;
10902 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010903
Takashi Iwai42171c12009-05-08 14:11:43 +020010904 if (val == spec->master_sw)
10905 return 0;
10906 spec->master_sw = val;
10907 alc262_hippo_master_update(codec);
10908 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010909}
Takashi Iwai5b319542007-07-26 11:49:22 +020010910
Takashi Iwai42171c12009-05-08 14:11:43 +020010911#define ALC262_HIPPO_MASTER_SWITCH \
10912 { \
10913 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10914 .name = "Master Playback Switch", \
10915 .info = snd_ctl_boolean_mono_info, \
10916 .get = alc262_hippo_master_sw_get, \
10917 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010918 }, \
10919 { \
10920 .iface = NID_MAPPING, \
10921 .name = "Master Playback Switch", \
10922 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10923 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010924 }
10925
10926static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10927 ALC262_HIPPO_MASTER_SWITCH,
10928 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10929 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10930 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10935 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10936 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10937 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10938 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10939 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10940 { } /* end */
10941};
10942
10943static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10944 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10945 ALC262_HIPPO_MASTER_SWITCH,
10946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10948 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10949 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10950 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10952 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10955 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10956 { } /* end */
10957};
10958
10959/* mute/unmute internal speaker according to the hp jack and mute state */
10960static void alc262_hippo_automute(struct hda_codec *codec)
10961{
10962 struct alc_spec *spec = codec->spec;
10963 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010964
Wu Fengguang864f92b2009-11-18 12:38:02 +080010965 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010966 alc262_hippo_master_update(codec);
10967}
10968
10969static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10970{
10971 if ((res >> 26) != ALC880_HP_EVENT)
10972 return;
10973 alc262_hippo_automute(codec);
10974}
10975
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010976static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010977{
10978 struct alc_spec *spec = codec->spec;
10979
10980 spec->autocfg.hp_pins[0] = 0x15;
10981 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010982}
10983
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010984static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010985{
10986 struct alc_spec *spec = codec->spec;
10987
10988 spec->autocfg.hp_pins[0] = 0x1b;
10989 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010990}
10991
10992
Kailang Yang272a5272007-05-14 11:00:38 +020010993static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010994 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010995 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10998 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10999 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11000 { } /* end */
11001};
11002
Kailang Yang83c34212007-07-05 11:43:05 +020011003static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011004 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11005 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11009 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11010 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11011 { } /* end */
11012};
Kailang Yang272a5272007-05-14 11:00:38 +020011013
Tony Vroonba340e82009-02-02 19:01:30 +000011014static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11015 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11016 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11017 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11018 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11019 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11020 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11023 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11024 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11025 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11026 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11027 { } /* end */
11028};
11029
11030static struct hda_verb alc262_tyan_verbs[] = {
11031 /* Headphone automute */
11032 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11033 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11034 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11035
11036 /* P11 AUX_IN, white 4-pin connector */
11037 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11038 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11039 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11040 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11041
11042 {}
11043};
11044
11045/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011046static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011047{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011048 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011049
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011050 spec->autocfg.hp_pins[0] = 0x1b;
11051 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011052}
11053
Tony Vroonba340e82009-02-02 19:01:30 +000011054
Kailang Yangdf694da2005-12-05 19:42:22 +010011055#define alc262_capture_mixer alc882_capture_mixer
11056#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11057
11058/*
11059 * generic initialization of ADC, input mixers and output mixers
11060 */
11061static struct hda_verb alc262_init_verbs[] = {
11062 /*
11063 * Unmute ADC0-2 and set the default input to mic-in
11064 */
11065 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11067 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11069 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11071
Takashi Iwaicb53c622007-08-10 17:21:45 +020011072 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011073 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011074 * Note: PASD motherboards uses the Line In 2 as the input for
11075 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011076 */
11077 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011078 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11079 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011083
11084 /*
11085 * Set up output mixers (0x0c - 0x0e)
11086 */
11087 /* set vol=0 to output mixers */
11088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11091 /* set up input amps for analog loopback */
11092 /* Amp Indices: DAC = 0, mixer = 1 */
11093 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11095 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11096 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11097 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11098 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11099
11100 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11102 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11103 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11104 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11105 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11106
11107 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11108 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11109 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11110 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11111 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011112
Kailang Yangdf694da2005-12-05 19:42:22 +010011113 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011115
Kailang Yangdf694da2005-12-05 19:42:22 +010011116 /* FIXME: use matrix-type input source selection */
11117 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11118 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11119 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11120 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11121 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11122 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11123 /* Input mixer2 */
11124 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11125 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11126 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11127 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11128 /* Input mixer3 */
11129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011133
11134 { }
11135};
11136
Kailang Yang4e555fe2008-08-26 13:05:55 +020011137static struct hda_verb alc262_eapd_verbs[] = {
11138 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11139 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11140 { }
11141};
11142
Kailang Yangccc656c2006-10-17 12:32:26 +020011143static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11144 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11145 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11146 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11147
11148 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11149 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11150 {}
11151};
11152
Kailang Yang272a5272007-05-14 11:00:38 +020011153static struct hda_verb alc262_sony_unsol_verbs[] = {
11154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11156 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11157
11158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11159 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011160 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011161};
11162
Kailang Yang4e555fe2008-08-26 13:05:55 +020011163static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11164 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11165 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11168 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011169 { } /* end */
11170};
11171
11172static struct hda_verb alc262_toshiba_s06_verbs[] = {
11173 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11174 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11175 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11176 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11177 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11179 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11180 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11181 {}
11182};
11183
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011184static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011185{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011186 struct alc_spec *spec = codec->spec;
11187
11188 spec->autocfg.hp_pins[0] = 0x15;
11189 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011190 spec->ext_mic.pin = 0x18;
11191 spec->ext_mic.mux_idx = 0;
11192 spec->int_mic.pin = 0x12;
11193 spec->int_mic.mux_idx = 9;
11194 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011195}
11196
Takashi Iwai834be882006-03-01 14:16:17 +010011197/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011198 * nec model
11199 * 0x15 = headphone
11200 * 0x16 = internal speaker
11201 * 0x18 = external mic
11202 */
11203
11204static struct snd_kcontrol_new alc262_nec_mixer[] = {
11205 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11206 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11207
11208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11210 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11211
11212 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11213 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11214 { } /* end */
11215};
11216
11217static struct hda_verb alc262_nec_verbs[] = {
11218 /* Unmute Speaker */
11219 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11220
11221 /* Headphone */
11222 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11224
11225 /* External mic to headphone */
11226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11227 /* External mic to speaker */
11228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11229 {}
11230};
11231
11232/*
Takashi Iwai834be882006-03-01 14:16:17 +010011233 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011234 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11235 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011236 */
11237
11238#define ALC_HP_EVENT 0x37
11239
11240static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11241 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011243 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11244 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011245 {}
11246};
11247
Jiang zhe0e31daf2008-03-20 12:12:39 +010011248static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11249 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11250 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11251 {}
11252};
11253
Daniel T Chene2595322009-12-19 18:19:02 -050011254static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11255 /* Front Mic pin: input vref at 50% */
11256 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11258 {}
11259};
11260
Takashi Iwai834be882006-03-01 14:16:17 +010011261static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011262 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011263 .items = {
11264 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011265 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011266 { "CD", 0x4 },
11267 },
11268};
11269
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011270static struct hda_input_mux alc262_HP_capture_source = {
11271 .num_items = 5,
11272 .items = {
11273 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011274 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011275 { "Line", 0x2 },
11276 { "CD", 0x4 },
11277 { "AUX IN", 0x6 },
11278 },
11279};
11280
zhejiangaccbe492007-08-31 12:36:05 +020011281static struct hda_input_mux alc262_HP_D7000_capture_source = {
11282 .num_items = 4,
11283 .items = {
11284 { "Mic", 0x0 },
11285 { "Front Mic", 0x2 },
11286 { "Line", 0x1 },
11287 { "CD", 0x4 },
11288 },
11289};
11290
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011291/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011292static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11293{
11294 struct alc_spec *spec = codec->spec;
11295 unsigned int mute;
11296
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011297 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011298 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11299 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011300 spec->sense_updated = 1;
11301 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011302 /* unmute internal speaker only if both HPs are unplugged and
11303 * master switch is on
11304 */
11305 if (spec->jack_present)
11306 mute = HDA_AMP_MUTE;
11307 else
Takashi Iwai834be882006-03-01 14:16:17 +010011308 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011309 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11310 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011311}
11312
11313/* unsolicited event for HP jack sensing */
11314static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11315 unsigned int res)
11316{
11317 if ((res >> 26) != ALC_HP_EVENT)
11318 return;
11319 alc262_fujitsu_automute(codec, 1);
11320}
11321
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011322static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11323{
11324 alc262_fujitsu_automute(codec, 1);
11325}
11326
Takashi Iwai834be882006-03-01 14:16:17 +010011327/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011328static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11329 .ops = &snd_hda_bind_vol,
11330 .values = {
11331 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11332 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11333 0
11334 },
11335};
Takashi Iwai834be882006-03-01 14:16:17 +010011336
Jiang zhe0e31daf2008-03-20 12:12:39 +010011337/* mute/unmute internal speaker according to the hp jack and mute state */
11338static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11339{
11340 struct alc_spec *spec = codec->spec;
11341 unsigned int mute;
11342
11343 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011344 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011345 spec->sense_updated = 1;
11346 }
11347 if (spec->jack_present) {
11348 /* mute internal speaker */
11349 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11350 HDA_AMP_MUTE, HDA_AMP_MUTE);
11351 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11352 HDA_AMP_MUTE, HDA_AMP_MUTE);
11353 } else {
11354 /* unmute internal speaker if necessary */
11355 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11356 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11357 HDA_AMP_MUTE, mute);
11358 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11359 HDA_AMP_MUTE, mute);
11360 }
11361}
11362
11363/* unsolicited event for HP jack sensing */
11364static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11365 unsigned int res)
11366{
11367 if ((res >> 26) != ALC_HP_EVENT)
11368 return;
11369 alc262_lenovo_3000_automute(codec, 1);
11370}
11371
Takashi Iwai8de56b72009-07-24 16:51:47 +020011372static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11373 int dir, int idx, long *valp)
11374{
11375 int i, change = 0;
11376
11377 for (i = 0; i < 2; i++, valp++)
11378 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11379 HDA_AMP_MUTE,
11380 *valp ? 0 : HDA_AMP_MUTE);
11381 return change;
11382}
11383
Takashi Iwai834be882006-03-01 14:16:17 +010011384/* bind hp and internal speaker mute (with plug check) */
11385static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11386 struct snd_ctl_elem_value *ucontrol)
11387{
11388 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11389 long *valp = ucontrol->value.integer.value;
11390 int change;
11391
Takashi Iwai8de56b72009-07-24 16:51:47 +020011392 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11393 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011394 if (change)
11395 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011396 return change;
11397}
11398
11399static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011400 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011401 {
11402 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11403 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011404 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011405 .info = snd_hda_mixer_amp_switch_info,
11406 .get = snd_hda_mixer_amp_switch_get,
11407 .put = alc262_fujitsu_master_sw_put,
11408 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11409 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011410 {
11411 .iface = NID_MAPPING,
11412 .name = "Master Playback Switch",
11413 .private_value = 0x1b,
11414 },
Takashi Iwai834be882006-03-01 14:16:17 +010011415 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11416 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11417 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011420 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11421 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11422 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011423 { } /* end */
11424};
11425
Jiang zhe0e31daf2008-03-20 12:12:39 +010011426/* bind hp and internal speaker mute (with plug check) */
11427static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11428 struct snd_ctl_elem_value *ucontrol)
11429{
11430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11431 long *valp = ucontrol->value.integer.value;
11432 int change;
11433
Takashi Iwai8de56b72009-07-24 16:51:47 +020011434 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011435 if (change)
11436 alc262_lenovo_3000_automute(codec, 0);
11437 return change;
11438}
11439
11440static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11441 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11442 {
11443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11444 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011445 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011446 .info = snd_hda_mixer_amp_switch_info,
11447 .get = snd_hda_mixer_amp_switch_get,
11448 .put = alc262_lenovo_3000_master_sw_put,
11449 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11450 },
11451 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11452 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11453 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11454 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11455 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11456 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11457 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11458 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11459 { } /* end */
11460};
11461
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011462static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11463 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011464 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11467 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11468 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11469 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11470 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11471 { } /* end */
11472};
11473
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011474/* additional init verbs for Benq laptops */
11475static struct hda_verb alc262_EAPD_verbs[] = {
11476 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11477 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11478 {}
11479};
11480
Kailang Yang83c34212007-07-05 11:43:05 +020011481static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11484
11485 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11486 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11487 {}
11488};
11489
Tobin Davisf651b502007-10-26 12:40:47 +020011490/* Samsung Q1 Ultra Vista model setup */
11491static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011492 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11493 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11495 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11496 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011497 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011498 { } /* end */
11499};
11500
11501static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011502 /* output mixer */
11503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11506 /* speaker */
11507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11509 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11510 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11511 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11514 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11515 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11516 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11517 /* internal mic */
11518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11520 /* ADC, choose mic */
11521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11524 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11525 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11526 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11527 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11528 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11529 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11530 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011531 {}
11532};
11533
Tobin Davisf651b502007-10-26 12:40:47 +020011534/* mute/unmute internal speaker according to the hp jack and mute state */
11535static void alc262_ultra_automute(struct hda_codec *codec)
11536{
11537 struct alc_spec *spec = codec->spec;
11538 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011539
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011540 mute = 0;
11541 /* auto-mute only when HP is used as HP */
11542 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011543 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011544 if (spec->jack_present)
11545 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011546 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011547 /* mute/unmute internal speaker */
11548 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11549 HDA_AMP_MUTE, mute);
11550 /* mute/unmute HP */
11551 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11552 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011553}
11554
11555/* unsolicited event for HP jack sensing */
11556static void alc262_ultra_unsol_event(struct hda_codec *codec,
11557 unsigned int res)
11558{
11559 if ((res >> 26) != ALC880_HP_EVENT)
11560 return;
11561 alc262_ultra_automute(codec);
11562}
11563
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011564static struct hda_input_mux alc262_ultra_capture_source = {
11565 .num_items = 2,
11566 .items = {
11567 { "Mic", 0x1 },
11568 { "Headphone", 0x7 },
11569 },
11570};
11571
11572static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11573 struct snd_ctl_elem_value *ucontrol)
11574{
11575 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11576 struct alc_spec *spec = codec->spec;
11577 int ret;
11578
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011579 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011580 if (!ret)
11581 return 0;
11582 /* reprogram the HP pin as mic or HP according to the input source */
11583 snd_hda_codec_write_cache(codec, 0x15, 0,
11584 AC_VERB_SET_PIN_WIDGET_CONTROL,
11585 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11586 alc262_ultra_automute(codec); /* mute/unmute HP */
11587 return ret;
11588}
11589
11590static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11591 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11592 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11593 {
11594 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11595 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011596 .info = alc_mux_enum_info,
11597 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011598 .put = alc262_ultra_mux_enum_put,
11599 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011600 {
11601 .iface = NID_MAPPING,
11602 .name = "Capture Source",
11603 .private_value = 0x15,
11604 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011605 { } /* end */
11606};
11607
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011608/* We use two mixers depending on the output pin; 0x16 is a mono output
11609 * and thus it's bound with a different mixer.
11610 * This function returns which mixer amp should be used.
11611 */
11612static int alc262_check_volbit(hda_nid_t nid)
11613{
11614 if (!nid)
11615 return 0;
11616 else if (nid == 0x16)
11617 return 2;
11618 else
11619 return 1;
11620}
11621
11622static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11623 const char *pfx, int *vbits)
11624{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011625 unsigned long val;
11626 int vbit;
11627
11628 vbit = alc262_check_volbit(nid);
11629 if (!vbit)
11630 return 0;
11631 if (*vbits & vbit) /* a volume control for this mixer already there */
11632 return 0;
11633 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011634 if (vbit == 2)
11635 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11636 else
11637 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011638 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011639}
11640
11641static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11642 const char *pfx)
11643{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011644 unsigned long val;
11645
11646 if (!nid)
11647 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011648 if (nid == 0x16)
11649 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11650 else
11651 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011652 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011653}
11654
Kailang Yangdf694da2005-12-05 19:42:22 +010011655/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011656static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11657 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011658{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011659 const char *pfx;
11660 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011661 int err;
11662
11663 spec->multiout.num_dacs = 1; /* only use one dac */
11664 spec->multiout.dac_nids = spec->private_dac_nids;
11665 spec->multiout.dac_nids[0] = 2;
11666
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011667 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11668 pfx = "Master";
11669 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11670 pfx = "Speaker";
11671 else
11672 pfx = "Front";
11673 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11674 if (err < 0)
11675 return err;
11676 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11677 if (err < 0)
11678 return err;
11679 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11680 if (err < 0)
11681 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011682
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011683 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11684 alc262_check_volbit(cfg->speaker_pins[0]) |
11685 alc262_check_volbit(cfg->hp_pins[0]);
11686 if (vbits == 1 || vbits == 2)
11687 pfx = "Master"; /* only one mixer is used */
11688 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11689 pfx = "Speaker";
11690 else
11691 pfx = "Front";
11692 vbits = 0;
11693 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11694 if (err < 0)
11695 return err;
11696 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11697 &vbits);
11698 if (err < 0)
11699 return err;
11700 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11701 &vbits);
11702 if (err < 0)
11703 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011704 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011705}
11706
Takashi Iwai05f5f472009-08-25 13:10:18 +020011707#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011708 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011709
11710/*
11711 * generic initialization of ADC, input mixers and output mixers
11712 */
11713static struct hda_verb alc262_volume_init_verbs[] = {
11714 /*
11715 * Unmute ADC0-2 and set the default input to mic-in
11716 */
11717 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11719 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11720 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11721 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11722 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11723
Takashi Iwaicb53c622007-08-10 17:21:45 +020011724 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011725 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011726 * Note: PASD motherboards uses the Line In 2 as the input for
11727 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011728 */
11729 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011735
11736 /*
11737 * Set up output mixers (0x0c - 0x0f)
11738 */
11739 /* set vol=0 to output mixers */
11740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011743
Kailang Yangdf694da2005-12-05 19:42:22 +010011744 /* set up input amps for analog loopback */
11745 /* Amp Indices: DAC = 0, mixer = 1 */
11746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11748 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11749 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11752
11753 /* FIXME: use matrix-type input source selection */
11754 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11755 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11760 /* Input mixer2 */
11761 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11762 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11765 /* Input mixer3 */
11766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11770
11771 { }
11772};
11773
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011774static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11775 /*
11776 * Unmute ADC0-2 and set the default input to mic-in
11777 */
11778 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11779 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11780 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11782 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11783 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11784
Takashi Iwaicb53c622007-08-10 17:21:45 +020011785 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011786 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011787 * Note: PASD motherboards uses the Line In 2 as the input for
11788 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011789 */
11790 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011798
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011799 /*
11800 * Set up output mixers (0x0c - 0x0e)
11801 */
11802 /* set vol=0 to output mixers */
11803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11804 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11805 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11806
11807 /* set up input amps for analog loopback */
11808 /* Amp Indices: DAC = 0, mixer = 1 */
11809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11813 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11814 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11815
Takashi Iwaice875f02008-01-28 18:17:43 +010011816 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11818 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11819
11820 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11822
11823 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11824 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11825
11826 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11827 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11828 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11829 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11830 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11831
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011832 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011833 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11834 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011835 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011836 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11837 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11838
11839
11840 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011841 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11842 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011843 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011844 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11845 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11848 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11849 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11850 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11851 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011852 /* Input mixer2 */
11853 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011854 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11855 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11856 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011862 /* Input mixer3 */
11863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11865 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11866 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011872
Takashi Iwaice875f02008-01-28 18:17:43 +010011873 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11874
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011875 { }
11876};
11877
Kailang Yangcd7509a2007-01-26 18:33:17 +010011878static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11879 /*
11880 * Unmute ADC0-2 and set the default input to mic-in
11881 */
11882 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11884 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11885 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11886 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11888
Takashi Iwaicb53c622007-08-10 17:21:45 +020011889 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011890 * mixer widget
11891 * Note: PASD motherboards uses the Line In 2 as the input for front
11892 * panel mic (mic 2)
11893 */
11894 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011903 /*
11904 * Set up output mixers (0x0c - 0x0e)
11905 */
11906 /* set vol=0 to output mixers */
11907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11909 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11910
11911 /* set up input amps for analog loopback */
11912 /* Amp Indices: DAC = 0, mixer = 1 */
11913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11919
11920
11921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11922 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11923 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11924 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11925 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11926 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11927 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11928
11929 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11931
11932 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11933 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11934
11935 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11936 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11937 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11938 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11939 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11940 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11941
11942 /* FIXME: use matrix-type input source selection */
11943 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11944 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11946 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11947 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11948 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11949 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11950 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11951 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11952 /* Input mixer2 */
11953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11954 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11956 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11957 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11958 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11959 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11960 /* Input mixer3 */
11961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11963 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11966 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11968
Takashi Iwaice875f02008-01-28 18:17:43 +010011969 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11970
Kailang Yangcd7509a2007-01-26 18:33:17 +010011971 { }
11972};
11973
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011974static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11975
11976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11978 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11979
11980 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11981 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11982 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11983 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11984
11985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11986 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11987 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11988 {}
11989};
11990
11991
Takashi Iwaicb53c622007-08-10 17:21:45 +020011992#ifdef CONFIG_SND_HDA_POWER_SAVE
11993#define alc262_loopbacks alc880_loopbacks
11994#endif
11995
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011996/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011997#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11998#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11999#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12000#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12001
12002/*
12003 * BIOS auto configuration
12004 */
12005static int alc262_parse_auto_config(struct hda_codec *codec)
12006{
12007 struct alc_spec *spec = codec->spec;
12008 int err;
12009 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12010
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012011 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12012 alc262_ignore);
12013 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012014 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012015 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012016 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012017 spec->multiout.max_channels = 2;
12018 spec->no_analog = 1;
12019 goto dig_only;
12020 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012021 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012022 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012023 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12024 if (err < 0)
12025 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012026 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012027 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012028 return err;
12029
12030 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12031
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012032 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012033 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012034 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012035 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012036 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012037 if (spec->autocfg.dig_in_pin)
12038 spec->dig_in_nid = ALC262_DIGIN_NID;
12039
Takashi Iwai603c4012008-07-30 15:01:44 +020012040 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012041 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012042
Takashi Iwaid88897e2008-10-31 15:01:37 +010012043 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012044 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012045 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012046
Takashi Iwai776e1842007-08-29 15:07:11 +020012047 err = alc_auto_add_mic_boost(codec);
12048 if (err < 0)
12049 return err;
12050
Kailang Yang6227cdc2010-02-25 08:36:52 +010012051 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012052
Kailang Yangdf694da2005-12-05 19:42:22 +010012053 return 1;
12054}
12055
12056#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12057#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12058#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012059#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012060
12061
12062/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012063static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012064{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012065 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012066 alc262_auto_init_multi_out(codec);
12067 alc262_auto_init_hp_out(codec);
12068 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012069 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012070 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012071 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012072}
12073
12074/*
12075 * configuration and preset
12076 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012077static const char *alc262_models[ALC262_MODEL_LAST] = {
12078 [ALC262_BASIC] = "basic",
12079 [ALC262_HIPPO] = "hippo",
12080 [ALC262_HIPPO_1] = "hippo_1",
12081 [ALC262_FUJITSU] = "fujitsu",
12082 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012083 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012084 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012085 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012086 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012087 [ALC262_BENQ_T31] = "benq-t31",
12088 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012089 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012090 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012091 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012092 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012093 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012094 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012095 [ALC262_AUTO] = "auto",
12096};
12097
12098static struct snd_pci_quirk alc262_cfg_tbl[] = {
12099 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012100 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012101 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12102 ALC262_HP_BPC),
12103 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12104 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012105 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12106 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012107 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012108 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012109 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012110 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012111 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012112 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012113 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012114 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012115 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12116 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12117 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012118 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12119 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012120 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012121 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012122 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012123 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012124 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012125 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012126 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012127 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012128#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012129 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12130 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012131#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012132 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012133 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012134 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012135 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012136 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012137 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012138 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12139 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012140 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012141 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012142 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012143 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012144 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012145 {}
12146};
12147
12148static struct alc_config_preset alc262_presets[] = {
12149 [ALC262_BASIC] = {
12150 .mixers = { alc262_base_mixer },
12151 .init_verbs = { alc262_init_verbs },
12152 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12153 .dac_nids = alc262_dac_nids,
12154 .hp_nid = 0x03,
12155 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12156 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012157 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012158 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012159 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012160 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012161 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012162 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12163 .dac_nids = alc262_dac_nids,
12164 .hp_nid = 0x03,
12165 .dig_out_nid = ALC262_DIGOUT_NID,
12166 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12167 .channel_mode = alc262_modes,
12168 .input_mux = &alc262_capture_source,
12169 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012170 .setup = alc262_hippo_setup,
12171 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012172 },
12173 [ALC262_HIPPO_1] = {
12174 .mixers = { alc262_hippo1_mixer },
12175 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12176 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12177 .dac_nids = alc262_dac_nids,
12178 .hp_nid = 0x02,
12179 .dig_out_nid = ALC262_DIGOUT_NID,
12180 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12181 .channel_mode = alc262_modes,
12182 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012183 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012184 .setup = alc262_hippo1_setup,
12185 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012186 },
Takashi Iwai834be882006-03-01 14:16:17 +010012187 [ALC262_FUJITSU] = {
12188 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012189 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12190 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012191 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12192 .dac_nids = alc262_dac_nids,
12193 .hp_nid = 0x03,
12194 .dig_out_nid = ALC262_DIGOUT_NID,
12195 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12196 .channel_mode = alc262_modes,
12197 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012198 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012199 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012200 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012201 [ALC262_HP_BPC] = {
12202 .mixers = { alc262_HP_BPC_mixer },
12203 .init_verbs = { alc262_HP_BPC_init_verbs },
12204 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12205 .dac_nids = alc262_dac_nids,
12206 .hp_nid = 0x03,
12207 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12208 .channel_mode = alc262_modes,
12209 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012210 .unsol_event = alc262_hp_bpc_unsol_event,
12211 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012212 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012213 [ALC262_HP_BPC_D7000_WF] = {
12214 .mixers = { alc262_HP_BPC_WildWest_mixer },
12215 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12216 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12217 .dac_nids = alc262_dac_nids,
12218 .hp_nid = 0x03,
12219 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12220 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012221 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012222 .unsol_event = alc262_hp_wildwest_unsol_event,
12223 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012224 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012225 [ALC262_HP_BPC_D7000_WL] = {
12226 .mixers = { alc262_HP_BPC_WildWest_mixer,
12227 alc262_HP_BPC_WildWest_option_mixer },
12228 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12229 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12230 .dac_nids = alc262_dac_nids,
12231 .hp_nid = 0x03,
12232 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12233 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012234 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012235 .unsol_event = alc262_hp_wildwest_unsol_event,
12236 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012237 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012238 [ALC262_HP_TC_T5735] = {
12239 .mixers = { alc262_hp_t5735_mixer },
12240 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12241 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12242 .dac_nids = alc262_dac_nids,
12243 .hp_nid = 0x03,
12244 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12245 .channel_mode = alc262_modes,
12246 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012247 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012248 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012249 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012250 },
12251 [ALC262_HP_RP5700] = {
12252 .mixers = { alc262_hp_rp5700_mixer },
12253 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12254 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12255 .dac_nids = alc262_dac_nids,
12256 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12257 .channel_mode = alc262_modes,
12258 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012259 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012260 [ALC262_BENQ_ED8] = {
12261 .mixers = { alc262_base_mixer },
12262 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12263 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12264 .dac_nids = alc262_dac_nids,
12265 .hp_nid = 0x03,
12266 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12267 .channel_mode = alc262_modes,
12268 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012269 },
Kailang Yang272a5272007-05-14 11:00:38 +020012270 [ALC262_SONY_ASSAMD] = {
12271 .mixers = { alc262_sony_mixer },
12272 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12273 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12274 .dac_nids = alc262_dac_nids,
12275 .hp_nid = 0x02,
12276 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12277 .channel_mode = alc262_modes,
12278 .input_mux = &alc262_capture_source,
12279 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012280 .setup = alc262_hippo_setup,
12281 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012282 },
12283 [ALC262_BENQ_T31] = {
12284 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012285 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12286 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012287 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12288 .dac_nids = alc262_dac_nids,
12289 .hp_nid = 0x03,
12290 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12291 .channel_mode = alc262_modes,
12292 .input_mux = &alc262_capture_source,
12293 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012294 .setup = alc262_hippo_setup,
12295 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012296 },
Tobin Davisf651b502007-10-26 12:40:47 +020012297 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012298 .mixers = { alc262_ultra_mixer },
12299 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012300 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012301 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12302 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012303 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12304 .channel_mode = alc262_modes,
12305 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012306 .adc_nids = alc262_adc_nids, /* ADC0 */
12307 .capsrc_nids = alc262_capsrc_nids,
12308 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012309 .unsol_event = alc262_ultra_unsol_event,
12310 .init_hook = alc262_ultra_automute,
12311 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012312 [ALC262_LENOVO_3000] = {
12313 .mixers = { alc262_lenovo_3000_mixer },
12314 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012315 alc262_lenovo_3000_unsol_verbs,
12316 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012317 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12318 .dac_nids = alc262_dac_nids,
12319 .hp_nid = 0x03,
12320 .dig_out_nid = ALC262_DIGOUT_NID,
12321 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12322 .channel_mode = alc262_modes,
12323 .input_mux = &alc262_fujitsu_capture_source,
12324 .unsol_event = alc262_lenovo_3000_unsol_event,
12325 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012326 [ALC262_NEC] = {
12327 .mixers = { alc262_nec_mixer },
12328 .init_verbs = { alc262_nec_verbs },
12329 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12330 .dac_nids = alc262_dac_nids,
12331 .hp_nid = 0x03,
12332 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12333 .channel_mode = alc262_modes,
12334 .input_mux = &alc262_capture_source,
12335 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012336 [ALC262_TOSHIBA_S06] = {
12337 .mixers = { alc262_toshiba_s06_mixer },
12338 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12339 alc262_eapd_verbs },
12340 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12341 .capsrc_nids = alc262_dmic_capsrc_nids,
12342 .dac_nids = alc262_dac_nids,
12343 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012344 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012345 .dig_out_nid = ALC262_DIGOUT_NID,
12346 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12347 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012348 .unsol_event = alc_sku_unsol_event,
12349 .setup = alc262_toshiba_s06_setup,
12350 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012351 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012352 [ALC262_TOSHIBA_RX1] = {
12353 .mixers = { alc262_toshiba_rx1_mixer },
12354 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12355 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12356 .dac_nids = alc262_dac_nids,
12357 .hp_nid = 0x03,
12358 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12359 .channel_mode = alc262_modes,
12360 .input_mux = &alc262_capture_source,
12361 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012362 .setup = alc262_hippo_setup,
12363 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012364 },
Tony Vroonba340e82009-02-02 19:01:30 +000012365 [ALC262_TYAN] = {
12366 .mixers = { alc262_tyan_mixer },
12367 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12368 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12369 .dac_nids = alc262_dac_nids,
12370 .hp_nid = 0x02,
12371 .dig_out_nid = ALC262_DIGOUT_NID,
12372 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12373 .channel_mode = alc262_modes,
12374 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012375 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012376 .setup = alc262_tyan_setup,
12377 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012378 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012379};
12380
12381static int patch_alc262(struct hda_codec *codec)
12382{
12383 struct alc_spec *spec;
12384 int board_config;
12385 int err;
12386
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012387 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012388 if (spec == NULL)
12389 return -ENOMEM;
12390
12391 codec->spec = spec;
12392#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012393 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12394 * under-run
12395 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012396 {
12397 int tmp;
12398 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12399 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12400 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12401 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12402 }
12403#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012404 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012405
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012406 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12407
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012408 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12409 alc262_models,
12410 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012411
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012412 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012413 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12414 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012415 board_config = ALC262_AUTO;
12416 }
12417
12418 if (board_config == ALC262_AUTO) {
12419 /* automatic parse from the BIOS config */
12420 err = alc262_parse_auto_config(codec);
12421 if (err < 0) {
12422 alc_free(codec);
12423 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012424 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012425 printk(KERN_INFO
12426 "hda_codec: Cannot set up configuration "
12427 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012428 board_config = ALC262_BASIC;
12429 }
12430 }
12431
Takashi Iwai07eba612009-02-19 08:06:35 +010012432 if (!spec->no_analog) {
12433 err = snd_hda_attach_beep_device(codec, 0x1);
12434 if (err < 0) {
12435 alc_free(codec);
12436 return err;
12437 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012438 }
12439
Kailang Yangdf694da2005-12-05 19:42:22 +010012440 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012441 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012442
Kailang Yangdf694da2005-12-05 19:42:22 +010012443 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12444 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012445
Kailang Yangdf694da2005-12-05 19:42:22 +010012446 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12447 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12448
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012449 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012450 int i;
12451 /* check whether the digital-mic has to be supported */
12452 for (i = 0; i < spec->input_mux->num_items; i++) {
12453 if (spec->input_mux->items[i].index >= 9)
12454 break;
12455 }
12456 if (i < spec->input_mux->num_items) {
12457 /* use only ADC0 */
12458 spec->adc_nids = alc262_dmic_adc_nids;
12459 spec->num_adc_nids = 1;
12460 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012461 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012462 /* all analog inputs */
12463 /* check whether NID 0x07 is valid */
12464 unsigned int wcap = get_wcaps(codec, 0x07);
12465
12466 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012467 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012468 if (wcap != AC_WID_AUD_IN) {
12469 spec->adc_nids = alc262_adc_nids_alt;
12470 spec->num_adc_nids =
12471 ARRAY_SIZE(alc262_adc_nids_alt);
12472 spec->capsrc_nids = alc262_capsrc_nids_alt;
12473 } else {
12474 spec->adc_nids = alc262_adc_nids;
12475 spec->num_adc_nids =
12476 ARRAY_SIZE(alc262_adc_nids);
12477 spec->capsrc_nids = alc262_capsrc_nids;
12478 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012479 }
12480 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012481 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012482 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010012483 if (!spec->no_analog && spec->cdefine.enable_pcbeep)
Takashi Iwai07eba612009-02-19 08:06:35 +010012484 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012485
Takashi Iwai2134ea42008-01-10 16:53:55 +010012486 spec->vmaster_nid = 0x0c;
12487
Kailang Yangdf694da2005-12-05 19:42:22 +010012488 codec->patch_ops = alc_patch_ops;
12489 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012490 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012491#ifdef CONFIG_SND_HDA_POWER_SAVE
12492 if (!spec->loopback.amplist)
12493 spec->loopback.amplist = alc262_loopbacks;
12494#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012495
Kailang Yangdf694da2005-12-05 19:42:22 +010012496 return 0;
12497}
12498
Kailang Yangdf694da2005-12-05 19:42:22 +010012499/*
Kailang Yanga361d842007-06-05 12:30:55 +020012500 * ALC268 channel source setting (2 channel)
12501 */
12502#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12503#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012504
Kailang Yanga361d842007-06-05 12:30:55 +020012505static hda_nid_t alc268_dac_nids[2] = {
12506 /* front, hp */
12507 0x02, 0x03
12508};
12509
12510static hda_nid_t alc268_adc_nids[2] = {
12511 /* ADC0-1 */
12512 0x08, 0x07
12513};
12514
12515static hda_nid_t alc268_adc_nids_alt[1] = {
12516 /* ADC0 */
12517 0x08
12518};
12519
Takashi Iwaie1406342008-02-11 18:32:32 +010012520static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12521
Kailang Yanga361d842007-06-05 12:30:55 +020012522static struct snd_kcontrol_new alc268_base_mixer[] = {
12523 /* output mixer control */
12524 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12525 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12526 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012528 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12529 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12530 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012531 { }
12532};
12533
Takashi Iwai42171c12009-05-08 14:11:43 +020012534static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12535 /* output mixer control */
12536 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12537 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12538 ALC262_HIPPO_MASTER_SWITCH,
12539 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12540 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12541 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12542 { }
12543};
12544
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012545/* bind Beep switches of both NID 0x0f and 0x10 */
12546static struct hda_bind_ctls alc268_bind_beep_sw = {
12547 .ops = &snd_hda_bind_sw,
12548 .values = {
12549 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12550 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12551 0
12552 },
12553};
12554
12555static struct snd_kcontrol_new alc268_beep_mixer[] = {
12556 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12557 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12558 { }
12559};
12560
Kailang Yangd1a991a2007-08-15 16:21:59 +020012561static struct hda_verb alc268_eapd_verbs[] = {
12562 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12563 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12564 { }
12565};
12566
Takashi Iwaid2738092007-08-16 14:59:45 +020012567/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012568static struct hda_verb alc268_toshiba_verbs[] = {
12569 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12570 { } /* end */
12571};
12572
12573/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012574/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012575static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12576 .ops = &snd_hda_bind_vol,
12577 .values = {
12578 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12579 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12580 0
12581 },
12582};
12583
Takashi Iwai889c4392007-08-23 18:56:52 +020012584/* mute/unmute internal speaker according to the hp jack and mute state */
12585static void alc268_acer_automute(struct hda_codec *codec, int force)
12586{
12587 struct alc_spec *spec = codec->spec;
12588 unsigned int mute;
12589
12590 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012591 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012592 spec->sense_updated = 1;
12593 }
12594 if (spec->jack_present)
12595 mute = HDA_AMP_MUTE; /* mute internal speaker */
12596 else /* unmute internal speaker if necessary */
12597 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12598 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12599 HDA_AMP_MUTE, mute);
12600}
12601
12602
12603/* bind hp and internal speaker mute (with plug check) */
12604static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12605 struct snd_ctl_elem_value *ucontrol)
12606{
12607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12608 long *valp = ucontrol->value.integer.value;
12609 int change;
12610
Takashi Iwai8de56b72009-07-24 16:51:47 +020012611 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012612 if (change)
12613 alc268_acer_automute(codec, 0);
12614 return change;
12615}
Takashi Iwaid2738092007-08-16 14:59:45 +020012616
Kailang Yang8ef355d2008-08-26 13:10:22 +020012617static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12618 /* output mixer control */
12619 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12620 {
12621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12622 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012623 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012624 .info = snd_hda_mixer_amp_switch_info,
12625 .get = snd_hda_mixer_amp_switch_get,
12626 .put = alc268_acer_master_sw_put,
12627 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12628 },
12629 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12630 { }
12631};
12632
Takashi Iwaid2738092007-08-16 14:59:45 +020012633static struct snd_kcontrol_new alc268_acer_mixer[] = {
12634 /* output mixer control */
12635 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12636 {
12637 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12638 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012639 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012640 .info = snd_hda_mixer_amp_switch_info,
12641 .get = snd_hda_mixer_amp_switch_get,
12642 .put = alc268_acer_master_sw_put,
12643 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12644 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012645 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12646 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12647 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012648 { }
12649};
12650
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012651static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12652 /* output mixer control */
12653 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12654 {
12655 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12656 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012657 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012658 .info = snd_hda_mixer_amp_switch_info,
12659 .get = snd_hda_mixer_amp_switch_get,
12660 .put = alc268_acer_master_sw_put,
12661 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12662 },
12663 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12664 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12665 { }
12666};
12667
Kailang Yang8ef355d2008-08-26 13:10:22 +020012668static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12669 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12670 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12671 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12672 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12673 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12675 { }
12676};
12677
Takashi Iwaid2738092007-08-16 14:59:45 +020012678static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012679 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12680 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012683 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12684 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012685 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12686 { }
12687};
12688
12689/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012690#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012691#define alc268_toshiba_setup alc262_hippo_setup
12692#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012693
12694static void alc268_acer_unsol_event(struct hda_codec *codec,
12695 unsigned int res)
12696{
Takashi Iwai889c4392007-08-23 18:56:52 +020012697 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012698 return;
12699 alc268_acer_automute(codec, 1);
12700}
12701
Takashi Iwai889c4392007-08-23 18:56:52 +020012702static void alc268_acer_init_hook(struct hda_codec *codec)
12703{
12704 alc268_acer_automute(codec, 1);
12705}
12706
Kailang Yang8ef355d2008-08-26 13:10:22 +020012707/* toggle speaker-output according to the hp-jack state */
12708static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12709{
12710 unsigned int present;
12711 unsigned char bits;
12712
Wu Fengguang864f92b2009-11-18 12:38:02 +080012713 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012714 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012715 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012716 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012717 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012718 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012719}
12720
Kailang Yang8ef355d2008-08-26 13:10:22 +020012721static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12722 unsigned int res)
12723{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012724 switch (res >> 26) {
12725 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012726 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012727 break;
12728 case ALC880_MIC_EVENT:
12729 alc_mic_automute(codec);
12730 break;
12731 }
12732}
12733
12734static void alc268_acer_lc_setup(struct hda_codec *codec)
12735{
12736 struct alc_spec *spec = codec->spec;
12737 spec->ext_mic.pin = 0x18;
12738 spec->ext_mic.mux_idx = 0;
12739 spec->int_mic.pin = 0x12;
12740 spec->int_mic.mux_idx = 6;
12741 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012742}
12743
12744static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12745{
12746 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012747 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012748}
12749
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012750static struct snd_kcontrol_new alc268_dell_mixer[] = {
12751 /* output mixer control */
12752 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12753 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12754 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12755 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12756 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12757 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12758 { }
12759};
12760
12761static struct hda_verb alc268_dell_verbs[] = {
12762 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12763 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12764 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012765 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012766 { }
12767};
12768
12769/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012770static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012771{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012772 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012773
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012774 spec->autocfg.hp_pins[0] = 0x15;
12775 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012776 spec->ext_mic.pin = 0x18;
12777 spec->ext_mic.mux_idx = 0;
12778 spec->int_mic.pin = 0x19;
12779 spec->int_mic.mux_idx = 1;
12780 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012781}
12782
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012783static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12784 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12785 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12786 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12787 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12788 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12789 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12790 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12791 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12792 { }
12793};
12794
12795static struct hda_verb alc267_quanta_il1_verbs[] = {
12796 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12797 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12798 { }
12799};
12800
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012801static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012802{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012803 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012804 spec->autocfg.hp_pins[0] = 0x15;
12805 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012806 spec->ext_mic.pin = 0x18;
12807 spec->ext_mic.mux_idx = 0;
12808 spec->int_mic.pin = 0x19;
12809 spec->int_mic.mux_idx = 1;
12810 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012811}
12812
Kailang Yanga361d842007-06-05 12:30:55 +020012813/*
12814 * generic initialization of ADC, input mixers and output mixers
12815 */
12816static struct hda_verb alc268_base_init_verbs[] = {
12817 /* Unmute DAC0-1 and set vol = 0 */
12818 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012819 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012820
12821 /*
12822 * Set up output mixers (0x0c - 0x0e)
12823 */
12824 /* set vol=0 to output mixers */
12825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012826 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12827
12828 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12829 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12830
12831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12834 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12835 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12836 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12837 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12838 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12839
12840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12842 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12843 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012844 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012845
12846 /* set PCBEEP vol = 0, mute connections */
12847 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12849 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012850
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012851 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012852
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012853 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12854 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12855 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012857
Kailang Yanga361d842007-06-05 12:30:55 +020012858 { }
12859};
12860
12861/*
12862 * generic initialization of ADC, input mixers and output mixers
12863 */
12864static struct hda_verb alc268_volume_init_verbs[] = {
12865 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012866 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12867 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012868
12869 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12871 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12872 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12873 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12874
Kailang Yanga361d842007-06-05 12:30:55 +020012875 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012876 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12877 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12878
12879 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012880 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012881
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012882 /* set PCBEEP vol = 0, mute connections */
12883 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12884 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12885 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012886
12887 { }
12888};
12889
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012890static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12891 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12892 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12893 { } /* end */
12894};
12895
Kailang Yanga361d842007-06-05 12:30:55 +020012896static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12897 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12898 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012899 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012900 { } /* end */
12901};
12902
12903static struct snd_kcontrol_new alc268_capture_mixer[] = {
12904 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12905 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12906 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12907 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012908 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012909 { } /* end */
12910};
12911
12912static struct hda_input_mux alc268_capture_source = {
12913 .num_items = 4,
12914 .items = {
12915 { "Mic", 0x0 },
12916 { "Front Mic", 0x1 },
12917 { "Line", 0x2 },
12918 { "CD", 0x3 },
12919 },
12920};
12921
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012922static struct hda_input_mux alc268_acer_capture_source = {
12923 .num_items = 3,
12924 .items = {
12925 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012926 { "Internal Mic", 0x1 },
12927 { "Line", 0x2 },
12928 },
12929};
12930
12931static struct hda_input_mux alc268_acer_dmic_capture_source = {
12932 .num_items = 3,
12933 .items = {
12934 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012935 { "Internal Mic", 0x6 },
12936 { "Line", 0x2 },
12937 },
12938};
12939
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012940#ifdef CONFIG_SND_DEBUG
12941static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012942 /* Volume widgets */
12943 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12944 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12945 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12946 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12947 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12948 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12949 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12950 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12951 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12952 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12953 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12954 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12955 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012956 /* The below appears problematic on some hardwares */
12957 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012958 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12959 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12960 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12961 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12962
12963 /* Modes for retasking pin widgets */
12964 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12965 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12966 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12967 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12968
12969 /* Controls for GPIO pins, assuming they are configured as outputs */
12970 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12971 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12972 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12973 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12974
12975 /* Switches to allow the digital SPDIF output pin to be enabled.
12976 * The ALC268 does not have an SPDIF input.
12977 */
12978 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12979
12980 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12981 * this output to turn on an external amplifier.
12982 */
12983 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12984 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12985
12986 { } /* end */
12987};
12988#endif
12989
Kailang Yanga361d842007-06-05 12:30:55 +020012990/* create input playback/capture controls for the given pin */
12991static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12992 const char *ctlname, int idx)
12993{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012994 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012995 int err;
12996
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012997 switch (nid) {
12998 case 0x14:
12999 case 0x16:
13000 dac = 0x02;
13001 break;
13002 case 0x15:
Kailang Yang531d8792010-04-09 10:57:33 +020013003 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013004 dac = 0x03;
13005 break;
13006 default:
13007 return 0;
13008 }
13009 if (spec->multiout.dac_nids[0] != dac &&
13010 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013011 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013012 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013013 HDA_OUTPUT));
13014 if (err < 0)
13015 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013016 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13017 }
13018
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013019 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013020 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013021 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013022 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013023 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013024 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013025 if (err < 0)
13026 return err;
13027 return 0;
13028}
13029
13030/* add playback controls from the parsed DAC table */
13031static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13032 const struct auto_pin_cfg *cfg)
13033{
13034 hda_nid_t nid;
13035 int err;
13036
Kailang Yanga361d842007-06-05 12:30:55 +020013037 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013038
13039 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013040 if (nid) {
13041 const char *name;
13042 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13043 name = "Speaker";
13044 else
13045 name = "Front";
13046 err = alc268_new_analog_output(spec, nid, name, 0);
13047 if (err < 0)
13048 return err;
13049 }
Kailang Yanga361d842007-06-05 12:30:55 +020013050
13051 nid = cfg->speaker_pins[0];
13052 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013053 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013054 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13055 if (err < 0)
13056 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013057 } else {
13058 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13059 if (err < 0)
13060 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013061 }
13062 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013063 if (nid) {
13064 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13065 if (err < 0)
13066 return err;
13067 }
Kailang Yanga361d842007-06-05 12:30:55 +020013068
13069 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13070 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013071 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013072 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013073 if (err < 0)
13074 return err;
13075 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013076 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013077}
13078
13079/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013080static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013081 const struct auto_pin_cfg *cfg)
13082{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013083 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013084}
13085
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013086static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13087 hda_nid_t nid, int pin_type)
13088{
13089 int idx;
13090
13091 alc_set_pin_output(codec, nid, pin_type);
13092 if (nid == 0x14 || nid == 0x16)
13093 idx = 0;
13094 else
13095 idx = 1;
13096 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13097}
13098
13099static void alc268_auto_init_multi_out(struct hda_codec *codec)
13100{
13101 struct alc_spec *spec = codec->spec;
13102 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13103 if (nid) {
13104 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13105 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13106 }
13107}
13108
13109static void alc268_auto_init_hp_out(struct hda_codec *codec)
13110{
13111 struct alc_spec *spec = codec->spec;
13112 hda_nid_t pin;
13113
13114 pin = spec->autocfg.hp_pins[0];
13115 if (pin)
13116 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13117 pin = spec->autocfg.speaker_pins[0];
13118 if (pin)
13119 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13120}
13121
Kailang Yanga361d842007-06-05 12:30:55 +020013122static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13123{
13124 struct alc_spec *spec = codec->spec;
13125 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13126 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13127 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13128 unsigned int dac_vol1, dac_vol2;
13129
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013130 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013131 snd_hda_codec_write(codec, speaker_nid, 0,
13132 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013133 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013134 snd_hda_codec_write(codec, 0x0f, 0,
13135 AC_VERB_SET_AMP_GAIN_MUTE,
13136 AMP_IN_UNMUTE(1));
13137 snd_hda_codec_write(codec, 0x10, 0,
13138 AC_VERB_SET_AMP_GAIN_MUTE,
13139 AMP_IN_UNMUTE(1));
13140 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013141 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013142 snd_hda_codec_write(codec, 0x0f, 0,
13143 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13144 snd_hda_codec_write(codec, 0x10, 0,
13145 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13146 }
13147
13148 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013149 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013150 dac_vol2 = AMP_OUT_ZERO;
13151 else if (line_nid == 0x15)
13152 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013153 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013154 dac_vol2 = AMP_OUT_ZERO;
13155 else if (hp_nid == 0x15)
13156 dac_vol1 = AMP_OUT_ZERO;
13157 if (line_nid != 0x16 || hp_nid != 0x16 ||
13158 spec->autocfg.line_out_pins[1] != 0x16 ||
13159 spec->autocfg.line_out_pins[2] != 0x16)
13160 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13161
13162 snd_hda_codec_write(codec, 0x02, 0,
13163 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13164 snd_hda_codec_write(codec, 0x03, 0,
13165 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13166}
13167
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013168/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013169#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13170#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013171#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013172#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13173
13174/*
13175 * BIOS auto configuration
13176 */
13177static int alc268_parse_auto_config(struct hda_codec *codec)
13178{
13179 struct alc_spec *spec = codec->spec;
13180 int err;
13181 static hda_nid_t alc268_ignore[] = { 0 };
13182
13183 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13184 alc268_ignore);
13185 if (err < 0)
13186 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013187 if (!spec->autocfg.line_outs) {
13188 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13189 spec->multiout.max_channels = 2;
13190 spec->no_analog = 1;
13191 goto dig_only;
13192 }
Kailang Yanga361d842007-06-05 12:30:55 +020013193 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013194 }
Kailang Yanga361d842007-06-05 12:30:55 +020013195 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13196 if (err < 0)
13197 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013198 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013199 if (err < 0)
13200 return err;
13201
13202 spec->multiout.max_channels = 2;
13203
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013204 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013205 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013206 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020013207 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013208 spec->dig_out_type = spec->autocfg.dig_out_type[0];
13209 }
Takashi Iwai603c4012008-07-30 15:01:44 +020013210 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013211 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013212
Takashi Iwai892981f2009-03-02 08:04:35 +010013213 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013214 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013215
Takashi Iwaid88897e2008-10-31 15:01:37 +010013216 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013217 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013218 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013219
Takashi Iwai776e1842007-08-29 15:07:11 +020013220 err = alc_auto_add_mic_boost(codec);
13221 if (err < 0)
13222 return err;
13223
Kailang Yang6227cdc2010-02-25 08:36:52 +010013224 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013225
Kailang Yanga361d842007-06-05 12:30:55 +020013226 return 1;
13227}
13228
Kailang Yanga361d842007-06-05 12:30:55 +020013229#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13230
13231/* init callback for auto-configuration model -- overriding the default init */
13232static void alc268_auto_init(struct hda_codec *codec)
13233{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013234 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013235 alc268_auto_init_multi_out(codec);
13236 alc268_auto_init_hp_out(codec);
13237 alc268_auto_init_mono_speaker_out(codec);
13238 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013239 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013240 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013241}
13242
13243/*
13244 * configuration and preset
13245 */
13246static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013247 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013248 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013249 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013250 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013251 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013252 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013253 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013254 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013255#ifdef CONFIG_SND_DEBUG
13256 [ALC268_TEST] = "test",
13257#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013258 [ALC268_AUTO] = "auto",
13259};
13260
13261static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013262 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013263 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013264 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013265 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013266 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013267 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13268 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013269 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013270 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13271 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013272 /* almost compatible with toshiba but with optional digital outs;
13273 * auto-probing seems working fine
13274 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013275 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013276 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013277 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013278 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013279 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013280 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013281 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013282 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013283 {}
13284};
13285
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013286/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13287static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13288 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13289 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13290 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13291 ALC268_TOSHIBA),
13292 {}
13293};
13294
Kailang Yanga361d842007-06-05 12:30:55 +020013295static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013296 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013297 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13298 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013299 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13300 alc267_quanta_il1_verbs },
13301 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13302 .dac_nids = alc268_dac_nids,
13303 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13304 .adc_nids = alc268_adc_nids_alt,
13305 .hp_nid = 0x03,
13306 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13307 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013308 .unsol_event = alc_sku_unsol_event,
13309 .setup = alc267_quanta_il1_setup,
13310 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013311 },
Kailang Yanga361d842007-06-05 12:30:55 +020013312 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013313 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13314 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013315 .init_verbs = { alc268_base_init_verbs },
13316 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13317 .dac_nids = alc268_dac_nids,
13318 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13319 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013320 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013321 .hp_nid = 0x03,
13322 .dig_out_nid = ALC268_DIGOUT_NID,
13323 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13324 .channel_mode = alc268_modes,
13325 .input_mux = &alc268_capture_source,
13326 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013327 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013328 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013329 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013330 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13331 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013332 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13333 .dac_nids = alc268_dac_nids,
13334 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13335 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013336 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013337 .hp_nid = 0x03,
13338 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13339 .channel_mode = alc268_modes,
13340 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013341 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013342 .setup = alc268_toshiba_setup,
13343 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013344 },
13345 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013346 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013347 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013348 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13349 alc268_acer_verbs },
13350 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13351 .dac_nids = alc268_dac_nids,
13352 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13353 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013354 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013355 .hp_nid = 0x02,
13356 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13357 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013358 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013359 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013360 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013361 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013362 [ALC268_ACER_DMIC] = {
13363 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13364 alc268_beep_mixer },
13365 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13366 alc268_acer_verbs },
13367 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13368 .dac_nids = alc268_dac_nids,
13369 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13370 .adc_nids = alc268_adc_nids_alt,
13371 .capsrc_nids = alc268_capsrc_nids,
13372 .hp_nid = 0x02,
13373 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13374 .channel_mode = alc268_modes,
13375 .input_mux = &alc268_acer_dmic_capture_source,
13376 .unsol_event = alc268_acer_unsol_event,
13377 .init_hook = alc268_acer_init_hook,
13378 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013379 [ALC268_ACER_ASPIRE_ONE] = {
13380 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013381 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013382 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013383 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13384 alc268_acer_aspire_one_verbs },
13385 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13386 .dac_nids = alc268_dac_nids,
13387 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13388 .adc_nids = alc268_adc_nids_alt,
13389 .capsrc_nids = alc268_capsrc_nids,
13390 .hp_nid = 0x03,
13391 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13392 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013393 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013394 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013395 .init_hook = alc268_acer_lc_init_hook,
13396 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013397 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013398 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13399 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013400 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13401 alc268_dell_verbs },
13402 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13403 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013404 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13405 .adc_nids = alc268_adc_nids_alt,
13406 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013407 .hp_nid = 0x02,
13408 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13409 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013410 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013411 .setup = alc268_dell_setup,
13412 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013413 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013414 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013415 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13416 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013417 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13418 alc268_toshiba_verbs },
13419 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13420 .dac_nids = alc268_dac_nids,
13421 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13422 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013423 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013424 .hp_nid = 0x03,
13425 .dig_out_nid = ALC268_DIGOUT_NID,
13426 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13427 .channel_mode = alc268_modes,
13428 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013429 .setup = alc268_toshiba_setup,
13430 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013431 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013432#ifdef CONFIG_SND_DEBUG
13433 [ALC268_TEST] = {
13434 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13435 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13436 alc268_volume_init_verbs },
13437 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13438 .dac_nids = alc268_dac_nids,
13439 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13440 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013441 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013442 .hp_nid = 0x03,
13443 .dig_out_nid = ALC268_DIGOUT_NID,
13444 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13445 .channel_mode = alc268_modes,
13446 .input_mux = &alc268_capture_source,
13447 },
13448#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013449};
13450
13451static int patch_alc268(struct hda_codec *codec)
13452{
13453 struct alc_spec *spec;
13454 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013455 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013456
Julia Lawallef86f582009-12-19 08:18:03 +010013457 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013458 if (spec == NULL)
13459 return -ENOMEM;
13460
13461 codec->spec = spec;
13462
13463 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13464 alc268_models,
13465 alc268_cfg_tbl);
13466
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013467 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13468 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013469 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013470
Kailang Yanga361d842007-06-05 12:30:55 +020013471 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013472 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13473 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013474 board_config = ALC268_AUTO;
13475 }
13476
13477 if (board_config == ALC268_AUTO) {
13478 /* automatic parse from the BIOS config */
13479 err = alc268_parse_auto_config(codec);
13480 if (err < 0) {
13481 alc_free(codec);
13482 return err;
13483 } else if (!err) {
13484 printk(KERN_INFO
13485 "hda_codec: Cannot set up configuration "
13486 "from BIOS. Using base mode...\n");
13487 board_config = ALC268_3ST;
13488 }
13489 }
13490
13491 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013492 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013493
Kailang Yanga361d842007-06-05 12:30:55 +020013494 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13495 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013496 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013497
Kailang Yanga361d842007-06-05 12:30:55 +020013498 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13499
Takashi Iwai22971e32009-02-10 11:56:44 +010013500 has_beep = 0;
13501 for (i = 0; i < spec->num_mixers; i++) {
13502 if (spec->mixers[i] == alc268_beep_mixer) {
13503 has_beep = 1;
13504 break;
13505 }
13506 }
13507
13508 if (has_beep) {
13509 err = snd_hda_attach_beep_device(codec, 0x1);
13510 if (err < 0) {
13511 alc_free(codec);
13512 return err;
13513 }
13514 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13515 /* override the amp caps for beep generator */
13516 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013517 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13518 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13519 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13520 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013521 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013522
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013523 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013524 /* check whether NID 0x07 is valid */
13525 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013526 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013527
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013528 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013529 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013530 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013531 if (spec->auto_mic ||
13532 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013533 spec->adc_nids = alc268_adc_nids_alt;
13534 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013535 if (spec->auto_mic)
13536 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013537 if (spec->auto_mic || spec->input_mux->num_items == 1)
13538 add_mixer(spec, alc268_capture_nosrc_mixer);
13539 else
13540 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013541 } else {
13542 spec->adc_nids = alc268_adc_nids;
13543 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013544 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013545 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013546 /* set default input source */
13547 for (i = 0; i < spec->num_adc_nids; i++)
13548 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13549 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013550 i < spec->num_mux_defs ?
13551 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013552 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013553 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013554
13555 spec->vmaster_nid = 0x02;
13556
Kailang Yanga361d842007-06-05 12:30:55 +020013557 codec->patch_ops = alc_patch_ops;
13558 if (board_config == ALC268_AUTO)
13559 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013560
Kailang Yanga361d842007-06-05 12:30:55 +020013561 return 0;
13562}
13563
13564/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013565 * ALC269 channel source setting (2 channel)
13566 */
13567#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13568
13569#define alc269_dac_nids alc260_dac_nids
13570
13571static hda_nid_t alc269_adc_nids[1] = {
13572 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013573 0x08,
13574};
13575
Takashi Iwaie01bf502008-08-21 16:25:07 +020013576static hda_nid_t alc269_capsrc_nids[1] = {
13577 0x23,
13578};
13579
Kailang Yang84898e82010-02-04 14:16:14 +010013580static hda_nid_t alc269vb_adc_nids[1] = {
13581 /* ADC1 */
13582 0x09,
13583};
13584
13585static hda_nid_t alc269vb_capsrc_nids[1] = {
13586 0x22,
13587};
13588
Takashi Iwai66946352010-03-29 17:21:45 +020013589static hda_nid_t alc269_adc_candidates[] = {
13590 0x08, 0x09, 0x07,
13591};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013592
Kailang Yangf6a92242007-12-13 16:52:54 +010013593#define alc269_modes alc260_modes
13594#define alc269_capture_source alc880_lg_lw_capture_source
13595
13596static struct snd_kcontrol_new alc269_base_mixer[] = {
13597 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13598 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13602 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13603 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13604 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13605 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13606 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13608 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13609 { } /* end */
13610};
13611
Kailang Yang60db6b52008-08-26 13:13:00 +020013612static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13613 /* output mixer control */
13614 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13615 {
13616 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13617 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013618 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013619 .info = snd_hda_mixer_amp_switch_info,
13620 .get = snd_hda_mixer_amp_switch_get,
13621 .put = alc268_acer_master_sw_put,
13622 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13623 },
13624 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13625 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13626 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13627 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13628 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13629 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013630 { }
13631};
13632
Tony Vroon64154832008-11-06 15:08:49 +000013633static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13634 /* output mixer control */
13635 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13636 {
13637 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13638 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013639 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013640 .info = snd_hda_mixer_amp_switch_info,
13641 .get = snd_hda_mixer_amp_switch_get,
13642 .put = alc268_acer_master_sw_put,
13643 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13644 },
13645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13647 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13648 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13649 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13650 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13651 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13652 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13653 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013654 { }
13655};
13656
Kailang Yang84898e82010-02-04 14:16:14 +010013657static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013658 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013659 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013660 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013661 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013662 { } /* end */
13663};
13664
Kailang Yang84898e82010-02-04 14:16:14 +010013665static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13666 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13667 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13669 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13670 { } /* end */
13671};
13672
Kailang Yangf6a92242007-12-13 16:52:54 +010013673/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013674static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13675 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13676 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13677 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13678 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13679 { } /* end */
13680};
13681
13682static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013683 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13684 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013685 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13686 { } /* end */
13687};
13688
Kailang Yang84898e82010-02-04 14:16:14 +010013689static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13690 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13691 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13692 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13693 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13694 { } /* end */
13695};
13696
13697static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13698 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13699 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13700 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13701 { } /* end */
13702};
13703
Takashi Iwai26f5df22008-11-03 17:39:46 +010013704/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013705#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013706
Kailang Yang60db6b52008-08-26 13:13:00 +020013707static struct hda_verb alc269_quanta_fl1_verbs[] = {
13708 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13709 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13711 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13712 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13713 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13714 { }
13715};
13716
Tony Vroon64154832008-11-06 15:08:49 +000013717static struct hda_verb alc269_lifebook_verbs[] = {
13718 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13719 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13720 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13721 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13722 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13725 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13726 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13727 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13728 { }
13729};
13730
Kailang Yang60db6b52008-08-26 13:13:00 +020013731/* toggle speaker-output according to the hp-jack state */
13732static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13733{
13734 unsigned int present;
13735 unsigned char bits;
13736
Wu Fengguang864f92b2009-11-18 12:38:02 +080013737 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013738 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013739 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013740 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013741 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013742 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013743
13744 snd_hda_codec_write(codec, 0x20, 0,
13745 AC_VERB_SET_COEF_INDEX, 0x0c);
13746 snd_hda_codec_write(codec, 0x20, 0,
13747 AC_VERB_SET_PROC_COEF, 0x680);
13748
13749 snd_hda_codec_write(codec, 0x20, 0,
13750 AC_VERB_SET_COEF_INDEX, 0x0c);
13751 snd_hda_codec_write(codec, 0x20, 0,
13752 AC_VERB_SET_PROC_COEF, 0x480);
13753}
13754
Tony Vroon64154832008-11-06 15:08:49 +000013755/* toggle speaker-output according to the hp-jacks state */
13756static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13757{
13758 unsigned int present;
13759 unsigned char bits;
13760
13761 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013762 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013763
13764 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013765 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013766
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013767 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013768 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013769 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013770 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013771 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013772
13773 snd_hda_codec_write(codec, 0x20, 0,
13774 AC_VERB_SET_COEF_INDEX, 0x0c);
13775 snd_hda_codec_write(codec, 0x20, 0,
13776 AC_VERB_SET_PROC_COEF, 0x680);
13777
13778 snd_hda_codec_write(codec, 0x20, 0,
13779 AC_VERB_SET_COEF_INDEX, 0x0c);
13780 snd_hda_codec_write(codec, 0x20, 0,
13781 AC_VERB_SET_PROC_COEF, 0x480);
13782}
13783
Tony Vroon64154832008-11-06 15:08:49 +000013784static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13785{
13786 unsigned int present_laptop;
13787 unsigned int present_dock;
13788
Wu Fengguang864f92b2009-11-18 12:38:02 +080013789 present_laptop = snd_hda_jack_detect(codec, 0x18);
13790 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013791
13792 /* Laptop mic port overrides dock mic port, design decision */
13793 if (present_dock)
13794 snd_hda_codec_write(codec, 0x23, 0,
13795 AC_VERB_SET_CONNECT_SEL, 0x3);
13796 if (present_laptop)
13797 snd_hda_codec_write(codec, 0x23, 0,
13798 AC_VERB_SET_CONNECT_SEL, 0x0);
13799 if (!present_dock && !present_laptop)
13800 snd_hda_codec_write(codec, 0x23, 0,
13801 AC_VERB_SET_CONNECT_SEL, 0x1);
13802}
13803
Kailang Yang60db6b52008-08-26 13:13:00 +020013804static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13805 unsigned int res)
13806{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013807 switch (res >> 26) {
13808 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013809 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013810 break;
13811 case ALC880_MIC_EVENT:
13812 alc_mic_automute(codec);
13813 break;
13814 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013815}
13816
Tony Vroon64154832008-11-06 15:08:49 +000013817static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13818 unsigned int res)
13819{
13820 if ((res >> 26) == ALC880_HP_EVENT)
13821 alc269_lifebook_speaker_automute(codec);
13822 if ((res >> 26) == ALC880_MIC_EVENT)
13823 alc269_lifebook_mic_autoswitch(codec);
13824}
13825
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013826static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13827{
13828 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013829 spec->autocfg.hp_pins[0] = 0x15;
13830 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013831 spec->ext_mic.pin = 0x18;
13832 spec->ext_mic.mux_idx = 0;
13833 spec->int_mic.pin = 0x19;
13834 spec->int_mic.mux_idx = 1;
13835 spec->auto_mic = 1;
13836}
13837
Kailang Yang60db6b52008-08-26 13:13:00 +020013838static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13839{
13840 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013841 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013842}
13843
Tony Vroon64154832008-11-06 15:08:49 +000013844static void alc269_lifebook_init_hook(struct hda_codec *codec)
13845{
13846 alc269_lifebook_speaker_automute(codec);
13847 alc269_lifebook_mic_autoswitch(codec);
13848}
13849
Kailang Yang84898e82010-02-04 14:16:14 +010013850static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013851 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13852 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13853 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13855 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13856 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13857 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13858 {}
13859};
13860
Kailang Yang84898e82010-02-04 14:16:14 +010013861static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013862 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13863 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13864 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13866 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13867 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13868 {}
13869};
13870
Kailang Yang84898e82010-02-04 14:16:14 +010013871static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13872 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13873 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13874 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13876 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13877 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13878 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13879 {}
13880};
13881
13882static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13883 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13884 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13885 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13886 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13887 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13888 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13889 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13890 {}
13891};
13892
Kailang Yang60db6b52008-08-26 13:13:00 +020013893/* toggle speaker-output according to the hp-jack state */
13894static void alc269_speaker_automute(struct hda_codec *codec)
13895{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013896 struct alc_spec *spec = codec->spec;
13897 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013898 unsigned int present;
13899 unsigned char bits;
13900
Kailang Yangebb83ee2009-12-17 12:23:00 +010013901 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013902 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013903 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013904 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013905 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013906 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013907}
13908
Kailang Yang60db6b52008-08-26 13:13:00 +020013909/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013910static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013911 unsigned int res)
13912{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013913 switch (res >> 26) {
13914 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013915 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013916 break;
13917 case ALC880_MIC_EVENT:
13918 alc_mic_automute(codec);
13919 break;
13920 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013921}
13922
Kailang Yang226b1ec2010-04-09 11:01:20 +020013923static void alc269_laptop_amic_setup(struct hda_codec *codec)
13924{
13925 struct alc_spec *spec = codec->spec;
13926 spec->autocfg.hp_pins[0] = 0x15;
13927 spec->autocfg.speaker_pins[0] = 0x14;
13928 spec->ext_mic.pin = 0x18;
13929 spec->ext_mic.mux_idx = 0;
13930 spec->int_mic.pin = 0x19;
13931 spec->int_mic.mux_idx = 1;
13932 spec->auto_mic = 1;
13933}
13934
Kailang Yang84898e82010-02-04 14:16:14 +010013935static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013936{
13937 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013938 spec->autocfg.hp_pins[0] = 0x15;
13939 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013940 spec->ext_mic.pin = 0x18;
13941 spec->ext_mic.mux_idx = 0;
13942 spec->int_mic.pin = 0x12;
13943 spec->int_mic.mux_idx = 5;
13944 spec->auto_mic = 1;
13945}
13946
Kailang Yang226b1ec2010-04-09 11:01:20 +020013947static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010013948{
13949 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020013950 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010013951 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013952 spec->ext_mic.pin = 0x18;
13953 spec->ext_mic.mux_idx = 0;
13954 spec->int_mic.pin = 0x19;
13955 spec->int_mic.mux_idx = 1;
13956 spec->auto_mic = 1;
13957}
13958
Kailang Yang226b1ec2010-04-09 11:01:20 +020013959static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13960{
13961 struct alc_spec *spec = codec->spec;
13962 spec->autocfg.hp_pins[0] = 0x21;
13963 spec->autocfg.speaker_pins[0] = 0x14;
13964 spec->ext_mic.pin = 0x18;
13965 spec->ext_mic.mux_idx = 0;
13966 spec->int_mic.pin = 0x12;
13967 spec->int_mic.mux_idx = 6;
13968 spec->auto_mic = 1;
13969}
13970
Kailang Yang84898e82010-02-04 14:16:14 +010013971static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013972{
13973 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013974 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013975}
13976
Kailang Yangf6a92242007-12-13 16:52:54 +010013977/*
13978 * generic initialization of ADC, input mixers and output mixers
13979 */
13980static struct hda_verb alc269_init_verbs[] = {
13981 /*
13982 * Unmute ADC0 and set the default input to mic-in
13983 */
Kailang Yang84898e82010-02-04 14:16:14 +010013984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013985
13986 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013987 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013988 */
13989 /* set vol=0 to output mixers */
13990 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13991 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13992
13993 /* set up input amps for analog loopback */
13994 /* Amp Indices: DAC = 0, mixer = 1 */
13995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13997 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14001
14002 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14004 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14005 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14006 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14007 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14008 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14009
14010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014012
Kailang Yang84898e82010-02-04 14:16:14 +010014013 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014014 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14015 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014016 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014017
14018 /* set EAPD */
14019 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014020 { }
14021};
14022
14023static struct hda_verb alc269vb_init_verbs[] = {
14024 /*
14025 * Unmute ADC0 and set the default input to mic-in
14026 */
14027 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14028
14029 /*
14030 * Set up output mixers (0x02 - 0x03)
14031 */
14032 /* set vol=0 to output mixers */
14033 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14034 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14035
14036 /* set up input amps for analog loopback */
14037 /* Amp Indices: DAC = 0, mixer = 1 */
14038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14040 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14042 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14043 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14044
14045 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14046 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14047 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14049 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14050 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14052
14053 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14054 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14055
14056 /* FIXME: use Mux-type input source selection */
14057 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14058 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14059 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14060
14061 /* set EAPD */
14062 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014063 { }
14064};
14065
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014066#define alc269_auto_create_multi_out_ctls \
14067 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014068#define alc269_auto_create_input_ctls \
14069 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014070
14071#ifdef CONFIG_SND_HDA_POWER_SAVE
14072#define alc269_loopbacks alc880_loopbacks
14073#endif
14074
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014075/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014076#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14077#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14078#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14079#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14080
Takashi Iwaif03d3112009-03-05 14:18:16 +010014081static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14082 .substreams = 1,
14083 .channels_min = 2,
14084 .channels_max = 8,
14085 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14086 /* NID is set in alc_build_pcms */
14087 .ops = {
14088 .open = alc880_playback_pcm_open,
14089 .prepare = alc880_playback_pcm_prepare,
14090 .cleanup = alc880_playback_pcm_cleanup
14091 },
14092};
14093
14094static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14095 .substreams = 1,
14096 .channels_min = 2,
14097 .channels_max = 2,
14098 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14099 /* NID is set in alc_build_pcms */
14100};
14101
Takashi Iwaiad358792010-03-30 18:00:59 +020014102#ifdef CONFIG_SND_HDA_POWER_SAVE
14103static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14104{
14105 switch (codec->subsystem_id) {
14106 case 0x103c1586:
14107 return 1;
14108 }
14109 return 0;
14110}
14111
14112static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14113{
14114 /* update mute-LED according to the speaker mute state */
14115 if (nid == 0x01 || nid == 0x14) {
14116 int pinval;
14117 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14118 HDA_AMP_MUTE)
14119 pinval = 0x24;
14120 else
14121 pinval = 0x20;
14122 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014123 snd_hda_codec_update_cache(codec, 0x19, 0,
14124 AC_VERB_SET_PIN_WIDGET_CONTROL,
14125 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014126 }
14127 return alc_check_power_status(codec, nid);
14128}
14129#endif /* CONFIG_SND_HDA_POWER_SAVE */
14130
Kailang Yangf6a92242007-12-13 16:52:54 +010014131/*
14132 * BIOS auto configuration
14133 */
14134static int alc269_parse_auto_config(struct hda_codec *codec)
14135{
14136 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014137 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014138 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14139
14140 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14141 alc269_ignore);
14142 if (err < 0)
14143 return err;
14144
14145 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14146 if (err < 0)
14147 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014148 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014149 if (err < 0)
14150 return err;
14151
14152 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14153
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014154 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010014155 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
14156
Takashi Iwai603c4012008-07-30 15:01:44 +020014157 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014158 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014159
Kailang Yang84898e82010-02-04 14:16:14 +010014160 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14161 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014162 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014163 } else {
14164 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014165 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014166 }
14167
Kailang Yangf6a92242007-12-13 16:52:54 +010014168 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014169 spec->input_mux = &spec->private_imux[0];
Takashi Iwai66946352010-03-29 17:21:45 +020014170 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14171 sizeof(alc269_adc_candidates));
14172
Takashi Iwaie01bf502008-08-21 16:25:07 +020014173 /* set default input source */
Takashi Iwai66946352010-03-29 17:21:45 +020014174 snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
Takashi Iwaie01bf502008-08-21 16:25:07 +020014175 0, AC_VERB_SET_CONNECT_SEL,
14176 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014177
14178 err = alc_auto_add_mic_boost(codec);
14179 if (err < 0)
14180 return err;
14181
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014182 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014183 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014184
Kailang Yangf6a92242007-12-13 16:52:54 +010014185 return 1;
14186}
14187
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014188#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14189#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014190#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14191
14192
14193/* init callback for auto-configuration model -- overriding the default init */
14194static void alc269_auto_init(struct hda_codec *codec)
14195{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014196 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014197 alc269_auto_init_multi_out(codec);
14198 alc269_auto_init_hp_out(codec);
14199 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014200 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014201 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014202}
14203
Takashi Iwaiff818c22010-04-12 08:59:25 +020014204enum {
14205 ALC269_FIXUP_SONY_VAIO,
14206};
14207
Tobias Klauserfbc25662010-05-20 10:40:55 +020014208static const struct hda_verb alc269_sony_vaio_fixup_verbs[] = {
Takashi Iwaiff818c22010-04-12 08:59:25 +020014209 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14210 {}
14211};
14212
14213static const struct alc_fixup alc269_fixups[] = {
14214 [ALC269_FIXUP_SONY_VAIO] = {
14215 .verbs = alc269_sony_vaio_fixup_verbs
14216 },
14217};
14218
14219static struct snd_pci_quirk alc269_fixup_tbl[] = {
14220 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
14221 {}
14222};
14223
14224
Kailang Yangf6a92242007-12-13 16:52:54 +010014225/*
14226 * configuration and preset
14227 */
14228static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014229 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014230 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014231 [ALC269_AMIC] = "laptop-amic",
14232 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014233 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014234 [ALC269_LIFEBOOK] = "lifebook",
14235 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014236};
14237
14238static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014239 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020014240 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014241 ALC269_AMIC),
14242 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14243 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14244 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14245 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14246 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14247 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14248 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14249 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14250 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14251 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14252 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14253 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14254 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14255 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14256 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14257 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14258 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14259 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14260 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14261 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14262 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14263 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14264 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14265 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14266 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14267 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14268 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14269 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14270 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14271 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14272 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14273 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14274 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14275 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14276 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14277 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014278 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014279 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014280 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014281 ALC269_DMIC),
14282 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14283 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014284 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014285 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014286 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14287 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14288 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14289 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14290 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14291 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014292 {}
14293};
14294
14295static struct alc_config_preset alc269_presets[] = {
14296 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014297 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014298 .init_verbs = { alc269_init_verbs },
14299 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14300 .dac_nids = alc269_dac_nids,
14301 .hp_nid = 0x03,
14302 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14303 .channel_mode = alc269_modes,
14304 .input_mux = &alc269_capture_source,
14305 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014306 [ALC269_QUANTA_FL1] = {
14307 .mixers = { alc269_quanta_fl1_mixer },
14308 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14309 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14310 .dac_nids = alc269_dac_nids,
14311 .hp_nid = 0x03,
14312 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14313 .channel_mode = alc269_modes,
14314 .input_mux = &alc269_capture_source,
14315 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014316 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014317 .init_hook = alc269_quanta_fl1_init_hook,
14318 },
Kailang Yang84898e82010-02-04 14:16:14 +010014319 [ALC269_AMIC] = {
14320 .mixers = { alc269_laptop_mixer },
14321 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014322 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014323 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014324 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14325 .dac_nids = alc269_dac_nids,
14326 .hp_nid = 0x03,
14327 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14328 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014329 .unsol_event = alc269_laptop_unsol_event,
14330 .setup = alc269_laptop_amic_setup,
14331 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014332 },
Kailang Yang84898e82010-02-04 14:16:14 +010014333 [ALC269_DMIC] = {
14334 .mixers = { alc269_laptop_mixer },
14335 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014336 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014337 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014338 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14339 .dac_nids = alc269_dac_nids,
14340 .hp_nid = 0x03,
14341 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14342 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014343 .unsol_event = alc269_laptop_unsol_event,
14344 .setup = alc269_laptop_dmic_setup,
14345 .init_hook = alc269_laptop_inithook,
14346 },
14347 [ALC269VB_AMIC] = {
14348 .mixers = { alc269vb_laptop_mixer },
14349 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14350 .init_verbs = { alc269vb_init_verbs,
14351 alc269vb_laptop_amic_init_verbs },
14352 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14353 .dac_nids = alc269_dac_nids,
14354 .hp_nid = 0x03,
14355 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14356 .channel_mode = alc269_modes,
14357 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014358 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014359 .init_hook = alc269_laptop_inithook,
14360 },
14361 [ALC269VB_DMIC] = {
14362 .mixers = { alc269vb_laptop_mixer },
14363 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14364 .init_verbs = { alc269vb_init_verbs,
14365 alc269vb_laptop_dmic_init_verbs },
14366 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14367 .dac_nids = alc269_dac_nids,
14368 .hp_nid = 0x03,
14369 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14370 .channel_mode = alc269_modes,
14371 .unsol_event = alc269_laptop_unsol_event,
14372 .setup = alc269vb_laptop_dmic_setup,
14373 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014374 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014375 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014376 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014377 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014378 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014379 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014380 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14381 .dac_nids = alc269_dac_nids,
14382 .hp_nid = 0x03,
14383 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14384 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014385 .unsol_event = alc269_laptop_unsol_event,
14386 .setup = alc269_laptop_dmic_setup,
14387 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014388 },
Tony Vroon64154832008-11-06 15:08:49 +000014389 [ALC269_LIFEBOOK] = {
14390 .mixers = { alc269_lifebook_mixer },
14391 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14392 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14393 .dac_nids = alc269_dac_nids,
14394 .hp_nid = 0x03,
14395 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14396 .channel_mode = alc269_modes,
14397 .input_mux = &alc269_capture_source,
14398 .unsol_event = alc269_lifebook_unsol_event,
14399 .init_hook = alc269_lifebook_init_hook,
14400 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014401};
14402
14403static int patch_alc269(struct hda_codec *codec)
14404{
14405 struct alc_spec *spec;
14406 int board_config;
14407 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014408 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014409
14410 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14411 if (spec == NULL)
14412 return -ENOMEM;
14413
14414 codec->spec = spec;
14415
Kailang Yangda00c242010-03-19 11:23:45 +010014416 alc_auto_parse_customize_define(codec);
14417
Kailang Yang274693f2009-12-03 10:07:50 +010014418 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014419 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14420 spec->cdefine.platform_type == 1)
14421 alc_codec_rename(codec, "ALC271X");
14422 else
14423 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014424 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014425 } else
14426 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014427
Kailang Yangf6a92242007-12-13 16:52:54 +010014428 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14429 alc269_models,
14430 alc269_cfg_tbl);
14431
14432 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014433 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14434 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014435 board_config = ALC269_AUTO;
14436 }
14437
Takashi Iwaiff818c22010-04-12 08:59:25 +020014438 if (board_config == ALC269_AUTO)
14439 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14440
Kailang Yangf6a92242007-12-13 16:52:54 +010014441 if (board_config == ALC269_AUTO) {
14442 /* automatic parse from the BIOS config */
14443 err = alc269_parse_auto_config(codec);
14444 if (err < 0) {
14445 alc_free(codec);
14446 return err;
14447 } else if (!err) {
14448 printk(KERN_INFO
14449 "hda_codec: Cannot set up configuration "
14450 "from BIOS. Using base mode...\n");
14451 board_config = ALC269_BASIC;
14452 }
14453 }
14454
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014455 err = snd_hda_attach_beep_device(codec, 0x1);
14456 if (err < 0) {
14457 alc_free(codec);
14458 return err;
14459 }
14460
Kailang Yangf6a92242007-12-13 16:52:54 +010014461 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014462 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014463
Kailang Yang84898e82010-02-04 14:16:14 +010014464 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014465 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14466 * fix the sample rate of analog I/O to 44.1kHz
14467 */
14468 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14469 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14470 } else {
14471 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14472 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14473 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014474 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14475 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14476
Takashi Iwai66946352010-03-29 17:21:45 +020014477 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14478 if (!is_alc269vb) {
14479 spec->adc_nids = alc269_adc_nids;
14480 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14481 spec->capsrc_nids = alc269_capsrc_nids;
14482 } else {
14483 spec->adc_nids = alc269vb_adc_nids;
14484 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14485 spec->capsrc_nids = alc269vb_capsrc_nids;
14486 }
Kailang Yang84898e82010-02-04 14:16:14 +010014487 }
14488
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014489 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014490 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010014491 if (spec->cdefine.enable_pcbeep)
14492 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014493
Takashi Iwaiff818c22010-04-12 08:59:25 +020014494 if (board_config == ALC269_AUTO)
14495 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14496
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014497 spec->vmaster_nid = 0x02;
14498
Kailang Yangf6a92242007-12-13 16:52:54 +010014499 codec->patch_ops = alc_patch_ops;
14500 if (board_config == ALC269_AUTO)
14501 spec->init_hook = alc269_auto_init;
14502#ifdef CONFIG_SND_HDA_POWER_SAVE
14503 if (!spec->loopback.amplist)
14504 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014505 if (alc269_mic2_for_mute_led(codec))
14506 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014507#endif
14508
14509 return 0;
14510}
14511
14512/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014513 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14514 */
14515
14516/*
14517 * set the path ways for 2 channel output
14518 * need to set the codec line out and mic 1 pin widgets to inputs
14519 */
14520static struct hda_verb alc861_threestack_ch2_init[] = {
14521 /* set pin widget 1Ah (line in) for input */
14522 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014523 /* set pin widget 18h (mic1/2) for input, for mic also enable
14524 * the vref
14525 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014526 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14527
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014528 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14529#if 0
14530 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14531 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14532#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014533 { } /* end */
14534};
14535/*
14536 * 6ch mode
14537 * need to set the codec line out and mic 1 pin widgets to outputs
14538 */
14539static struct hda_verb alc861_threestack_ch6_init[] = {
14540 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14541 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14542 /* set pin widget 18h (mic1) for output (CLFE)*/
14543 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14544
14545 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014546 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014547
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014548 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14549#if 0
14550 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14551 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14552#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014553 { } /* end */
14554};
14555
14556static struct hda_channel_mode alc861_threestack_modes[2] = {
14557 { 2, alc861_threestack_ch2_init },
14558 { 6, alc861_threestack_ch6_init },
14559};
Takashi Iwai22309c32006-08-09 16:57:28 +020014560/* Set mic1 as input and unmute the mixer */
14561static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14562 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14563 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14564 { } /* end */
14565};
14566/* Set mic1 as output and mute mixer */
14567static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14568 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14569 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14570 { } /* end */
14571};
14572
14573static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14574 { 2, alc861_uniwill_m31_ch2_init },
14575 { 4, alc861_uniwill_m31_ch4_init },
14576};
Kailang Yangdf694da2005-12-05 19:42:22 +010014577
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014578/* Set mic1 and line-in as input and unmute the mixer */
14579static struct hda_verb alc861_asus_ch2_init[] = {
14580 /* set pin widget 1Ah (line in) for input */
14581 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014582 /* set pin widget 18h (mic1/2) for input, for mic also enable
14583 * the vref
14584 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014585 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14586
14587 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14588#if 0
14589 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14590 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14591#endif
14592 { } /* end */
14593};
14594/* Set mic1 nad line-in as output and mute mixer */
14595static struct hda_verb alc861_asus_ch6_init[] = {
14596 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14597 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14598 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14599 /* set pin widget 18h (mic1) for output (CLFE)*/
14600 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14601 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14602 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14603 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14604
14605 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14606#if 0
14607 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14608 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14609#endif
14610 { } /* end */
14611};
14612
14613static struct hda_channel_mode alc861_asus_modes[2] = {
14614 { 2, alc861_asus_ch2_init },
14615 { 6, alc861_asus_ch6_init },
14616};
14617
Kailang Yangdf694da2005-12-05 19:42:22 +010014618/* patch-ALC861 */
14619
14620static struct snd_kcontrol_new alc861_base_mixer[] = {
14621 /* output mixer control */
14622 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14623 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14624 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14625 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14626 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14627
14628 /*Input mixer control */
14629 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14630 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14631 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14632 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14633 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14634 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14636 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14637 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014639
Kailang Yangdf694da2005-12-05 19:42:22 +010014640 { } /* end */
14641};
14642
14643static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14644 /* output mixer control */
14645 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14646 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14647 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14648 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14649 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14650
14651 /* Input mixer control */
14652 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14653 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14654 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14655 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14656 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14657 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14659 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14660 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14661 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014662
Kailang Yangdf694da2005-12-05 19:42:22 +010014663 {
14664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14665 .name = "Channel Mode",
14666 .info = alc_ch_mode_info,
14667 .get = alc_ch_mode_get,
14668 .put = alc_ch_mode_put,
14669 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14670 },
14671 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014672};
14673
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014674static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014675 /* output mixer control */
14676 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14677 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14678 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014679
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014680 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014681};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014682
Takashi Iwai22309c32006-08-09 16:57:28 +020014683static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14684 /* output mixer control */
14685 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14686 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14687 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14688 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14689 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14690
14691 /* Input mixer control */
14692 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14693 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14694 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14695 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14696 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14697 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14699 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14700 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14701 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014702
Takashi Iwai22309c32006-08-09 16:57:28 +020014703 {
14704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14705 .name = "Channel Mode",
14706 .info = alc_ch_mode_info,
14707 .get = alc_ch_mode_get,
14708 .put = alc_ch_mode_put,
14709 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14710 },
14711 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014712};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014713
14714static struct snd_kcontrol_new alc861_asus_mixer[] = {
14715 /* output mixer control */
14716 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14717 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14718 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14719 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14720 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14721
14722 /* Input mixer control */
14723 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14724 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14725 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14726 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14727 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14728 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14730 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14731 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014732 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14733
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014734 {
14735 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14736 .name = "Channel Mode",
14737 .info = alc_ch_mode_info,
14738 .get = alc_ch_mode_get,
14739 .put = alc_ch_mode_put,
14740 .private_value = ARRAY_SIZE(alc861_asus_modes),
14741 },
14742 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014743};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014744
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014745/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014746static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014747 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14748 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014749 { }
14750};
14751
Kailang Yangdf694da2005-12-05 19:42:22 +010014752/*
14753 * generic initialization of ADC, input mixers and output mixers
14754 */
14755static struct hda_verb alc861_base_init_verbs[] = {
14756 /*
14757 * Unmute ADC0 and set the default input to mic-in
14758 */
14759 /* port-A for surround (rear panel) */
14760 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14761 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14762 /* port-B for mic-in (rear panel) with vref */
14763 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14764 /* port-C for line-in (rear panel) */
14765 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14766 /* port-D for Front */
14767 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14768 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14769 /* port-E for HP out (front panel) */
14770 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14771 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014772 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014773 /* port-F for mic-in (front panel) with vref */
14774 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14775 /* port-G for CLFE (rear panel) */
14776 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14777 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14778 /* port-H for side (rear panel) */
14779 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14780 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14781 /* CD-in */
14782 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14783 /* route front mic to ADC1*/
14784 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014786
Kailang Yangdf694da2005-12-05 19:42:22 +010014787 /* Unmute DAC0~3 & spdif out*/
14788 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14789 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14790 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14791 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14792 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014793
Kailang Yangdf694da2005-12-05 19:42:22 +010014794 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14795 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14796 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14797 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14798 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014799
Kailang Yangdf694da2005-12-05 19:42:22 +010014800 /* Unmute Stereo Mixer 15 */
14801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14802 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14803 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014804 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014805
14806 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14807 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14808 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14809 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14810 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14812 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014814 /* hp used DAC 3 (Front) */
14815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014816 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14817
14818 { }
14819};
14820
14821static struct hda_verb alc861_threestack_init_verbs[] = {
14822 /*
14823 * Unmute ADC0 and set the default input to mic-in
14824 */
14825 /* port-A for surround (rear panel) */
14826 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14827 /* port-B for mic-in (rear panel) with vref */
14828 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14829 /* port-C for line-in (rear panel) */
14830 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14831 /* port-D for Front */
14832 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14833 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14834 /* port-E for HP out (front panel) */
14835 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14836 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014837 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014838 /* port-F for mic-in (front panel) with vref */
14839 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14840 /* port-G for CLFE (rear panel) */
14841 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14842 /* port-H for side (rear panel) */
14843 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14844 /* CD-in */
14845 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14846 /* route front mic to ADC1*/
14847 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14848 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14849 /* Unmute DAC0~3 & spdif out*/
14850 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14851 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14852 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14853 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014855
Kailang Yangdf694da2005-12-05 19:42:22 +010014856 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14857 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14858 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14859 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14860 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014861
Kailang Yangdf694da2005-12-05 19:42:22 +010014862 /* Unmute Stereo Mixer 15 */
14863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014867
14868 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14870 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14871 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14873 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14874 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14875 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014876 /* hp used DAC 3 (Front) */
14877 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14879 { }
14880};
Takashi Iwai22309c32006-08-09 16:57:28 +020014881
14882static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14883 /*
14884 * Unmute ADC0 and set the default input to mic-in
14885 */
14886 /* port-A for surround (rear panel) */
14887 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14888 /* port-B for mic-in (rear panel) with vref */
14889 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14890 /* port-C for line-in (rear panel) */
14891 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14892 /* port-D for Front */
14893 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14894 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14895 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014896 /* this has to be set to VREF80 */
14897 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014898 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014899 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014900 /* port-F for mic-in (front panel) with vref */
14901 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14902 /* port-G for CLFE (rear panel) */
14903 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14904 /* port-H for side (rear panel) */
14905 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14906 /* CD-in */
14907 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14908 /* route front mic to ADC1*/
14909 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14910 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14911 /* Unmute DAC0~3 & spdif out*/
14912 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14913 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14914 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14915 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014917
Takashi Iwai22309c32006-08-09 16:57:28 +020014918 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14919 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14920 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14921 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14922 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014923
Takashi Iwai22309c32006-08-09 16:57:28 +020014924 /* Unmute Stereo Mixer 15 */
14925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014929
14930 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14931 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14932 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14933 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14934 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14935 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14936 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14937 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014938 /* hp used DAC 3 (Front) */
14939 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014940 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14941 { }
14942};
14943
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014944static struct hda_verb alc861_asus_init_verbs[] = {
14945 /*
14946 * Unmute ADC0 and set the default input to mic-in
14947 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014948 /* port-A for surround (rear panel)
14949 * according to codec#0 this is the HP jack
14950 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014951 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14952 /* route front PCM to HP */
14953 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14954 /* port-B for mic-in (rear panel) with vref */
14955 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14956 /* port-C for line-in (rear panel) */
14957 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14958 /* port-D for Front */
14959 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14960 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14961 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014962 /* this has to be set to VREF80 */
14963 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014964 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014965 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014966 /* port-F for mic-in (front panel) with vref */
14967 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14968 /* port-G for CLFE (rear panel) */
14969 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14970 /* port-H for side (rear panel) */
14971 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14972 /* CD-in */
14973 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14974 /* route front mic to ADC1*/
14975 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14976 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14977 /* Unmute DAC0~3 & spdif out*/
14978 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14979 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14980 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14981 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14983 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14984 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14985 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14986 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14987 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014988
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014989 /* Unmute Stereo Mixer 15 */
14990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14991 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14992 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014993 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014994
14995 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14996 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14997 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14998 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14999 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15000 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15001 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15002 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015003 /* hp used DAC 3 (Front) */
15004 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015005 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15006 { }
15007};
15008
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015009/* additional init verbs for ASUS laptops */
15010static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15011 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15012 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15013 { }
15014};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015015
Kailang Yangdf694da2005-12-05 19:42:22 +010015016/*
15017 * generic initialization of ADC, input mixers and output mixers
15018 */
15019static struct hda_verb alc861_auto_init_verbs[] = {
15020 /*
15021 * Unmute ADC0 and set the default input to mic-in
15022 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015023 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015024 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015025
Kailang Yangdf694da2005-12-05 19:42:22 +010015026 /* Unmute DAC0~3 & spdif out*/
15027 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15028 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15029 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15030 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015032
Kailang Yangdf694da2005-12-05 19:42:22 +010015033 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15034 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15035 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15036 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15037 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015038
Kailang Yangdf694da2005-12-05 19:42:22 +010015039 /* Unmute Stereo Mixer 15 */
15040 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15042 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15043 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15044
Takashi Iwai1c209302009-07-22 15:17:45 +020015045 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15046 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15047 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15048 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15049 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15050 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15051 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15052 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015053
15054 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15055 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015056 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15057 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015058 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15059 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015060 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15061 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015062
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015063 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015064
15065 { }
15066};
15067
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015068static struct hda_verb alc861_toshiba_init_verbs[] = {
15069 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015070
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015071 { }
15072};
15073
15074/* toggle speaker-output according to the hp-jack state */
15075static void alc861_toshiba_automute(struct hda_codec *codec)
15076{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015077 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015078
Takashi Iwai47fd8302007-08-10 17:11:07 +020015079 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15080 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15081 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15082 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015083}
15084
15085static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15086 unsigned int res)
15087{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015088 if ((res >> 26) == ALC880_HP_EVENT)
15089 alc861_toshiba_automute(codec);
15090}
15091
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015092/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015093#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15094#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15095#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15096#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15097
15098
15099#define ALC861_DIGOUT_NID 0x07
15100
15101static struct hda_channel_mode alc861_8ch_modes[1] = {
15102 { 8, NULL }
15103};
15104
15105static hda_nid_t alc861_dac_nids[4] = {
15106 /* front, surround, clfe, side */
15107 0x03, 0x06, 0x05, 0x04
15108};
15109
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015110static hda_nid_t alc660_dac_nids[3] = {
15111 /* front, clfe, surround */
15112 0x03, 0x05, 0x06
15113};
15114
Kailang Yangdf694da2005-12-05 19:42:22 +010015115static hda_nid_t alc861_adc_nids[1] = {
15116 /* ADC0-2 */
15117 0x08,
15118};
15119
15120static struct hda_input_mux alc861_capture_source = {
15121 .num_items = 5,
15122 .items = {
15123 { "Mic", 0x0 },
15124 { "Front Mic", 0x3 },
15125 { "Line", 0x1 },
15126 { "CD", 0x4 },
15127 { "Mixer", 0x5 },
15128 },
15129};
15130
Takashi Iwai1c209302009-07-22 15:17:45 +020015131static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15132{
15133 struct alc_spec *spec = codec->spec;
15134 hda_nid_t mix, srcs[5];
15135 int i, j, num;
15136
15137 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15138 return 0;
15139 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15140 if (num < 0)
15141 return 0;
15142 for (i = 0; i < num; i++) {
15143 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015144 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015145 if (type != AC_WID_AUD_OUT)
15146 continue;
15147 for (j = 0; j < spec->multiout.num_dacs; j++)
15148 if (spec->multiout.dac_nids[j] == srcs[i])
15149 break;
15150 if (j >= spec->multiout.num_dacs)
15151 return srcs[i];
15152 }
15153 return 0;
15154}
15155
Kailang Yangdf694da2005-12-05 19:42:22 +010015156/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015157static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015158 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015159{
Takashi Iwai1c209302009-07-22 15:17:45 +020015160 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015161 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015162 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015163
15164 spec->multiout.dac_nids = spec->private_dac_nids;
15165 for (i = 0; i < cfg->line_outs; i++) {
15166 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015167 dac = alc861_look_for_dac(codec, nid);
15168 if (!dac)
15169 continue;
15170 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015171 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015172 return 0;
15173}
15174
Takashi Iwai1c209302009-07-22 15:17:45 +020015175static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15176 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015177{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015178 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015179 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15180}
15181
15182/* add playback controls from the parsed DAC table */
15183static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15184 const struct auto_pin_cfg *cfg)
15185{
15186 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015187 static const char *chname[4] = {
15188 "Front", "Surround", NULL /*CLFE*/, "Side"
15189 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015190 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015191 int i, err;
15192
15193 if (cfg->line_outs == 1) {
15194 const char *pfx = NULL;
15195 if (!cfg->hp_outs)
15196 pfx = "Master";
15197 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15198 pfx = "Speaker";
15199 if (pfx) {
15200 nid = spec->multiout.dac_nids[0];
15201 return alc861_create_out_sw(codec, pfx, nid, 3);
15202 }
15203 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015204
15205 for (i = 0; i < cfg->line_outs; i++) {
15206 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015207 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015208 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015209 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015210 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015211 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015212 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015213 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015214 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015215 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015216 return err;
15217 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015218 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015219 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015220 return err;
15221 }
15222 }
15223 return 0;
15224}
15225
Takashi Iwai1c209302009-07-22 15:17:45 +020015226static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015227{
Takashi Iwai1c209302009-07-22 15:17:45 +020015228 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015229 int err;
15230 hda_nid_t nid;
15231
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015232 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015233 return 0;
15234
15235 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015236 nid = alc861_look_for_dac(codec, pin);
15237 if (nid) {
15238 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15239 if (err < 0)
15240 return err;
15241 spec->multiout.hp_nid = nid;
15242 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015243 }
15244 return 0;
15245}
15246
15247/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015248static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015249 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015250{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015251 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015252}
15253
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015254static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15255 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015256 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015257{
Takashi Iwai1c209302009-07-22 15:17:45 +020015258 hda_nid_t mix, srcs[5];
15259 int i, num;
15260
Jacek Luczak564c5be2008-05-03 18:41:23 +020015261 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15262 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015263 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015264 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015265 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15266 return;
15267 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15268 if (num < 0)
15269 return;
15270 for (i = 0; i < num; i++) {
15271 unsigned int mute;
15272 if (srcs[i] == dac || srcs[i] == 0x15)
15273 mute = AMP_IN_UNMUTE(i);
15274 else
15275 mute = AMP_IN_MUTE(i);
15276 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15277 mute);
15278 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015279}
15280
15281static void alc861_auto_init_multi_out(struct hda_codec *codec)
15282{
15283 struct alc_spec *spec = codec->spec;
15284 int i;
15285
15286 for (i = 0; i < spec->autocfg.line_outs; i++) {
15287 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015288 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015289 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015290 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015291 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015292 }
15293}
15294
15295static void alc861_auto_init_hp_out(struct hda_codec *codec)
15296{
15297 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015298
Takashi Iwai15870f02009-10-05 08:25:13 +020015299 if (spec->autocfg.hp_outs)
15300 alc861_auto_set_output_and_unmute(codec,
15301 spec->autocfg.hp_pins[0],
15302 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015303 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015304 if (spec->autocfg.speaker_outs)
15305 alc861_auto_set_output_and_unmute(codec,
15306 spec->autocfg.speaker_pins[0],
15307 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015308 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015309}
15310
15311static void alc861_auto_init_analog_input(struct hda_codec *codec)
15312{
15313 struct alc_spec *spec = codec->spec;
15314 int i;
15315
15316 for (i = 0; i < AUTO_PIN_LAST; i++) {
15317 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015318 if (nid >= 0x0c && nid <= 0x11)
15319 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015320 }
15321}
15322
15323/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015324/* return 1 if successful, 0 if the proper config is not found,
15325 * or a negative error code
15326 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015327static int alc861_parse_auto_config(struct hda_codec *codec)
15328{
15329 struct alc_spec *spec = codec->spec;
15330 int err;
15331 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15332
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015333 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15334 alc861_ignore);
15335 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015336 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015337 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015338 return 0; /* can't find valid BIOS pin config */
15339
Takashi Iwai1c209302009-07-22 15:17:45 +020015340 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015341 if (err < 0)
15342 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015343 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015344 if (err < 0)
15345 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015346 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015347 if (err < 0)
15348 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015349 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015350 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015351 return err;
15352
15353 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15354
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015355 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015356 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15357
Takashi Iwai603c4012008-07-30 15:01:44 +020015358 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015359 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015360
Takashi Iwaid88897e2008-10-31 15:01:37 +010015361 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015362
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015363 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015364 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015365
15366 spec->adc_nids = alc861_adc_nids;
15367 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015368 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015369
Kailang Yang6227cdc2010-02-25 08:36:52 +010015370 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015371
Kailang Yangdf694da2005-12-05 19:42:22 +010015372 return 1;
15373}
15374
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015375/* additional initialization for auto-configuration model */
15376static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015377{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015378 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015379 alc861_auto_init_multi_out(codec);
15380 alc861_auto_init_hp_out(codec);
15381 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015382 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015383 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015384}
15385
Takashi Iwaicb53c622007-08-10 17:21:45 +020015386#ifdef CONFIG_SND_HDA_POWER_SAVE
15387static struct hda_amp_list alc861_loopbacks[] = {
15388 { 0x15, HDA_INPUT, 0 },
15389 { 0x15, HDA_INPUT, 1 },
15390 { 0x15, HDA_INPUT, 2 },
15391 { 0x15, HDA_INPUT, 3 },
15392 { } /* end */
15393};
15394#endif
15395
Kailang Yangdf694da2005-12-05 19:42:22 +010015396
15397/*
15398 * configuration and preset
15399 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015400static const char *alc861_models[ALC861_MODEL_LAST] = {
15401 [ALC861_3ST] = "3stack",
15402 [ALC660_3ST] = "3stack-660",
15403 [ALC861_3ST_DIG] = "3stack-dig",
15404 [ALC861_6ST_DIG] = "6stack-dig",
15405 [ALC861_UNIWILL_M31] = "uniwill-m31",
15406 [ALC861_TOSHIBA] = "toshiba",
15407 [ALC861_ASUS] = "asus",
15408 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15409 [ALC861_AUTO] = "auto",
15410};
15411
15412static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015413 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015414 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15415 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15416 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015417 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015418 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015419 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015420 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15421 * Any other models that need this preset?
15422 */
15423 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015424 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15425 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015426 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15427 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15428 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15429 /* FIXME: the below seems conflict */
15430 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15431 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15432 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015433 {}
15434};
15435
15436static struct alc_config_preset alc861_presets[] = {
15437 [ALC861_3ST] = {
15438 .mixers = { alc861_3ST_mixer },
15439 .init_verbs = { alc861_threestack_init_verbs },
15440 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15441 .dac_nids = alc861_dac_nids,
15442 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15443 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015444 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015445 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15446 .adc_nids = alc861_adc_nids,
15447 .input_mux = &alc861_capture_source,
15448 },
15449 [ALC861_3ST_DIG] = {
15450 .mixers = { alc861_base_mixer },
15451 .init_verbs = { alc861_threestack_init_verbs },
15452 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15453 .dac_nids = alc861_dac_nids,
15454 .dig_out_nid = ALC861_DIGOUT_NID,
15455 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15456 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015457 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015458 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15459 .adc_nids = alc861_adc_nids,
15460 .input_mux = &alc861_capture_source,
15461 },
15462 [ALC861_6ST_DIG] = {
15463 .mixers = { alc861_base_mixer },
15464 .init_verbs = { alc861_base_init_verbs },
15465 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15466 .dac_nids = alc861_dac_nids,
15467 .dig_out_nid = ALC861_DIGOUT_NID,
15468 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15469 .channel_mode = alc861_8ch_modes,
15470 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15471 .adc_nids = alc861_adc_nids,
15472 .input_mux = &alc861_capture_source,
15473 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015474 [ALC660_3ST] = {
15475 .mixers = { alc861_3ST_mixer },
15476 .init_verbs = { alc861_threestack_init_verbs },
15477 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15478 .dac_nids = alc660_dac_nids,
15479 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15480 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015481 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015482 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15483 .adc_nids = alc861_adc_nids,
15484 .input_mux = &alc861_capture_source,
15485 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015486 [ALC861_UNIWILL_M31] = {
15487 .mixers = { alc861_uniwill_m31_mixer },
15488 .init_verbs = { alc861_uniwill_m31_init_verbs },
15489 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15490 .dac_nids = alc861_dac_nids,
15491 .dig_out_nid = ALC861_DIGOUT_NID,
15492 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15493 .channel_mode = alc861_uniwill_m31_modes,
15494 .need_dac_fix = 1,
15495 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15496 .adc_nids = alc861_adc_nids,
15497 .input_mux = &alc861_capture_source,
15498 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015499 [ALC861_TOSHIBA] = {
15500 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015501 .init_verbs = { alc861_base_init_verbs,
15502 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015503 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15504 .dac_nids = alc861_dac_nids,
15505 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15506 .channel_mode = alc883_3ST_2ch_modes,
15507 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15508 .adc_nids = alc861_adc_nids,
15509 .input_mux = &alc861_capture_source,
15510 .unsol_event = alc861_toshiba_unsol_event,
15511 .init_hook = alc861_toshiba_automute,
15512 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015513 [ALC861_ASUS] = {
15514 .mixers = { alc861_asus_mixer },
15515 .init_verbs = { alc861_asus_init_verbs },
15516 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15517 .dac_nids = alc861_dac_nids,
15518 .dig_out_nid = ALC861_DIGOUT_NID,
15519 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15520 .channel_mode = alc861_asus_modes,
15521 .need_dac_fix = 1,
15522 .hp_nid = 0x06,
15523 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15524 .adc_nids = alc861_adc_nids,
15525 .input_mux = &alc861_capture_source,
15526 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015527 [ALC861_ASUS_LAPTOP] = {
15528 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15529 .init_verbs = { alc861_asus_init_verbs,
15530 alc861_asus_laptop_init_verbs },
15531 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15532 .dac_nids = alc861_dac_nids,
15533 .dig_out_nid = ALC861_DIGOUT_NID,
15534 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15535 .channel_mode = alc883_3ST_2ch_modes,
15536 .need_dac_fix = 1,
15537 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15538 .adc_nids = alc861_adc_nids,
15539 .input_mux = &alc861_capture_source,
15540 },
15541};
Kailang Yangdf694da2005-12-05 19:42:22 +010015542
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015543/* Pin config fixes */
15544enum {
15545 PINFIX_FSC_AMILO_PI1505,
15546};
15547
15548static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15549 { 0x0b, 0x0221101f }, /* HP */
15550 { 0x0f, 0x90170310 }, /* speaker */
15551 { }
15552};
15553
15554static const struct alc_fixup alc861_fixups[] = {
15555 [PINFIX_FSC_AMILO_PI1505] = {
15556 .pins = alc861_fsc_amilo_pi1505_pinfix
15557 },
15558};
15559
15560static struct snd_pci_quirk alc861_fixup_tbl[] = {
15561 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15562 {}
15563};
Kailang Yangdf694da2005-12-05 19:42:22 +010015564
15565static int patch_alc861(struct hda_codec *codec)
15566{
15567 struct alc_spec *spec;
15568 int board_config;
15569 int err;
15570
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015571 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015572 if (spec == NULL)
15573 return -ENOMEM;
15574
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015575 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015576
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015577 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15578 alc861_models,
15579 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015580
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015581 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015582 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15583 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015584 board_config = ALC861_AUTO;
15585 }
15586
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015587 if (board_config == ALC861_AUTO)
15588 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015589
Kailang Yangdf694da2005-12-05 19:42:22 +010015590 if (board_config == ALC861_AUTO) {
15591 /* automatic parse from the BIOS config */
15592 err = alc861_parse_auto_config(codec);
15593 if (err < 0) {
15594 alc_free(codec);
15595 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015596 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015597 printk(KERN_INFO
15598 "hda_codec: Cannot set up configuration "
15599 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015600 board_config = ALC861_3ST_DIG;
15601 }
15602 }
15603
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015604 err = snd_hda_attach_beep_device(codec, 0x23);
15605 if (err < 0) {
15606 alc_free(codec);
15607 return err;
15608 }
15609
Kailang Yangdf694da2005-12-05 19:42:22 +010015610 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015611 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015612
Kailang Yangdf694da2005-12-05 19:42:22 +010015613 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15614 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15615
Kailang Yangdf694da2005-12-05 19:42:22 +010015616 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15617 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15618
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015619 if (!spec->cap_mixer)
15620 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015621 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15622
Takashi Iwai2134ea42008-01-10 16:53:55 +010015623 spec->vmaster_nid = 0x03;
15624
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015625 if (board_config == ALC861_AUTO)
15626 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15627
Kailang Yangdf694da2005-12-05 19:42:22 +010015628 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015629 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015630 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015631#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015632 spec->power_hook = alc_power_eapd;
15633#endif
15634 }
15635#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015636 if (!spec->loopback.amplist)
15637 spec->loopback.amplist = alc861_loopbacks;
15638#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015639
Kailang Yangdf694da2005-12-05 19:42:22 +010015640 return 0;
15641}
15642
15643/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015644 * ALC861-VD support
15645 *
15646 * Based on ALC882
15647 *
15648 * In addition, an independent DAC
15649 */
15650#define ALC861VD_DIGOUT_NID 0x06
15651
15652static hda_nid_t alc861vd_dac_nids[4] = {
15653 /* front, surr, clfe, side surr */
15654 0x02, 0x03, 0x04, 0x05
15655};
15656
15657/* dac_nids for ALC660vd are in a different order - according to
15658 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015659 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015660 * of ALC660vd codecs, but for now there is only 3stack mixer
15661 * - and it is the same as in 861vd.
15662 * adc_nids in ALC660vd are (is) the same as in 861vd
15663 */
15664static hda_nid_t alc660vd_dac_nids[3] = {
15665 /* front, rear, clfe, rear_surr */
15666 0x02, 0x04, 0x03
15667};
15668
15669static hda_nid_t alc861vd_adc_nids[1] = {
15670 /* ADC0 */
15671 0x09,
15672};
15673
Takashi Iwaie1406342008-02-11 18:32:32 +010015674static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15675
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015676/* input MUX */
15677/* FIXME: should be a matrix-type input source selection */
15678static struct hda_input_mux alc861vd_capture_source = {
15679 .num_items = 4,
15680 .items = {
15681 { "Mic", 0x0 },
15682 { "Front Mic", 0x1 },
15683 { "Line", 0x2 },
15684 { "CD", 0x4 },
15685 },
15686};
15687
Kailang Yang272a5272007-05-14 11:00:38 +020015688static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015689 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015690 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015691 { "Ext Mic", 0x0 },
15692 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015693 },
15694};
15695
Kailang Yangd1a991a2007-08-15 16:21:59 +020015696static struct hda_input_mux alc861vd_hp_capture_source = {
15697 .num_items = 2,
15698 .items = {
15699 { "Front Mic", 0x0 },
15700 { "ATAPI Mic", 0x1 },
15701 },
15702};
15703
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015704/*
15705 * 2ch mode
15706 */
15707static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15708 { 2, NULL }
15709};
15710
15711/*
15712 * 6ch mode
15713 */
15714static struct hda_verb alc861vd_6stack_ch6_init[] = {
15715 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15716 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15717 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15718 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15719 { } /* end */
15720};
15721
15722/*
15723 * 8ch mode
15724 */
15725static struct hda_verb alc861vd_6stack_ch8_init[] = {
15726 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15727 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15728 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15729 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15730 { } /* end */
15731};
15732
15733static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15734 { 6, alc861vd_6stack_ch6_init },
15735 { 8, alc861vd_6stack_ch8_init },
15736};
15737
15738static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15739 {
15740 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15741 .name = "Channel Mode",
15742 .info = alc_ch_mode_info,
15743 .get = alc_ch_mode_get,
15744 .put = alc_ch_mode_put,
15745 },
15746 { } /* end */
15747};
15748
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015749/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15750 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15751 */
15752static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15753 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15754 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15755
15756 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15757 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15758
15759 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15760 HDA_OUTPUT),
15761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15762 HDA_OUTPUT),
15763 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15764 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15765
15766 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15767 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15768
15769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15770
15771 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15774
15775 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15776 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15777 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15778
15779 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15780 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15781
15782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15784
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015785 { } /* end */
15786};
15787
15788static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15789 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15790 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15791
15792 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15793
15794 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15797
15798 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15801
15802 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15803 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15804
15805 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15806 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15807
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015808 { } /* end */
15809};
15810
Kailang Yangbdd148a2007-05-08 15:19:08 +020015811static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15812 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15813 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15814 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15815
15816 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15817
15818 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15821
15822 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15825
15826 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15827 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15828
15829 { } /* end */
15830};
15831
Tobin Davisb419f342008-03-07 11:57:51 +010015832/* Pin assignment: Speaker=0x14, HP = 0x15,
15833 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015834 */
15835static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015836 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15837 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15839 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015840 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15841 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15842 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15843 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15844 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15845 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015846 { } /* end */
15847};
15848
Kailang Yangd1a991a2007-08-15 16:21:59 +020015849/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15850 * Front Mic=0x18, ATAPI Mic = 0x19,
15851 */
15852static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15853 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15854 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15855 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15856 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15857 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15858 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15859 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15860 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015861
Kailang Yangd1a991a2007-08-15 16:21:59 +020015862 { } /* end */
15863};
15864
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015865/*
15866 * generic initialization of ADC, input mixers and output mixers
15867 */
15868static struct hda_verb alc861vd_volume_init_verbs[] = {
15869 /*
15870 * Unmute ADC0 and set the default input to mic-in
15871 */
15872 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15873 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15874
15875 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15876 * the analog-loopback mixer widget
15877 */
15878 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015884
15885 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015886 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015890
15891 /*
15892 * Set up output mixers (0x02 - 0x05)
15893 */
15894 /* set vol=0 to output mixers */
15895 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15896 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15897 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15898 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15899
15900 /* set up input amps for analog loopback */
15901 /* Amp Indices: DAC = 0, mixer = 1 */
15902 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15904 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15905 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15906 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15907 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15909 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15910
15911 { }
15912};
15913
15914/*
15915 * 3-stack pin configuration:
15916 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15917 */
15918static struct hda_verb alc861vd_3stack_init_verbs[] = {
15919 /*
15920 * Set pin mode and muting
15921 */
15922 /* set front pin widgets 0x14 for output */
15923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15925 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15926
15927 /* Mic (rear) pin: input vref at 80% */
15928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15930 /* Front Mic pin: input vref at 80% */
15931 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15932 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15933 /* Line In pin: input */
15934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15936 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15938 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15939 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15940 /* CD pin widget for input */
15941 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15942
15943 { }
15944};
15945
15946/*
15947 * 6-stack pin configuration:
15948 */
15949static struct hda_verb alc861vd_6stack_init_verbs[] = {
15950 /*
15951 * Set pin mode and muting
15952 */
15953 /* set front pin widgets 0x14 for output */
15954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15956 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15957
15958 /* Rear Pin: output 1 (0x0d) */
15959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15961 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15962 /* CLFE Pin: output 2 (0x0e) */
15963 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15964 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15965 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15966 /* Side Pin: output 3 (0x0f) */
15967 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15968 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15969 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15970
15971 /* Mic (rear) pin: input vref at 80% */
15972 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15973 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15974 /* Front Mic pin: input vref at 80% */
15975 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15976 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15977 /* Line In pin: input */
15978 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15979 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15980 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15983 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15984 /* CD pin widget for input */
15985 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15986
15987 { }
15988};
15989
Kailang Yangbdd148a2007-05-08 15:19:08 +020015990static struct hda_verb alc861vd_eapd_verbs[] = {
15991 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15992 { }
15993};
15994
Kailang Yangf9423e72008-05-27 12:32:25 +020015995static struct hda_verb alc660vd_eapd_verbs[] = {
15996 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15997 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15998 { }
15999};
16000
Kailang Yangbdd148a2007-05-08 15:19:08 +020016001static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16003 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16005 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016006 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016007 {}
16008};
16009
Kailang Yangbdd148a2007-05-08 15:19:08 +020016010static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16011{
16012 unsigned int present;
16013 unsigned char bits;
16014
Wu Fengguang864f92b2009-11-18 12:38:02 +080016015 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016016 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016017
Takashi Iwai47fd8302007-08-10 17:11:07 +020016018 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16019 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016020}
16021
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016022static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016023{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016024 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016025 spec->autocfg.hp_pins[0] = 0x1b;
16026 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016027}
16028
16029static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16030{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016031 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016032 alc861vd_lenovo_mic_automute(codec);
16033}
16034
16035static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16036 unsigned int res)
16037{
16038 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016039 case ALC880_MIC_EVENT:
16040 alc861vd_lenovo_mic_automute(codec);
16041 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016042 default:
16043 alc_automute_amp_unsol_event(codec, res);
16044 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016045 }
16046}
16047
Kailang Yang272a5272007-05-14 11:00:38 +020016048static struct hda_verb alc861vd_dallas_verbs[] = {
16049 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16050 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16051 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16052 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16053
16054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16060 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16061 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016062
Kailang Yang272a5272007-05-14 11:00:38 +020016063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16064 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16067 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16068 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16069 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16070 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16071
16072 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16074 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16075 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16076 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16077 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16078 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16079 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16080
16081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16084 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16085
16086 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016087 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016088 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16089
16090 { } /* end */
16091};
16092
16093/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016094static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016095{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016096 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016097
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016098 spec->autocfg.hp_pins[0] = 0x15;
16099 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016100}
16101
Takashi Iwaicb53c622007-08-10 17:21:45 +020016102#ifdef CONFIG_SND_HDA_POWER_SAVE
16103#define alc861vd_loopbacks alc880_loopbacks
16104#endif
16105
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016106/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016107#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16108#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16109#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16110#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16111
16112/*
16113 * configuration and preset
16114 */
16115static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16116 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016117 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016118 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016119 [ALC861VD_3ST] = "3stack",
16120 [ALC861VD_3ST_DIG] = "3stack-digout",
16121 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016122 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016123 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016124 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016125 [ALC861VD_AUTO] = "auto",
16126};
16127
16128static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016129 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16130 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016131 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016132 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016133 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016134 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016135 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016136 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016137 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016138 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016139 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016140 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016141 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016142 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016143 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016144 {}
16145};
16146
16147static struct alc_config_preset alc861vd_presets[] = {
16148 [ALC660VD_3ST] = {
16149 .mixers = { alc861vd_3st_mixer },
16150 .init_verbs = { alc861vd_volume_init_verbs,
16151 alc861vd_3stack_init_verbs },
16152 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16153 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016154 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16155 .channel_mode = alc861vd_3stack_2ch_modes,
16156 .input_mux = &alc861vd_capture_source,
16157 },
Mike Crash6963f842007-06-25 12:12:51 +020016158 [ALC660VD_3ST_DIG] = {
16159 .mixers = { alc861vd_3st_mixer },
16160 .init_verbs = { alc861vd_volume_init_verbs,
16161 alc861vd_3stack_init_verbs },
16162 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16163 .dac_nids = alc660vd_dac_nids,
16164 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016165 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16166 .channel_mode = alc861vd_3stack_2ch_modes,
16167 .input_mux = &alc861vd_capture_source,
16168 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016169 [ALC861VD_3ST] = {
16170 .mixers = { alc861vd_3st_mixer },
16171 .init_verbs = { alc861vd_volume_init_verbs,
16172 alc861vd_3stack_init_verbs },
16173 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16174 .dac_nids = alc861vd_dac_nids,
16175 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16176 .channel_mode = alc861vd_3stack_2ch_modes,
16177 .input_mux = &alc861vd_capture_source,
16178 },
16179 [ALC861VD_3ST_DIG] = {
16180 .mixers = { alc861vd_3st_mixer },
16181 .init_verbs = { alc861vd_volume_init_verbs,
16182 alc861vd_3stack_init_verbs },
16183 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16184 .dac_nids = alc861vd_dac_nids,
16185 .dig_out_nid = ALC861VD_DIGOUT_NID,
16186 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16187 .channel_mode = alc861vd_3stack_2ch_modes,
16188 .input_mux = &alc861vd_capture_source,
16189 },
16190 [ALC861VD_6ST_DIG] = {
16191 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16192 .init_verbs = { alc861vd_volume_init_verbs,
16193 alc861vd_6stack_init_verbs },
16194 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16195 .dac_nids = alc861vd_dac_nids,
16196 .dig_out_nid = ALC861VD_DIGOUT_NID,
16197 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16198 .channel_mode = alc861vd_6stack_modes,
16199 .input_mux = &alc861vd_capture_source,
16200 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016201 [ALC861VD_LENOVO] = {
16202 .mixers = { alc861vd_lenovo_mixer },
16203 .init_verbs = { alc861vd_volume_init_verbs,
16204 alc861vd_3stack_init_verbs,
16205 alc861vd_eapd_verbs,
16206 alc861vd_lenovo_unsol_verbs },
16207 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16208 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016209 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16210 .channel_mode = alc861vd_3stack_2ch_modes,
16211 .input_mux = &alc861vd_capture_source,
16212 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016213 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016214 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016215 },
Kailang Yang272a5272007-05-14 11:00:38 +020016216 [ALC861VD_DALLAS] = {
16217 .mixers = { alc861vd_dallas_mixer },
16218 .init_verbs = { alc861vd_dallas_verbs },
16219 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16220 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016221 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16222 .channel_mode = alc861vd_3stack_2ch_modes,
16223 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016224 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016225 .setup = alc861vd_dallas_setup,
16226 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016227 },
16228 [ALC861VD_HP] = {
16229 .mixers = { alc861vd_hp_mixer },
16230 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16231 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16232 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016233 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016234 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16235 .channel_mode = alc861vd_3stack_2ch_modes,
16236 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016237 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016238 .setup = alc861vd_dallas_setup,
16239 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016240 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016241 [ALC660VD_ASUS_V1S] = {
16242 .mixers = { alc861vd_lenovo_mixer },
16243 .init_verbs = { alc861vd_volume_init_verbs,
16244 alc861vd_3stack_init_verbs,
16245 alc861vd_eapd_verbs,
16246 alc861vd_lenovo_unsol_verbs },
16247 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16248 .dac_nids = alc660vd_dac_nids,
16249 .dig_out_nid = ALC861VD_DIGOUT_NID,
16250 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16251 .channel_mode = alc861vd_3stack_2ch_modes,
16252 .input_mux = &alc861vd_capture_source,
16253 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016254 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016255 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016256 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016257};
16258
16259/*
16260 * BIOS auto configuration
16261 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016262static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16263 const struct auto_pin_cfg *cfg)
16264{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016265 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016266}
16267
16268
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016269static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16270 hda_nid_t nid, int pin_type, int dac_idx)
16271{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016272 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016273}
16274
16275static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16276{
16277 struct alc_spec *spec = codec->spec;
16278 int i;
16279
16280 for (i = 0; i <= HDA_SIDE; i++) {
16281 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016282 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016283 if (nid)
16284 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016285 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016286 }
16287}
16288
16289
16290static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16291{
16292 struct alc_spec *spec = codec->spec;
16293 hda_nid_t pin;
16294
16295 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016296 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016297 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016298 pin = spec->autocfg.speaker_pins[0];
16299 if (pin)
16300 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016301}
16302
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016303#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16304
16305static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16306{
16307 struct alc_spec *spec = codec->spec;
16308 int i;
16309
16310 for (i = 0; i < AUTO_PIN_LAST; i++) {
16311 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016312 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016313 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016314 if (nid != ALC861VD_PIN_CD_NID &&
16315 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016316 snd_hda_codec_write(codec, nid, 0,
16317 AC_VERB_SET_AMP_GAIN_MUTE,
16318 AMP_OUT_MUTE);
16319 }
16320 }
16321}
16322
Takashi Iwaif511b012008-08-15 16:46:42 +020016323#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16324
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016325#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16326#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16327
16328/* add playback controls from the parsed DAC table */
16329/* Based on ALC880 version. But ALC861VD has separate,
16330 * different NIDs for mute/unmute switch and volume control */
16331static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16332 const struct auto_pin_cfg *cfg)
16333{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016334 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16335 hda_nid_t nid_v, nid_s;
16336 int i, err;
16337
16338 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016339 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016340 continue;
16341 nid_v = alc861vd_idx_to_mixer_vol(
16342 alc880_dac_to_idx(
16343 spec->multiout.dac_nids[i]));
16344 nid_s = alc861vd_idx_to_mixer_switch(
16345 alc880_dac_to_idx(
16346 spec->multiout.dac_nids[i]));
16347
16348 if (i == 2) {
16349 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016350 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16351 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016352 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16353 HDA_OUTPUT));
16354 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016355 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016356 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16357 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016358 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16359 HDA_OUTPUT));
16360 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016361 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016362 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16363 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016364 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16365 HDA_INPUT));
16366 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016367 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016368 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16369 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016370 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16371 HDA_INPUT));
16372 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016373 return err;
16374 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016375 const char *pfx;
16376 if (cfg->line_outs == 1 &&
16377 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16378 if (!cfg->hp_pins)
16379 pfx = "Speaker";
16380 else
16381 pfx = "PCM";
16382 } else
16383 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016384 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016385 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16386 HDA_OUTPUT));
16387 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016388 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016389 if (cfg->line_outs == 1 &&
16390 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16391 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016392 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016393 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016394 HDA_INPUT));
16395 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016396 return err;
16397 }
16398 }
16399 return 0;
16400}
16401
16402/* add playback controls for speaker and HP outputs */
16403/* Based on ALC880 version. But ALC861VD has separate,
16404 * different NIDs for mute/unmute switch and volume control */
16405static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16406 hda_nid_t pin, const char *pfx)
16407{
16408 hda_nid_t nid_v, nid_s;
16409 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016410
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016411 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016412 return 0;
16413
16414 if (alc880_is_fixed_pin(pin)) {
16415 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16416 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016417 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016418 spec->multiout.hp_nid = nid_v;
16419 else
16420 spec->multiout.extra_out_nid[0] = nid_v;
16421 /* control HP volume/switch on the output mixer amp */
16422 nid_v = alc861vd_idx_to_mixer_vol(
16423 alc880_fixed_pin_idx(pin));
16424 nid_s = alc861vd_idx_to_mixer_switch(
16425 alc880_fixed_pin_idx(pin));
16426
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016427 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016428 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16429 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016430 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016431 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016432 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16433 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016434 return err;
16435 } else if (alc880_is_multi_pin(pin)) {
16436 /* set manual connection */
16437 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016438 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016439 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16440 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016441 return err;
16442 }
16443 return 0;
16444}
16445
16446/* parse the BIOS configuration and set up the alc_spec
16447 * return 1 if successful, 0 if the proper config is not found,
16448 * or a negative error code
16449 * Based on ALC880 version - had to change it to override
16450 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16451static int alc861vd_parse_auto_config(struct hda_codec *codec)
16452{
16453 struct alc_spec *spec = codec->spec;
16454 int err;
16455 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16456
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016457 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16458 alc861vd_ignore);
16459 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016460 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016461 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016462 return 0; /* can't find valid BIOS pin config */
16463
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016464 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16465 if (err < 0)
16466 return err;
16467 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16468 if (err < 0)
16469 return err;
16470 err = alc861vd_auto_create_extra_out(spec,
16471 spec->autocfg.speaker_pins[0],
16472 "Speaker");
16473 if (err < 0)
16474 return err;
16475 err = alc861vd_auto_create_extra_out(spec,
16476 spec->autocfg.hp_pins[0],
16477 "Headphone");
16478 if (err < 0)
16479 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016480 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016481 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016482 return err;
16483
16484 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16485
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016486 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016487 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16488
Takashi Iwai603c4012008-07-30 15:01:44 +020016489 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016490 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016491
Takashi Iwaid88897e2008-10-31 15:01:37 +010016492 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016493
16494 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016495 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016496
Takashi Iwai776e1842007-08-29 15:07:11 +020016497 err = alc_auto_add_mic_boost(codec);
16498 if (err < 0)
16499 return err;
16500
Kailang Yang6227cdc2010-02-25 08:36:52 +010016501 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016502
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016503 return 1;
16504}
16505
16506/* additional initialization for auto-configuration model */
16507static void alc861vd_auto_init(struct hda_codec *codec)
16508{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016509 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016510 alc861vd_auto_init_multi_out(codec);
16511 alc861vd_auto_init_hp_out(codec);
16512 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016513 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016514 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016515 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016516}
16517
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016518enum {
16519 ALC660VD_FIX_ASUS_GPIO1
16520};
16521
16522/* reset GPIO1 */
16523static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16524 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16525 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16526 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16527 { }
16528};
16529
16530static const struct alc_fixup alc861vd_fixups[] = {
16531 [ALC660VD_FIX_ASUS_GPIO1] = {
16532 .verbs = alc660vd_fix_asus_gpio1_verbs,
16533 },
16534};
16535
16536static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16537 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16538 {}
16539};
16540
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016541static int patch_alc861vd(struct hda_codec *codec)
16542{
16543 struct alc_spec *spec;
16544 int err, board_config;
16545
16546 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16547 if (spec == NULL)
16548 return -ENOMEM;
16549
16550 codec->spec = spec;
16551
16552 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16553 alc861vd_models,
16554 alc861vd_cfg_tbl);
16555
16556 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016557 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16558 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016559 board_config = ALC861VD_AUTO;
16560 }
16561
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016562 if (board_config == ALC861VD_AUTO)
16563 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016564
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016565 if (board_config == ALC861VD_AUTO) {
16566 /* automatic parse from the BIOS config */
16567 err = alc861vd_parse_auto_config(codec);
16568 if (err < 0) {
16569 alc_free(codec);
16570 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016571 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016572 printk(KERN_INFO
16573 "hda_codec: Cannot set up configuration "
16574 "from BIOS. Using base mode...\n");
16575 board_config = ALC861VD_3ST;
16576 }
16577 }
16578
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016579 err = snd_hda_attach_beep_device(codec, 0x23);
16580 if (err < 0) {
16581 alc_free(codec);
16582 return err;
16583 }
16584
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016585 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016586 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016587
Kailang Yang2f893282008-05-27 12:14:47 +020016588 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016589 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016590 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016591 }
16592
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016593 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16594 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16595
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016596 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16597 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16598
Takashi Iwaidd704692009-08-11 08:45:11 +020016599 if (!spec->adc_nids) {
16600 spec->adc_nids = alc861vd_adc_nids;
16601 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16602 }
16603 if (!spec->capsrc_nids)
16604 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016605
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016606 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016607 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016608
Takashi Iwai2134ea42008-01-10 16:53:55 +010016609 spec->vmaster_nid = 0x02;
16610
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016611 if (board_config == ALC861VD_AUTO)
16612 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16613
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016614 codec->patch_ops = alc_patch_ops;
16615
16616 if (board_config == ALC861VD_AUTO)
16617 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016618#ifdef CONFIG_SND_HDA_POWER_SAVE
16619 if (!spec->loopback.amplist)
16620 spec->loopback.amplist = alc861vd_loopbacks;
16621#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016622
16623 return 0;
16624}
16625
16626/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016627 * ALC662 support
16628 *
16629 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16630 * configuration. Each pin widget can choose any input DACs and a mixer.
16631 * Each ADC is connected from a mixer of all inputs. This makes possible
16632 * 6-channel independent captures.
16633 *
16634 * In addition, an independent DAC for the multi-playback (not used in this
16635 * driver yet).
16636 */
16637#define ALC662_DIGOUT_NID 0x06
16638#define ALC662_DIGIN_NID 0x0a
16639
16640static hda_nid_t alc662_dac_nids[4] = {
16641 /* front, rear, clfe, rear_surr */
16642 0x02, 0x03, 0x04
16643};
16644
Kailang Yang622e84c2009-04-21 07:39:04 +020016645static hda_nid_t alc272_dac_nids[2] = {
16646 0x02, 0x03
16647};
16648
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016649static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016650 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016651 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016652};
Takashi Iwaie1406342008-02-11 18:32:32 +010016653
Kailang Yang622e84c2009-04-21 07:39:04 +020016654static hda_nid_t alc272_adc_nids[1] = {
16655 /* ADC1-2 */
16656 0x08,
16657};
16658
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016659static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016660static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16661
Takashi Iwaie1406342008-02-11 18:32:32 +010016662
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016663/* input MUX */
16664/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016665static struct hda_input_mux alc662_capture_source = {
16666 .num_items = 4,
16667 .items = {
16668 { "Mic", 0x0 },
16669 { "Front Mic", 0x1 },
16670 { "Line", 0x2 },
16671 { "CD", 0x4 },
16672 },
16673};
16674
16675static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16676 .num_items = 2,
16677 .items = {
16678 { "Mic", 0x1 },
16679 { "Line", 0x2 },
16680 },
16681};
Kailang Yang291702f2007-10-16 14:28:03 +020016682
Kailang Yang6dda9f42008-05-27 12:05:31 +020016683static struct hda_input_mux alc663_capture_source = {
16684 .num_items = 3,
16685 .items = {
16686 { "Mic", 0x0 },
16687 { "Front Mic", 0x1 },
16688 { "Line", 0x2 },
16689 },
16690};
16691
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016692#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016693static struct hda_input_mux alc272_nc10_capture_source = {
16694 .num_items = 16,
16695 .items = {
16696 { "Autoselect Mic", 0x0 },
16697 { "Internal Mic", 0x1 },
16698 { "In-0x02", 0x2 },
16699 { "In-0x03", 0x3 },
16700 { "In-0x04", 0x4 },
16701 { "In-0x05", 0x5 },
16702 { "In-0x06", 0x6 },
16703 { "In-0x07", 0x7 },
16704 { "In-0x08", 0x8 },
16705 { "In-0x09", 0x9 },
16706 { "In-0x0a", 0x0a },
16707 { "In-0x0b", 0x0b },
16708 { "In-0x0c", 0x0c },
16709 { "In-0x0d", 0x0d },
16710 { "In-0x0e", 0x0e },
16711 { "In-0x0f", 0x0f },
16712 },
16713};
16714#endif
16715
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016716/*
16717 * 2ch mode
16718 */
16719static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16720 { 2, NULL }
16721};
16722
16723/*
16724 * 2ch mode
16725 */
16726static struct hda_verb alc662_3ST_ch2_init[] = {
16727 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16728 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16729 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16730 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16731 { } /* end */
16732};
16733
16734/*
16735 * 6ch mode
16736 */
16737static struct hda_verb alc662_3ST_ch6_init[] = {
16738 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16739 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16740 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16741 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16742 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16743 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16744 { } /* end */
16745};
16746
16747static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16748 { 2, alc662_3ST_ch2_init },
16749 { 6, alc662_3ST_ch6_init },
16750};
16751
16752/*
16753 * 2ch mode
16754 */
16755static struct hda_verb alc662_sixstack_ch6_init[] = {
16756 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16757 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16758 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16759 { } /* end */
16760};
16761
16762/*
16763 * 6ch mode
16764 */
16765static struct hda_verb alc662_sixstack_ch8_init[] = {
16766 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16767 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16768 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16769 { } /* end */
16770};
16771
16772static struct hda_channel_mode alc662_5stack_modes[2] = {
16773 { 2, alc662_sixstack_ch6_init },
16774 { 6, alc662_sixstack_ch8_init },
16775};
16776
16777/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16778 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16779 */
16780
16781static struct snd_kcontrol_new alc662_base_mixer[] = {
16782 /* output mixer control */
16783 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016784 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016785 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016786 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016787 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16788 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016789 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16790 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16792
16793 /*Input mixer control */
16794 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16795 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16796 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16797 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16798 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16799 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016802 { } /* end */
16803};
16804
16805static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16806 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016807 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016808 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16809 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16810 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16811 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16812 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016817 { } /* end */
16818};
16819
16820static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16821 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016822 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016823 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016824 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016825 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16826 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016827 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16828 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16830 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16831 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16832 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16833 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16836 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16837 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016838 { } /* end */
16839};
16840
16841static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16842 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16843 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016844 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16845 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016851 { } /* end */
16852};
16853
Kailang Yang291702f2007-10-16 14:28:03 +020016854static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016855 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16856 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016857
16858 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16859 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16860 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16861
16862 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16863 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16864 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16865 { } /* end */
16866};
16867
Kailang Yang8c427222008-01-10 13:03:59 +010016868static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016869 ALC262_HIPPO_MASTER_SWITCH,
16870 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016871 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016872 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16873 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016874 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16875 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16876 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16878 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16879 { } /* end */
16880};
16881
Kailang Yangf1d4e282008-08-26 14:03:29 +020016882static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16883 .ops = &snd_hda_bind_vol,
16884 .values = {
16885 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16886 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16887 0
16888 },
16889};
16890
16891static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16892 .ops = &snd_hda_bind_sw,
16893 .values = {
16894 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16895 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16896 0
16897 },
16898};
16899
Kailang Yang6dda9f42008-05-27 12:05:31 +020016900static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016901 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16902 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16905 { } /* end */
16906};
16907
16908static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16909 .ops = &snd_hda_bind_sw,
16910 .values = {
16911 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16912 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16913 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16914 0
16915 },
16916};
16917
16918static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16919 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16920 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16922 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16923 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16924 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16925
16926 { } /* end */
16927};
16928
16929static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16930 .ops = &snd_hda_bind_sw,
16931 .values = {
16932 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16933 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16934 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16935 0
16936 },
16937};
16938
16939static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16940 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16941 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16944 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16945 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16946 { } /* end */
16947};
16948
16949static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016950 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16951 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016952 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16955 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16956 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16957 { } /* end */
16958};
16959
16960static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16961 .ops = &snd_hda_bind_vol,
16962 .values = {
16963 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16964 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16965 0
16966 },
16967};
16968
16969static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16970 .ops = &snd_hda_bind_sw,
16971 .values = {
16972 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16973 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16974 0
16975 },
16976};
16977
16978static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16979 HDA_BIND_VOL("Master Playback Volume",
16980 &alc663_asus_two_bind_master_vol),
16981 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16982 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016986 { } /* end */
16987};
16988
16989static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16990 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16991 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16992 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16995 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016996 { } /* end */
16997};
16998
16999static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17000 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17001 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17002 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17003 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17005
17006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17008 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17009 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17010 { } /* end */
17011};
17012
17013static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17014 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17015 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17016 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17017
17018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17020 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17021 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17024 { } /* end */
17025};
17026
Kailang Yangebb83ee2009-12-17 12:23:00 +010017027static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17028 .ops = &snd_hda_bind_sw,
17029 .values = {
17030 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17031 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17032 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17033 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17034 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17035 0
17036 },
17037};
17038
17039static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17040 .ops = &snd_hda_bind_sw,
17041 .values = {
17042 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17043 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17044 0
17045 },
17046};
17047
17048static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17049 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17050 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17051 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17052 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17053 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17054 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17055 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17056 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17057 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17058 { } /* end */
17059};
17060
17061static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17062 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17063 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17064 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17065 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17066 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17069 { } /* end */
17070};
17071
17072
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017073static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17074 {
17075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17076 .name = "Channel Mode",
17077 .info = alc_ch_mode_info,
17078 .get = alc_ch_mode_get,
17079 .put = alc_ch_mode_put,
17080 },
17081 { } /* end */
17082};
17083
17084static struct hda_verb alc662_init_verbs[] = {
17085 /* ADC: mute amp left and right */
17086 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17087 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017088
Kailang Yangb60dd392007-09-20 12:50:29 +020017089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17092 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017095
17096 /* Front Pin: output 0 (0x0c) */
17097 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17098 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17099
17100 /* Rear Pin: output 1 (0x0d) */
17101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17102 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17103
17104 /* CLFE Pin: output 2 (0x0e) */
17105 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17106 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17107
17108 /* Mic (rear) pin: input vref at 80% */
17109 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17110 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17111 /* Front Mic pin: input vref at 80% */
17112 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17113 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17114 /* Line In pin: input */
17115 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17116 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17117 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17118 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17119 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17120 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17121 /* CD pin widget for input */
17122 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17123
17124 /* FIXME: use matrix-type input source selection */
17125 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17126 /* Input mixer */
17127 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017128 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017129
17130 /* always trun on EAPD */
17131 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17132 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17133
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017134 { }
17135};
17136
Kailang Yangcec27c82010-02-04 14:18:18 +010017137static struct hda_verb alc663_init_verbs[] = {
17138 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17139 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17140 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17141 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17142 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17144 { }
17145};
17146
17147static struct hda_verb alc272_init_verbs[] = {
17148 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17149 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17150 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17151 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17152 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17153 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17154 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17155 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17156 { }
17157};
17158
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017159static struct hda_verb alc662_sue_init_verbs[] = {
17160 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17161 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017162 {}
17163};
17164
17165static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17166 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17167 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17168 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017169};
17170
Kailang Yang8c427222008-01-10 13:03:59 +010017171/* Set Unsolicited Event*/
17172static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17173 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17174 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17175 {}
17176};
17177
Kailang Yang6dda9f42008-05-27 12:05:31 +020017178static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17180 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017181 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17182 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017183 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017186 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17187 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17188 {}
17189};
17190
Kailang Yangf1d4e282008-08-26 14:03:29 +020017191static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17192 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17193 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17194 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17197 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17198 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17199 {}
17200};
17201
17202static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17203 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17204 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17205 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17206 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17209 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17210 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17211 {}
17212};
17213
17214static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17216 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17217 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17220 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17222 {}
17223};
17224
17225static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17226 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17227 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17228 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17229 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17231 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17232 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17233 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17234 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17235 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17236 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17237 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17238 {}
17239};
17240
17241static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17242 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17243 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17244 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17245 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17251 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17252 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17253 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17254 {}
17255};
17256
Kailang Yang6dda9f42008-05-27 12:05:31 +020017257static struct hda_verb alc663_g71v_init_verbs[] = {
17258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17259 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17260 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17261
17262 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17263 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17264 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17265
17266 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17267 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17268 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17269 {}
17270};
17271
17272static struct hda_verb alc663_g50v_init_verbs[] = {
17273 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17274 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17275 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17276
17277 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17278 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17279 {}
17280};
17281
Kailang Yangf1d4e282008-08-26 14:03:29 +020017282static struct hda_verb alc662_ecs_init_verbs[] = {
17283 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17285 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17286 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17287 {}
17288};
17289
Kailang Yang622e84c2009-04-21 07:39:04 +020017290static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17291 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17292 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17294 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17295 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17296 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17297 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17300 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17301 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17302 {}
17303};
17304
17305static struct hda_verb alc272_dell_init_verbs[] = {
17306 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17307 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17308 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17309 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17310 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17311 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17312 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17313 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17315 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17316 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17317 {}
17318};
17319
Kailang Yangebb83ee2009-12-17 12:23:00 +010017320static struct hda_verb alc663_mode7_init_verbs[] = {
17321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17322 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17323 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17324 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17325 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17326 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17327 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17328 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17329 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17330 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17333 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17334 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17335 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17336 {}
17337};
17338
17339static struct hda_verb alc663_mode8_init_verbs[] = {
17340 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17343 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17345 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17346 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17347 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17348 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17349 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17350 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17351 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17353 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17354 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17355 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17356 {}
17357};
17358
Kailang Yangf1d4e282008-08-26 14:03:29 +020017359static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17360 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17361 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17362 { } /* end */
17363};
17364
Kailang Yang622e84c2009-04-21 07:39:04 +020017365static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17366 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17367 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17368 { } /* end */
17369};
17370
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017371static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17372{
17373 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017374 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017375
Wu Fengguang864f92b2009-11-18 12:38:02 +080017376 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017377 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017378
Takashi Iwai47fd8302007-08-10 17:11:07 +020017379 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17380 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017381}
17382
17383static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17384{
17385 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017386 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017387
Wu Fengguang864f92b2009-11-18 12:38:02 +080017388 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017389 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017390
Takashi Iwai47fd8302007-08-10 17:11:07 +020017391 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17392 HDA_AMP_MUTE, bits);
17393 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17394 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017395}
17396
17397static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17398 unsigned int res)
17399{
17400 if ((res >> 26) == ALC880_HP_EVENT)
17401 alc662_lenovo_101e_all_automute(codec);
17402 if ((res >> 26) == ALC880_FRONT_EVENT)
17403 alc662_lenovo_101e_ispeaker_automute(codec);
17404}
17405
Kailang Yang291702f2007-10-16 14:28:03 +020017406/* unsolicited event for HP jack sensing */
17407static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17408 unsigned int res)
17409{
Kailang Yang291702f2007-10-16 14:28:03 +020017410 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017411 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017412 else
17413 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017414}
17415
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017416static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017417{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017418 struct alc_spec *spec = codec->spec;
17419
17420 alc262_hippo1_setup(codec);
17421 spec->ext_mic.pin = 0x18;
17422 spec->ext_mic.mux_idx = 0;
17423 spec->int_mic.pin = 0x19;
17424 spec->int_mic.mux_idx = 1;
17425 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017426}
17427
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017428static void alc662_eeepc_inithook(struct hda_codec *codec)
17429{
17430 alc262_hippo_automute(codec);
17431 alc_mic_automute(codec);
17432}
17433
17434static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017435{
Takashi Iwai42171c12009-05-08 14:11:43 +020017436 struct alc_spec *spec = codec->spec;
17437
17438 spec->autocfg.hp_pins[0] = 0x14;
17439 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017440}
17441
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017442#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17443
Kailang Yang6dda9f42008-05-27 12:05:31 +020017444static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17445{
17446 unsigned int present;
17447 unsigned char bits;
17448
Wu Fengguang864f92b2009-11-18 12:38:02 +080017449 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017450 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017451 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017452 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017453 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017454 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017455}
17456
17457static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17458{
17459 unsigned int present;
17460 unsigned char bits;
17461
Wu Fengguang864f92b2009-11-18 12:38:02 +080017462 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017463 bits = present ? HDA_AMP_MUTE : 0;
17464 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017465 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017466 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017467 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017468 snd_hda_codec_amp_stereo(codec, 0x0e, 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, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017471 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017472}
17473
17474static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17475{
17476 unsigned int present;
17477 unsigned char bits;
17478
Wu Fengguang864f92b2009-11-18 12:38:02 +080017479 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017480 bits = present ? HDA_AMP_MUTE : 0;
17481 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017482 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017483 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017484 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017485 snd_hda_codec_amp_stereo(codec, 0x0e, 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, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017488 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017489}
17490
17491static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17492{
17493 unsigned int present;
17494 unsigned char bits;
17495
Wu Fengguang864f92b2009-11-18 12:38:02 +080017496 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017497 bits = present ? 0 : PIN_OUT;
17498 snd_hda_codec_write(codec, 0x14, 0,
17499 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17500}
17501
17502static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17503{
17504 unsigned int present1, present2;
17505
Wu Fengguang864f92b2009-11-18 12:38:02 +080017506 present1 = snd_hda_jack_detect(codec, 0x21);
17507 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017508
17509 if (present1 || present2) {
17510 snd_hda_codec_write_cache(codec, 0x14, 0,
17511 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17512 } else {
17513 snd_hda_codec_write_cache(codec, 0x14, 0,
17514 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17515 }
17516}
17517
17518static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17519{
17520 unsigned int present1, present2;
17521
Wu Fengguang864f92b2009-11-18 12:38:02 +080017522 present1 = snd_hda_jack_detect(codec, 0x1b);
17523 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017524
17525 if (present1 || present2) {
17526 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017527 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017528 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017529 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017530 } else {
17531 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017532 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017533 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017534 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017535 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017536}
17537
Kailang Yangebb83ee2009-12-17 12:23:00 +010017538static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17539{
17540 unsigned int present1, present2;
17541
17542 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17543 AC_VERB_GET_PIN_SENSE, 0)
17544 & AC_PINSENSE_PRESENCE;
17545 present2 = snd_hda_codec_read(codec, 0x21, 0,
17546 AC_VERB_GET_PIN_SENSE, 0)
17547 & AC_PINSENSE_PRESENCE;
17548
17549 if (present1 || present2) {
17550 snd_hda_codec_write_cache(codec, 0x14, 0,
17551 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17552 snd_hda_codec_write_cache(codec, 0x17, 0,
17553 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17554 } else {
17555 snd_hda_codec_write_cache(codec, 0x14, 0,
17556 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17557 snd_hda_codec_write_cache(codec, 0x17, 0,
17558 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17559 }
17560}
17561
17562static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17563{
17564 unsigned int present1, present2;
17565
17566 present1 = snd_hda_codec_read(codec, 0x21, 0,
17567 AC_VERB_GET_PIN_SENSE, 0)
17568 & AC_PINSENSE_PRESENCE;
17569 present2 = snd_hda_codec_read(codec, 0x15, 0,
17570 AC_VERB_GET_PIN_SENSE, 0)
17571 & AC_PINSENSE_PRESENCE;
17572
17573 if (present1 || present2) {
17574 snd_hda_codec_write_cache(codec, 0x14, 0,
17575 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17576 snd_hda_codec_write_cache(codec, 0x17, 0,
17577 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17578 } else {
17579 snd_hda_codec_write_cache(codec, 0x14, 0,
17580 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17581 snd_hda_codec_write_cache(codec, 0x17, 0,
17582 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17583 }
17584}
17585
Kailang Yang6dda9f42008-05-27 12:05:31 +020017586static void alc663_m51va_unsol_event(struct hda_codec *codec,
17587 unsigned int res)
17588{
17589 switch (res >> 26) {
17590 case ALC880_HP_EVENT:
17591 alc663_m51va_speaker_automute(codec);
17592 break;
17593 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017594 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017595 break;
17596 }
17597}
17598
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017599static void alc663_m51va_setup(struct hda_codec *codec)
17600{
17601 struct alc_spec *spec = codec->spec;
17602 spec->ext_mic.pin = 0x18;
17603 spec->ext_mic.mux_idx = 0;
17604 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017605 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017606 spec->auto_mic = 1;
17607}
17608
Kailang Yang6dda9f42008-05-27 12:05:31 +020017609static void alc663_m51va_inithook(struct hda_codec *codec)
17610{
17611 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017612 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017613}
17614
Kailang Yangf1d4e282008-08-26 14:03:29 +020017615/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017616#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017617
17618static void alc663_mode1_setup(struct hda_codec *codec)
17619{
17620 struct alc_spec *spec = codec->spec;
17621 spec->ext_mic.pin = 0x18;
17622 spec->ext_mic.mux_idx = 0;
17623 spec->int_mic.pin = 0x19;
17624 spec->int_mic.mux_idx = 1;
17625 spec->auto_mic = 1;
17626}
17627
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017628#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017629
Kailang Yangf1d4e282008-08-26 14:03:29 +020017630/* ***************** Mode2 ******************************/
17631static void alc662_mode2_unsol_event(struct hda_codec *codec,
17632 unsigned int res)
17633{
17634 switch (res >> 26) {
17635 case ALC880_HP_EVENT:
17636 alc662_f5z_speaker_automute(codec);
17637 break;
17638 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017639 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017640 break;
17641 }
17642}
17643
Kailang Yangebb83ee2009-12-17 12:23:00 +010017644#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017645
Kailang Yangf1d4e282008-08-26 14:03:29 +020017646static void alc662_mode2_inithook(struct hda_codec *codec)
17647{
17648 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017649 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017650}
17651/* ***************** Mode3 ******************************/
17652static void alc663_mode3_unsol_event(struct hda_codec *codec,
17653 unsigned int res)
17654{
17655 switch (res >> 26) {
17656 case ALC880_HP_EVENT:
17657 alc663_two_hp_m1_speaker_automute(codec);
17658 break;
17659 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017660 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017661 break;
17662 }
17663}
17664
Kailang Yangebb83ee2009-12-17 12:23:00 +010017665#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017666
Kailang Yangf1d4e282008-08-26 14:03:29 +020017667static void alc663_mode3_inithook(struct hda_codec *codec)
17668{
17669 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017670 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017671}
17672/* ***************** Mode4 ******************************/
17673static void alc663_mode4_unsol_event(struct hda_codec *codec,
17674 unsigned int res)
17675{
17676 switch (res >> 26) {
17677 case ALC880_HP_EVENT:
17678 alc663_21jd_two_speaker_automute(codec);
17679 break;
17680 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017681 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017682 break;
17683 }
17684}
17685
Kailang Yangebb83ee2009-12-17 12:23:00 +010017686#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017687
Kailang Yangf1d4e282008-08-26 14:03:29 +020017688static void alc663_mode4_inithook(struct hda_codec *codec)
17689{
17690 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017691 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017692}
17693/* ***************** Mode5 ******************************/
17694static void alc663_mode5_unsol_event(struct hda_codec *codec,
17695 unsigned int res)
17696{
17697 switch (res >> 26) {
17698 case ALC880_HP_EVENT:
17699 alc663_15jd_two_speaker_automute(codec);
17700 break;
17701 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017702 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017703 break;
17704 }
17705}
17706
Kailang Yangebb83ee2009-12-17 12:23:00 +010017707#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017708
Kailang Yangf1d4e282008-08-26 14:03:29 +020017709static void alc663_mode5_inithook(struct hda_codec *codec)
17710{
17711 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017712 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017713}
17714/* ***************** Mode6 ******************************/
17715static void alc663_mode6_unsol_event(struct hda_codec *codec,
17716 unsigned int res)
17717{
17718 switch (res >> 26) {
17719 case ALC880_HP_EVENT:
17720 alc663_two_hp_m2_speaker_automute(codec);
17721 break;
17722 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017723 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017724 break;
17725 }
17726}
17727
Kailang Yangebb83ee2009-12-17 12:23:00 +010017728#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017729
Kailang Yangf1d4e282008-08-26 14:03:29 +020017730static void alc663_mode6_inithook(struct hda_codec *codec)
17731{
17732 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017733 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017734}
17735
Kailang Yangebb83ee2009-12-17 12:23:00 +010017736/* ***************** Mode7 ******************************/
17737static void alc663_mode7_unsol_event(struct hda_codec *codec,
17738 unsigned int res)
17739{
17740 switch (res >> 26) {
17741 case ALC880_HP_EVENT:
17742 alc663_two_hp_m7_speaker_automute(codec);
17743 break;
17744 case ALC880_MIC_EVENT:
17745 alc_mic_automute(codec);
17746 break;
17747 }
17748}
17749
17750#define alc663_mode7_setup alc663_mode1_setup
17751
17752static void alc663_mode7_inithook(struct hda_codec *codec)
17753{
17754 alc663_two_hp_m7_speaker_automute(codec);
17755 alc_mic_automute(codec);
17756}
17757
17758/* ***************** Mode8 ******************************/
17759static void alc663_mode8_unsol_event(struct hda_codec *codec,
17760 unsigned int res)
17761{
17762 switch (res >> 26) {
17763 case ALC880_HP_EVENT:
17764 alc663_two_hp_m8_speaker_automute(codec);
17765 break;
17766 case ALC880_MIC_EVENT:
17767 alc_mic_automute(codec);
17768 break;
17769 }
17770}
17771
17772#define alc663_mode8_setup alc663_m51va_setup
17773
17774static void alc663_mode8_inithook(struct hda_codec *codec)
17775{
17776 alc663_two_hp_m8_speaker_automute(codec);
17777 alc_mic_automute(codec);
17778}
17779
Kailang Yang6dda9f42008-05-27 12:05:31 +020017780static void alc663_g71v_hp_automute(struct hda_codec *codec)
17781{
17782 unsigned int present;
17783 unsigned char bits;
17784
Wu Fengguang864f92b2009-11-18 12:38:02 +080017785 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017786 bits = present ? HDA_AMP_MUTE : 0;
17787 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17788 HDA_AMP_MUTE, bits);
17789 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17790 HDA_AMP_MUTE, bits);
17791}
17792
17793static void alc663_g71v_front_automute(struct hda_codec *codec)
17794{
17795 unsigned int present;
17796 unsigned char bits;
17797
Wu Fengguang864f92b2009-11-18 12:38:02 +080017798 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017799 bits = present ? HDA_AMP_MUTE : 0;
17800 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17801 HDA_AMP_MUTE, bits);
17802}
17803
17804static void alc663_g71v_unsol_event(struct hda_codec *codec,
17805 unsigned int res)
17806{
17807 switch (res >> 26) {
17808 case ALC880_HP_EVENT:
17809 alc663_g71v_hp_automute(codec);
17810 break;
17811 case ALC880_FRONT_EVENT:
17812 alc663_g71v_front_automute(codec);
17813 break;
17814 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017815 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017816 break;
17817 }
17818}
17819
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017820#define alc663_g71v_setup alc663_m51va_setup
17821
Kailang Yang6dda9f42008-05-27 12:05:31 +020017822static void alc663_g71v_inithook(struct hda_codec *codec)
17823{
17824 alc663_g71v_front_automute(codec);
17825 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017826 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017827}
17828
17829static void alc663_g50v_unsol_event(struct hda_codec *codec,
17830 unsigned int res)
17831{
17832 switch (res >> 26) {
17833 case ALC880_HP_EVENT:
17834 alc663_m51va_speaker_automute(codec);
17835 break;
17836 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017837 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017838 break;
17839 }
17840}
17841
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017842#define alc663_g50v_setup alc663_m51va_setup
17843
Kailang Yang6dda9f42008-05-27 12:05:31 +020017844static void alc663_g50v_inithook(struct hda_codec *codec)
17845{
17846 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017847 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017848}
17849
Kailang Yangf1d4e282008-08-26 14:03:29 +020017850static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17851 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017852 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017853
17854 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17855 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17856 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17857
17858 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17859 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17860 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17861 { } /* end */
17862};
17863
Chris Pockelé9541ba12009-05-12 08:08:53 +020017864static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17865 /* Master Playback automatically created from Speaker and Headphone */
17866 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17867 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17868 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17869 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17870
17871 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17872 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17873 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17874
17875 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17876 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17877 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17878 { } /* end */
17879};
17880
Takashi Iwaicb53c622007-08-10 17:21:45 +020017881#ifdef CONFIG_SND_HDA_POWER_SAVE
17882#define alc662_loopbacks alc880_loopbacks
17883#endif
17884
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017885
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017886/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017887#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17888#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17889#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17890#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17891
17892/*
17893 * configuration and preset
17894 */
17895static const char *alc662_models[ALC662_MODEL_LAST] = {
17896 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17897 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17898 [ALC662_3ST_6ch] = "3stack-6ch",
17899 [ALC662_5ST_DIG] = "6stack-dig",
17900 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017901 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017902 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017903 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017904 [ALC663_ASUS_M51VA] = "m51va",
17905 [ALC663_ASUS_G71V] = "g71v",
17906 [ALC663_ASUS_H13] = "h13",
17907 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017908 [ALC663_ASUS_MODE1] = "asus-mode1",
17909 [ALC662_ASUS_MODE2] = "asus-mode2",
17910 [ALC663_ASUS_MODE3] = "asus-mode3",
17911 [ALC663_ASUS_MODE4] = "asus-mode4",
17912 [ALC663_ASUS_MODE5] = "asus-mode5",
17913 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017914 [ALC663_ASUS_MODE7] = "asus-mode7",
17915 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017916 [ALC272_DELL] = "dell",
17917 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017918 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017919 [ALC662_AUTO] = "auto",
17920};
17921
17922static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017923 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017924 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17925 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017926 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17927 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017928 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017929 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17930 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17931 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17932 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017933 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17934 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017935 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017936 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17937 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17938 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17939 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17940 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017941 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017942 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17943 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017944 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17945 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17946 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17947 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017948 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017949 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17950 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17951 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017952 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17953 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17954 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17955 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017956 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017957 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17958 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017959 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017960 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17961 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17962 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017963 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017964 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017965 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17966 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017967 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17968 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17969 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017970 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017971 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17972 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017973 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017974 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017975 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017976 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17977 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17978 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017979 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017980 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17981 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017982 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017983 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017984 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017985 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017986 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17987 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017988 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017989 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017990 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17991 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017992 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017993 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017994 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017995 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017996 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017997 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017998 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17999 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018000 {}
18001};
18002
18003static struct alc_config_preset alc662_presets[] = {
18004 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018005 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018006 .init_verbs = { alc662_init_verbs },
18007 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18008 .dac_nids = alc662_dac_nids,
18009 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018010 .dig_in_nid = ALC662_DIGIN_NID,
18011 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18012 .channel_mode = alc662_3ST_2ch_modes,
18013 .input_mux = &alc662_capture_source,
18014 },
18015 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018016 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018017 .init_verbs = { alc662_init_verbs },
18018 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18019 .dac_nids = alc662_dac_nids,
18020 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018021 .dig_in_nid = ALC662_DIGIN_NID,
18022 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18023 .channel_mode = alc662_3ST_6ch_modes,
18024 .need_dac_fix = 1,
18025 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018026 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018027 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018028 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018029 .init_verbs = { alc662_init_verbs },
18030 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18031 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018032 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18033 .channel_mode = alc662_3ST_6ch_modes,
18034 .need_dac_fix = 1,
18035 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018036 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018037 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018038 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018039 .init_verbs = { alc662_init_verbs },
18040 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18041 .dac_nids = alc662_dac_nids,
18042 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018043 .dig_in_nid = ALC662_DIGIN_NID,
18044 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18045 .channel_mode = alc662_5stack_modes,
18046 .input_mux = &alc662_capture_source,
18047 },
18048 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018049 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018050 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18051 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18052 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018053 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18054 .channel_mode = alc662_3ST_2ch_modes,
18055 .input_mux = &alc662_lenovo_101e_capture_source,
18056 .unsol_event = alc662_lenovo_101e_unsol_event,
18057 .init_hook = alc662_lenovo_101e_all_automute,
18058 },
Kailang Yang291702f2007-10-16 14:28:03 +020018059 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018060 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018061 .init_verbs = { alc662_init_verbs,
18062 alc662_eeepc_sue_init_verbs },
18063 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18064 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018065 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18066 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018067 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018068 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018069 .init_hook = alc662_eeepc_inithook,
18070 },
Kailang Yang8c427222008-01-10 13:03:59 +010018071 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018072 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018073 alc662_chmode_mixer },
18074 .init_verbs = { alc662_init_verbs,
18075 alc662_eeepc_ep20_sue_init_verbs },
18076 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18077 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018078 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18079 .channel_mode = alc662_3ST_6ch_modes,
18080 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018081 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018082 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018083 .init_hook = alc662_eeepc_ep20_inithook,
18084 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018085 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018086 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018087 .init_verbs = { alc662_init_verbs,
18088 alc662_ecs_init_verbs },
18089 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18090 .dac_nids = alc662_dac_nids,
18091 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18092 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018093 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018094 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018095 .init_hook = alc662_eeepc_inithook,
18096 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018097 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018098 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018099 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18100 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18101 .dac_nids = alc662_dac_nids,
18102 .dig_out_nid = ALC662_DIGOUT_NID,
18103 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18104 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018105 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018106 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018107 .init_hook = alc663_m51va_inithook,
18108 },
18109 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018110 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018111 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18112 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18113 .dac_nids = alc662_dac_nids,
18114 .dig_out_nid = ALC662_DIGOUT_NID,
18115 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18116 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018117 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018118 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018119 .init_hook = alc663_g71v_inithook,
18120 },
18121 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018122 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018123 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18124 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18125 .dac_nids = alc662_dac_nids,
18126 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18127 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018128 .unsol_event = alc663_m51va_unsol_event,
18129 .init_hook = alc663_m51va_inithook,
18130 },
18131 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018132 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018133 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18134 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18135 .dac_nids = alc662_dac_nids,
18136 .dig_out_nid = ALC662_DIGOUT_NID,
18137 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18138 .channel_mode = alc662_3ST_6ch_modes,
18139 .input_mux = &alc663_capture_source,
18140 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018141 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018142 .init_hook = alc663_g50v_inithook,
18143 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018144 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018145 .mixers = { alc663_m51va_mixer },
18146 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018147 .init_verbs = { alc662_init_verbs,
18148 alc663_21jd_amic_init_verbs },
18149 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18150 .hp_nid = 0x03,
18151 .dac_nids = alc662_dac_nids,
18152 .dig_out_nid = ALC662_DIGOUT_NID,
18153 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18154 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018155 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018156 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018157 .init_hook = alc663_mode1_inithook,
18158 },
18159 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018160 .mixers = { alc662_1bjd_mixer },
18161 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018162 .init_verbs = { alc662_init_verbs,
18163 alc662_1bjd_amic_init_verbs },
18164 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18165 .dac_nids = alc662_dac_nids,
18166 .dig_out_nid = ALC662_DIGOUT_NID,
18167 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18168 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018169 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018170 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018171 .init_hook = alc662_mode2_inithook,
18172 },
18173 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018174 .mixers = { alc663_two_hp_m1_mixer },
18175 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018176 .init_verbs = { alc662_init_verbs,
18177 alc663_two_hp_amic_m1_init_verbs },
18178 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18179 .hp_nid = 0x03,
18180 .dac_nids = alc662_dac_nids,
18181 .dig_out_nid = ALC662_DIGOUT_NID,
18182 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18183 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018184 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018185 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018186 .init_hook = alc663_mode3_inithook,
18187 },
18188 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018189 .mixers = { alc663_asus_21jd_clfe_mixer },
18190 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018191 .init_verbs = { alc662_init_verbs,
18192 alc663_21jd_amic_init_verbs},
18193 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18194 .hp_nid = 0x03,
18195 .dac_nids = alc662_dac_nids,
18196 .dig_out_nid = ALC662_DIGOUT_NID,
18197 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18198 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018199 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018200 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018201 .init_hook = alc663_mode4_inithook,
18202 },
18203 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018204 .mixers = { alc663_asus_15jd_clfe_mixer },
18205 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018206 .init_verbs = { alc662_init_verbs,
18207 alc663_15jd_amic_init_verbs },
18208 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18209 .hp_nid = 0x03,
18210 .dac_nids = alc662_dac_nids,
18211 .dig_out_nid = ALC662_DIGOUT_NID,
18212 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18213 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018214 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018215 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018216 .init_hook = alc663_mode5_inithook,
18217 },
18218 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018219 .mixers = { alc663_two_hp_m2_mixer },
18220 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018221 .init_verbs = { alc662_init_verbs,
18222 alc663_two_hp_amic_m2_init_verbs },
18223 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18224 .hp_nid = 0x03,
18225 .dac_nids = alc662_dac_nids,
18226 .dig_out_nid = ALC662_DIGOUT_NID,
18227 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18228 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018229 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018230 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018231 .init_hook = alc663_mode6_inithook,
18232 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018233 [ALC663_ASUS_MODE7] = {
18234 .mixers = { alc663_mode7_mixer },
18235 .cap_mixer = alc662_auto_capture_mixer,
18236 .init_verbs = { alc662_init_verbs,
18237 alc663_mode7_init_verbs },
18238 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18239 .hp_nid = 0x03,
18240 .dac_nids = alc662_dac_nids,
18241 .dig_out_nid = ALC662_DIGOUT_NID,
18242 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18243 .channel_mode = alc662_3ST_2ch_modes,
18244 .unsol_event = alc663_mode7_unsol_event,
18245 .setup = alc663_mode7_setup,
18246 .init_hook = alc663_mode7_inithook,
18247 },
18248 [ALC663_ASUS_MODE8] = {
18249 .mixers = { alc663_mode8_mixer },
18250 .cap_mixer = alc662_auto_capture_mixer,
18251 .init_verbs = { alc662_init_verbs,
18252 alc663_mode8_init_verbs },
18253 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18254 .hp_nid = 0x03,
18255 .dac_nids = alc662_dac_nids,
18256 .dig_out_nid = ALC662_DIGOUT_NID,
18257 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18258 .channel_mode = alc662_3ST_2ch_modes,
18259 .unsol_event = alc663_mode8_unsol_event,
18260 .setup = alc663_mode8_setup,
18261 .init_hook = alc663_mode8_inithook,
18262 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018263 [ALC272_DELL] = {
18264 .mixers = { alc663_m51va_mixer },
18265 .cap_mixer = alc272_auto_capture_mixer,
18266 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18267 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18268 .dac_nids = alc662_dac_nids,
18269 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18270 .adc_nids = alc272_adc_nids,
18271 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18272 .capsrc_nids = alc272_capsrc_nids,
18273 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018274 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018275 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018276 .init_hook = alc663_m51va_inithook,
18277 },
18278 [ALC272_DELL_ZM1] = {
18279 .mixers = { alc663_m51va_mixer },
18280 .cap_mixer = alc662_auto_capture_mixer,
18281 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18282 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18283 .dac_nids = alc662_dac_nids,
18284 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18285 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018286 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018287 .capsrc_nids = alc662_capsrc_nids,
18288 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018289 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018290 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018291 .init_hook = alc663_m51va_inithook,
18292 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018293 [ALC272_SAMSUNG_NC10] = {
18294 .mixers = { alc272_nc10_mixer },
18295 .init_verbs = { alc662_init_verbs,
18296 alc663_21jd_amic_init_verbs },
18297 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18298 .dac_nids = alc272_dac_nids,
18299 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18300 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018301 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018302 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018303 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018304 .init_hook = alc663_mode4_inithook,
18305 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018306};
18307
18308
18309/*
18310 * BIOS auto configuration
18311 */
18312
Takashi Iwai7085ec12009-10-02 09:03:58 +020018313/* convert from MIX nid to DAC */
18314static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18315{
18316 if (nid == 0x0f)
18317 return 0x02;
18318 else if (nid >= 0x0c && nid <= 0x0e)
18319 return nid - 0x0c + 0x02;
18320 else
18321 return 0;
18322}
18323
18324/* get MIX nid connected to the given pin targeted to DAC */
18325static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18326 hda_nid_t dac)
18327{
18328 hda_nid_t mix[4];
18329 int i, num;
18330
18331 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18332 for (i = 0; i < num; i++) {
18333 if (alc662_mix_to_dac(mix[i]) == dac)
18334 return mix[i];
18335 }
18336 return 0;
18337}
18338
18339/* look for an empty DAC slot */
18340static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18341{
18342 struct alc_spec *spec = codec->spec;
18343 hda_nid_t srcs[5];
18344 int i, j, num;
18345
18346 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18347 if (num < 0)
18348 return 0;
18349 for (i = 0; i < num; i++) {
18350 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18351 if (!nid)
18352 continue;
18353 for (j = 0; j < spec->multiout.num_dacs; j++)
18354 if (spec->multiout.dac_nids[j] == nid)
18355 break;
18356 if (j >= spec->multiout.num_dacs)
18357 return nid;
18358 }
18359 return 0;
18360}
18361
18362/* fill in the dac_nids table from the parsed pin configuration */
18363static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18364 const struct auto_pin_cfg *cfg)
18365{
18366 struct alc_spec *spec = codec->spec;
18367 int i;
18368 hda_nid_t dac;
18369
18370 spec->multiout.dac_nids = spec->private_dac_nids;
18371 for (i = 0; i < cfg->line_outs; i++) {
18372 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18373 if (!dac)
18374 continue;
18375 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18376 }
18377 return 0;
18378}
18379
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018380static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018381 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018382{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018383 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018384 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18385}
18386
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018387static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018388 hda_nid_t nid, unsigned int chs)
18389{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018390 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018391 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18392}
18393
18394#define alc662_add_stereo_vol(spec, pfx, nid) \
18395 alc662_add_vol_ctl(spec, pfx, nid, 3)
18396#define alc662_add_stereo_sw(spec, pfx, nid) \
18397 alc662_add_sw_ctl(spec, pfx, nid, 3)
18398
18399/* add playback controls from the parsed DAC table */
18400static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18401 const struct auto_pin_cfg *cfg)
18402{
18403 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018404 static const char *chname[4] = {
18405 "Front", "Surround", NULL /*CLFE*/, "Side"
18406 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018407 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018408 int i, err;
18409
18410 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018411 nid = spec->multiout.dac_nids[i];
18412 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018413 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018414 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18415 if (!mix)
18416 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018417 if (i == 2) {
18418 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018419 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018420 if (err < 0)
18421 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018422 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018423 if (err < 0)
18424 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018425 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018426 if (err < 0)
18427 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018428 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018429 if (err < 0)
18430 return err;
18431 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018432 const char *pfx;
18433 if (cfg->line_outs == 1 &&
18434 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018435 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018436 pfx = "Speaker";
18437 else
18438 pfx = "PCM";
18439 } else
18440 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018441 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018442 if (err < 0)
18443 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018444 if (cfg->line_outs == 1 &&
18445 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18446 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018447 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018448 if (err < 0)
18449 return err;
18450 }
18451 }
18452 return 0;
18453}
18454
18455/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018456/* return DAC nid if any new DAC is assigned */
18457static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018458 const char *pfx)
18459{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018460 struct alc_spec *spec = codec->spec;
18461 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018462 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018463
18464 if (!pin)
18465 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018466 nid = alc662_look_for_dac(codec, pin);
18467 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018468 /* the corresponding DAC is already occupied */
18469 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18470 return 0; /* no way */
18471 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018472 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018473 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18474 }
18475
18476 mix = alc662_dac_to_mix(codec, pin, nid);
18477 if (!mix)
18478 return 0;
18479 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18480 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018481 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018482 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18483 if (err < 0)
18484 return err;
18485 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018486}
18487
18488/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018489#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018490 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018491
18492static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18493 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018494 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018495{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018496 int i, num;
18497 hda_nid_t srcs[4];
18498
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018499 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018500 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018501 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18502 if (num <= 1)
18503 return;
18504 for (i = 0; i < num; i++) {
18505 if (alc662_mix_to_dac(srcs[i]) != dac)
18506 continue;
18507 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18508 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018509 }
18510}
18511
18512static void alc662_auto_init_multi_out(struct hda_codec *codec)
18513{
18514 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018515 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018516 int i;
18517
18518 for (i = 0; i <= HDA_SIDE; i++) {
18519 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18520 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018521 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018522 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018523 }
18524}
18525
18526static void alc662_auto_init_hp_out(struct hda_codec *codec)
18527{
18528 struct alc_spec *spec = codec->spec;
18529 hda_nid_t pin;
18530
18531 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018532 if (pin)
18533 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18534 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018535 pin = spec->autocfg.speaker_pins[0];
18536 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018537 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18538 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018539}
18540
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018541#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18542
18543static void alc662_auto_init_analog_input(struct hda_codec *codec)
18544{
18545 struct alc_spec *spec = codec->spec;
18546 int i;
18547
18548 for (i = 0; i < AUTO_PIN_LAST; i++) {
18549 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018550 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018551 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018552 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018553 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018554 snd_hda_codec_write(codec, nid, 0,
18555 AC_VERB_SET_AMP_GAIN_MUTE,
18556 AMP_OUT_MUTE);
18557 }
18558 }
18559}
18560
Takashi Iwaif511b012008-08-15 16:46:42 +020018561#define alc662_auto_init_input_src alc882_auto_init_input_src
18562
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018563static int alc662_parse_auto_config(struct hda_codec *codec)
18564{
18565 struct alc_spec *spec = codec->spec;
18566 int err;
18567 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18568
18569 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18570 alc662_ignore);
18571 if (err < 0)
18572 return err;
18573 if (!spec->autocfg.line_outs)
18574 return 0; /* can't find valid BIOS pin config */
18575
Takashi Iwai7085ec12009-10-02 09:03:58 +020018576 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018577 if (err < 0)
18578 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018579 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018580 if (err < 0)
18581 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018582 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018583 spec->autocfg.speaker_pins[0],
18584 "Speaker");
18585 if (err < 0)
18586 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018587 if (err)
18588 spec->multiout.extra_out_nid[0] = err;
18589 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018590 "Headphone");
18591 if (err < 0)
18592 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018593 if (err)
18594 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018595 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018596 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018597 return err;
18598
18599 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18600
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018601 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018602 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18603
Takashi Iwai603c4012008-07-30 15:01:44 +020018604 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018605 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018606
18607 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018608 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018609
Kailang Yangcec27c82010-02-04 14:18:18 +010018610 add_verb(spec, alc662_init_verbs);
18611 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18612 codec->vendor_id == 0x10ec0665)
18613 add_verb(spec, alc663_init_verbs);
18614
18615 if (codec->vendor_id == 0x10ec0272)
18616 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018617
18618 err = alc_auto_add_mic_boost(codec);
18619 if (err < 0)
18620 return err;
18621
Kailang Yang6227cdc2010-02-25 08:36:52 +010018622 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18623 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18624 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18625 else
18626 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018627
Takashi Iwai8c872862007-06-19 12:11:16 +020018628 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018629}
18630
18631/* additional initialization for auto-configuration model */
18632static void alc662_auto_init(struct hda_codec *codec)
18633{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018634 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018635 alc662_auto_init_multi_out(codec);
18636 alc662_auto_init_hp_out(codec);
18637 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018638 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018639 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018640 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018641}
18642
18643static int patch_alc662(struct hda_codec *codec)
18644{
18645 struct alc_spec *spec;
18646 int err, board_config;
18647
18648 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18649 if (!spec)
18650 return -ENOMEM;
18651
18652 codec->spec = spec;
18653
Kailang Yangda00c242010-03-19 11:23:45 +010018654 alc_auto_parse_customize_define(codec);
18655
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018656 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18657
Kailang Yangc027ddc2010-03-19 11:33:06 +010018658 if (alc_read_coef_idx(codec, 0) == 0x8020)
18659 alc_codec_rename(codec, "ALC661");
18660 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18661 codec->bus->pci->subsystem_vendor == 0x1025 &&
18662 spec->cdefine.platform_type == 1)
18663 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010018664
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018665 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18666 alc662_models,
18667 alc662_cfg_tbl);
18668 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018669 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18670 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018671 board_config = ALC662_AUTO;
18672 }
18673
18674 if (board_config == ALC662_AUTO) {
18675 /* automatic parse from the BIOS config */
18676 err = alc662_parse_auto_config(codec);
18677 if (err < 0) {
18678 alc_free(codec);
18679 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020018680 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018681 printk(KERN_INFO
18682 "hda_codec: Cannot set up configuration "
18683 "from BIOS. Using base mode...\n");
18684 board_config = ALC662_3ST_2ch_DIG;
18685 }
18686 }
18687
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018688 err = snd_hda_attach_beep_device(codec, 0x1);
18689 if (err < 0) {
18690 alc_free(codec);
18691 return err;
18692 }
18693
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018694 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018695 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018696
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018697 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18698 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18699
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018700 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18701 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18702
Takashi Iwaidd704692009-08-11 08:45:11 +020018703 if (!spec->adc_nids) {
18704 spec->adc_nids = alc662_adc_nids;
18705 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18706 }
18707 if (!spec->capsrc_nids)
18708 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018709
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018710 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018711 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018712
Kailang Yangda00c242010-03-19 11:23:45 +010018713 if (spec->cdefine.enable_pcbeep) {
18714 switch (codec->vendor_id) {
18715 case 0x10ec0662:
18716 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18717 break;
18718 case 0x10ec0272:
18719 case 0x10ec0663:
18720 case 0x10ec0665:
18721 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18722 break;
18723 case 0x10ec0273:
18724 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18725 break;
18726 }
Kailang Yangcec27c82010-02-04 14:18:18 +010018727 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018728 spec->vmaster_nid = 0x02;
18729
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018730 codec->patch_ops = alc_patch_ops;
18731 if (board_config == ALC662_AUTO)
18732 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018733#ifdef CONFIG_SND_HDA_POWER_SAVE
18734 if (!spec->loopback.amplist)
18735 spec->loopback.amplist = alc662_loopbacks;
18736#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018737
18738 return 0;
18739}
18740
Kailang Yang274693f2009-12-03 10:07:50 +010018741static int patch_alc888(struct hda_codec *codec)
18742{
18743 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18744 kfree(codec->chip_name);
18745 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018746 if (!codec->chip_name) {
18747 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018748 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018749 }
18750 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018751 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018752 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018753}
18754
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018755/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018756 * patch entries
18757 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018758static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018759 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018760 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018761 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018762 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018763 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018764 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018765 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018766 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018767 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018768 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018769 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18770 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18771 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018772 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018773 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018774 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18775 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018776 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018777 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018778 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018779 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018780 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018781 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018782 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018783 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018784 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018785 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018786 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018787 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018788 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018789 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018790 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018791 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018792 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018793 {} /* terminator */
18794};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018795
18796MODULE_ALIAS("snd-hda-codec-id:10ec*");
18797
18798MODULE_LICENSE("GPL");
18799MODULE_DESCRIPTION("Realtek HD-audio codec");
18800
18801static struct hda_codec_preset_list realtek_list = {
18802 .preset = snd_hda_preset_realtek,
18803 .owner = THIS_MODULE,
18804};
18805
18806static int __init patch_realtek_init(void)
18807{
18808 return snd_hda_add_codec_preset(&realtek_list);
18809}
18810
18811static void __exit patch_realtek_exit(void)
18812{
18813 snd_hda_delete_codec_preset(&realtek_list);
18814}
18815
18816module_init(patch_realtek_init)
18817module_exit(patch_realtek_exit)