blob: 596ea2f12cf60a74504efc751a9566265d7b3aeb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100134 ALC269_AMIC,
135 ALC269_DMIC,
136 ALC269VB_AMIC,
137 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100138 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000139 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100140 ALC269_AUTO,
141 ALC269_MODEL_LAST /* last tag */
142};
143
Kailang Yangdf694da2005-12-05 19:42:22 +0100144/* ALC861 models */
145enum {
146 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200147 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100148 ALC861_3ST_DIG,
149 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200150 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200151 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200152 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100153 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100154 ALC861_AUTO,
155 ALC861_MODEL_LAST,
156};
157
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158/* ALC861-VD models */
159enum {
160 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200161 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100162 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100163 ALC861VD_3ST,
164 ALC861VD_3ST_DIG,
165 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200166 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200167 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200168 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100169 ALC861VD_AUTO,
170 ALC861VD_MODEL_LAST,
171};
172
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200173/* ALC662 models */
174enum {
175 ALC662_3ST_2ch_DIG,
176 ALC662_3ST_6ch_DIG,
177 ALC662_3ST_6ch,
178 ALC662_5ST_DIG,
179 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200180 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100181 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200182 ALC663_ASUS_M51VA,
183 ALC663_ASUS_G71V,
184 ALC663_ASUS_H13,
185 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200186 ALC662_ECS,
187 ALC663_ASUS_MODE1,
188 ALC662_ASUS_MODE2,
189 ALC663_ASUS_MODE3,
190 ALC663_ASUS_MODE4,
191 ALC663_ASUS_MODE5,
192 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100193 ALC663_ASUS_MODE7,
194 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200195 ALC272_DELL,
196 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200197 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200198 ALC662_AUTO,
199 ALC662_MODEL_LAST,
200};
201
Kailang Yangdf694da2005-12-05 19:42:22 +0100202/* ALC882 models */
203enum {
204 ALC882_3ST_DIG,
205 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200206 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200207 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200208 ALC882_TARGA,
209 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200210 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100211 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800212 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200213 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200214 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100215 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200216 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800217 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200218 ALC883_3ST_2ch_DIG,
219 ALC883_3ST_6ch_DIG,
220 ALC883_3ST_6ch,
221 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200222 ALC883_TARGA_DIG,
223 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200224 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200225 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200226 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800227 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100228 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200229 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200230 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200231 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200232 ALC883_MEDION_MD2,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200233 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100234 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200235 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200236 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200237 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200238 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200239 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200240 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100241 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100242 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430243 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100244 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100245 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800246 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200247 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200248 ALC889A_INTEL,
249 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200250 ALC888_ASUS_M90V,
251 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200252 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100253 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200254 ALC883_SONY_VAIO_TT,
Takashi Iwai49535502009-06-30 15:28:30 +0200255 ALC882_AUTO,
256 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200257};
258
Kailang Yangdf694da2005-12-05 19:42:22 +0100259/* for GPIO Poll */
260#define GPIO_MASK 0x03
261
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200262/* extra amp-initialization sequence types */
263enum {
264 ALC_INIT_NONE,
265 ALC_INIT_DEFAULT,
266 ALC_INIT_GPIO1,
267 ALC_INIT_GPIO2,
268 ALC_INIT_GPIO3,
269};
270
Takashi Iwai6c819492009-08-10 18:47:44 +0200271struct alc_mic_route {
272 hda_nid_t pin;
273 unsigned char mux_idx;
274 unsigned char amix_idx;
275};
276
277#define MUX_IDX_UNDEF ((unsigned char)-1)
278
Kailang Yangda00c242010-03-19 11:23:45 +0100279struct alc_customize_define {
280 unsigned int sku_cfg;
281 unsigned char port_connectivity;
282 unsigned char check_sum;
283 unsigned char customization;
284 unsigned char external_amp;
285 unsigned int enable_pcbeep:1;
286 unsigned int platform_type:1;
287 unsigned int swap:1;
288 unsigned int override:1;
289};
290
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291struct alc_spec {
292 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100293 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100295 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100296 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200298 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200299 * don't forget NULL
300 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200301 */
302 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200304 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 struct hda_pcm_stream *stream_analog_playback;
306 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100307 struct hda_pcm_stream *stream_analog_alt_playback;
308 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200310 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 struct hda_pcm_stream *stream_digital_playback;
312 struct hda_pcm_stream *stream_digital_capture;
313
314 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200315 struct hda_multi_out multiout; /* playback set-up
316 * max_channels, dacs must be set
317 * dig_out_nid and hp_nid are optional
318 */
Takashi Iwai63300792008-01-24 15:31:36 +0100319 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100320 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100321 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 /* capture */
324 unsigned int num_adc_nids;
325 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100326 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200327 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
329 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200330 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 const struct hda_input_mux *input_mux;
332 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200333 struct alc_mic_route ext_mic;
334 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
336 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100337 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200339 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200340 int const_channel_count;
341 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342
343 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100344 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200345
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200346 /* dynamic controls, init_verbs and input_mux */
347 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100348 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200349 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200350 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200351 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai49535502009-06-30 15:28:30 +0200352 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
353 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100354
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100355 /* hooks */
356 void (*init_hook)(struct hda_codec *codec);
357 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100358#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500359 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100360#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100361
Takashi Iwai834be882006-03-01 14:16:17 +0100362 /* for pin sensing */
363 unsigned int sense_updated: 1;
364 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100365 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200366 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200367
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100368 /* other flags */
369 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200370 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100371
Takashi Iwai2134ea42008-01-10 16:53:55 +0100372 /* for virtual master */
373 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200374#ifdef CONFIG_SND_HDA_POWER_SAVE
375 struct hda_loopback_check loopback;
376#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200377
378 /* for PLL fix */
379 hda_nid_t pll_nid;
380 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100381};
382
383/*
384 * configuration template - to be copied to the spec instance
385 */
386struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200387 struct snd_kcontrol_new *mixers[5]; /* should be identical size
388 * with spec
389 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100390 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100391 const struct hda_verb *init_verbs[5];
392 unsigned int num_dacs;
393 hda_nid_t *dac_nids;
394 hda_nid_t dig_out_nid; /* optional */
395 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800396 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100397 unsigned int num_adc_nids;
398 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100399 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100400 hda_nid_t dig_in_nid;
401 unsigned int num_channel_mode;
402 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200403 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200404 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200405 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100406 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100407 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200408 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100409 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200410#ifdef CONFIG_SND_HDA_POWER_SAVE
411 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500412 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200413#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414};
415
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
417/*
418 * input MUX handling
419 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422{
423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200425 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
426 if (mux_idx >= spec->num_mux_defs)
427 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100428 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
429 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200430 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431}
432
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
434 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435{
436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
437 struct alc_spec *spec = codec->spec;
438 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
439
440 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
441 return 0;
442}
443
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200444static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
445 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446{
447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100449 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100451 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100452 hda_nid_t nid = spec->capsrc_nids ?
453 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200454 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
Takashi Iwaicd896c32008-11-18 12:36:33 +0100456 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
457 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100458 if (!imux->num_items && mux_idx > 0)
459 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100460
Takashi Iwaia22d5432009-07-27 12:54:26 +0200461 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200462 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100463 /* Matrix-mixer style (e.g. ALC882) */
464 unsigned int *cur_val = &spec->cur_mux[adc_idx];
465 unsigned int i, idx;
466
467 idx = ucontrol->value.enumerated.item[0];
468 if (idx >= imux->num_items)
469 idx = imux->num_items - 1;
470 if (*cur_val == idx)
471 return 0;
472 for (i = 0; i < imux->num_items; i++) {
473 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
474 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
475 imux->items[i].index,
476 HDA_AMP_MUTE, v);
477 }
478 *cur_val = idx;
479 return 1;
480 } else {
481 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100482 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100483 &spec->cur_mux[adc_idx]);
484 }
485}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200486
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487/*
488 * channel mode setting
489 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200490static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492{
493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
494 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100495 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
496 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497}
498
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200499static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501{
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
503 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100504 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200505 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200506 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507}
508
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200509static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511{
512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
513 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200514 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
515 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200516 &spec->ext_channel_count);
517 if (err >= 0 && !spec->const_channel_count) {
518 spec->multiout.max_channels = spec->ext_channel_count;
519 if (spec->need_dac_fix)
520 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
521 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200522 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523}
524
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200527 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528 * being part of a format specifier. Maximum allowed length of a value is
529 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100530 *
531 * Note: some retasking pin complexes seem to ignore requests for input
532 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
533 * are requested. Therefore order this list so that this behaviour will not
534 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200535 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
536 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200537 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100539 "Mic 50pc bias", "Mic 80pc bias",
540 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541};
542static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100543 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100544};
545/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200546 * in the pin being assumed to be exclusively an input or an output pin. In
547 * addition, "input" pins may or may not process the mic bias option
548 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
549 * accept requests for bias as of chip versions up to March 2006) and/or
550 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200552#define ALC_PIN_DIR_IN 0x00
553#define ALC_PIN_DIR_OUT 0x01
554#define ALC_PIN_DIR_INOUT 0x02
555#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
556#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100557
Kailang Yangea1fb292008-08-26 12:58:38 +0200558/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559 * For each direction the minimum and maximum values are given.
560 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200561static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562 { 0, 2 }, /* ALC_PIN_DIR_IN */
563 { 3, 4 }, /* ALC_PIN_DIR_OUT */
564 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200565 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
566 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567};
568#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
569#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
570#define alc_pin_mode_n_items(_dir) \
571 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
572
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200573static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
574 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200575{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 unsigned int item_num = uinfo->value.enumerated.item;
577 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
578
579 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200580 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
582
583 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
584 item_num = alc_pin_mode_min(dir);
585 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200586 return 0;
587}
588
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200589static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
590 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200591{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200593 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
594 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100595 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200596 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
598 AC_VERB_GET_PIN_WIDGET_CONTROL,
599 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200600
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100601 /* Find enumerated value for current pinctl setting */
602 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2c2009-08-02 13:30:45 +0200603 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100604 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200605 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606 return 0;
607}
608
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200609static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
610 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100611{
612 signed int change;
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 hda_nid_t nid = kcontrol->private_value & 0xffff;
615 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
616 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200617 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
618 AC_VERB_GET_PIN_WIDGET_CONTROL,
619 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100620
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200621 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100622 val = alc_pin_mode_min(dir);
623
624 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100625 if (change) {
626 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200627 snd_hda_codec_write_cache(codec, nid, 0,
628 AC_VERB_SET_PIN_WIDGET_CONTROL,
629 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100630
Kailang Yangea1fb292008-08-26 12:58:38 +0200631 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100632 * for the requested pin mode. Enum values of 2 or less are
633 * input modes.
634 *
635 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200636 * reduces noise slightly (particularly on input) so we'll
637 * do it. However, having both input and output buffers
638 * enabled simultaneously doesn't seem to be problematic if
639 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100640 */
641 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200642 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
643 HDA_AMP_MUTE, HDA_AMP_MUTE);
644 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
645 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100646 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200647 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
648 HDA_AMP_MUTE, HDA_AMP_MUTE);
649 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
650 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100651 }
652 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200653 return change;
654}
655
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100656#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200657 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100658 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100659 .info = alc_pin_mode_info, \
660 .get = alc_pin_mode_get, \
661 .put = alc_pin_mode_put, \
662 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100663
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100664/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
665 * together using a mask with more than one bit set. This control is
666 * currently used only by the ALC260 test model. At this stage they are not
667 * needed for any "production" models.
668 */
669#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200670#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200671
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200672static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100674{
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 hda_nid_t nid = kcontrol->private_value & 0xffff;
677 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
678 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679 unsigned int val = snd_hda_codec_read(codec, nid, 0,
680 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100681
682 *valp = (val & mask) != 0;
683 return 0;
684}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200685static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
686 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100687{
688 signed int change;
689 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
690 hda_nid_t nid = kcontrol->private_value & 0xffff;
691 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
692 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200693 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
694 AC_VERB_GET_GPIO_DATA,
695 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100696
697 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200698 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
699 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100700 gpio_data &= ~mask;
701 else
702 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200703 snd_hda_codec_write_cache(codec, nid, 0,
704 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100705
706 return change;
707}
708#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
709 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100710 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100711 .info = alc_gpio_data_info, \
712 .get = alc_gpio_data_get, \
713 .put = alc_gpio_data_put, \
714 .private_value = nid | (mask<<16) }
715#endif /* CONFIG_SND_DEBUG */
716
Jonathan Woithe92621f12006-02-28 11:47:47 +0100717/* A switch control to allow the enabling of the digital IO pins on the
718 * ALC260. This is incredibly simplistic; the intention of this control is
719 * to provide something in the test model allowing digital outputs to be
720 * identified if present. If models are found which can utilise these
721 * outputs a more complete mixer control can be devised for those models if
722 * necessary.
723 */
724#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200725#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200726
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200727static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
728 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100729{
730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
731 hda_nid_t nid = kcontrol->private_value & 0xffff;
732 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
733 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200734 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100735 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100736
737 *valp = (val & mask) != 0;
738 return 0;
739}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200740static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
741 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100742{
743 signed int change;
744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
745 hda_nid_t nid = kcontrol->private_value & 0xffff;
746 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
747 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200748 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100749 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200750 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100751
752 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200753 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100754 if (val==0)
755 ctrl_data &= ~mask;
756 else
757 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200758 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
759 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100760
761 return change;
762}
763#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
764 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100765 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100766 .info = alc_spdif_ctrl_info, \
767 .get = alc_spdif_ctrl_get, \
768 .put = alc_spdif_ctrl_put, \
769 .private_value = nid | (mask<<16) }
770#endif /* CONFIG_SND_DEBUG */
771
Jonathan Woithef8225f62008-01-08 12:16:54 +0100772/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
773 * Again, this is only used in the ALC26x test models to help identify when
774 * the EAPD line must be asserted for features to work.
775 */
776#ifdef CONFIG_SND_DEBUG
777#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
778
779static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
780 struct snd_ctl_elem_value *ucontrol)
781{
782 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
783 hda_nid_t nid = kcontrol->private_value & 0xffff;
784 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
785 long *valp = ucontrol->value.integer.value;
786 unsigned int val = snd_hda_codec_read(codec, nid, 0,
787 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
788
789 *valp = (val & mask) != 0;
790 return 0;
791}
792
793static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
794 struct snd_ctl_elem_value *ucontrol)
795{
796 int change;
797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
798 hda_nid_t nid = kcontrol->private_value & 0xffff;
799 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
800 long val = *ucontrol->value.integer.value;
801 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
802 AC_VERB_GET_EAPD_BTLENABLE,
803 0x00);
804
805 /* Set/unset the masked control bit(s) as needed */
806 change = (!val ? 0 : mask) != (ctrl_data & mask);
807 if (!val)
808 ctrl_data &= ~mask;
809 else
810 ctrl_data |= mask;
811 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
812 ctrl_data);
813
814 return change;
815}
816
817#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
818 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100819 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100820 .info = alc_eapd_ctrl_info, \
821 .get = alc_eapd_ctrl_get, \
822 .put = alc_eapd_ctrl_put, \
823 .private_value = nid | (mask<<16) }
824#endif /* CONFIG_SND_DEBUG */
825
Kailang Yangdf694da2005-12-05 19:42:22 +0100826/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100827 * set up the input pin config (depending on the given auto-pin type)
828 */
829static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
830 int auto_pin_type)
831{
832 unsigned int val = PIN_IN;
833
834 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
835 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100836 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100837 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
838 if (pincap & AC_PINCAP_VREF_80)
839 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200840 else if (pincap & AC_PINCAP_VREF_50)
841 val = PIN_VREF50;
842 else if (pincap & AC_PINCAP_VREF_100)
843 val = PIN_VREF100;
844 else if (pincap & AC_PINCAP_VREF_GRD)
845 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100846 }
847 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
848}
849
850/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100851 */
852static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
853{
854 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
855 return;
856 spec->mixers[spec->num_mixers++] = mix;
857}
858
859static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
860{
861 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
862 return;
863 spec->init_verbs[spec->num_init_verbs++] = verb;
864}
865
866/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100867 * set up from the preset table
868 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200869static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200870 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100871{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200872 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100873 int i;
874
875 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100876 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100877 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200878 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
879 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100880 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200881
Kailang Yangdf694da2005-12-05 19:42:22 +0100882 spec->channel_mode = preset->channel_mode;
883 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200884 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200885 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100886
Hector Martin3b315d72009-06-02 10:54:19 +0200887 if (preset->const_channel_count)
888 spec->multiout.max_channels = preset->const_channel_count;
889 else
890 spec->multiout.max_channels = spec->channel_mode[0].channels;
891 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100892
893 spec->multiout.num_dacs = preset->num_dacs;
894 spec->multiout.dac_nids = preset->dac_nids;
895 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800896 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100897 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200898
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200899 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200900 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200901 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100902 spec->input_mux = preset->input_mux;
903
904 spec->num_adc_nids = preset->num_adc_nids;
905 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100906 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100907 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100908
909 spec->unsol_event = preset->unsol_event;
910 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200911#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100912 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200913 spec->loopback.amplist = preset->loopbacks;
914#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200915
916 if (preset->setup)
917 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100918}
919
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200920/* Enable GPIO mask and set output */
921static struct hda_verb alc_gpio1_init_verbs[] = {
922 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
923 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
924 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
925 { }
926};
927
928static struct hda_verb alc_gpio2_init_verbs[] = {
929 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
930 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
931 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
932 { }
933};
934
Kailang Yangbdd148a2007-05-08 15:19:08 +0200935static struct hda_verb alc_gpio3_init_verbs[] = {
936 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
937 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
938 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
939 { }
940};
941
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200942/*
943 * Fix hardware PLL issue
944 * On some codecs, the analog PLL gating control must be off while
945 * the default value is 1.
946 */
947static void alc_fix_pll(struct hda_codec *codec)
948{
949 struct alc_spec *spec = codec->spec;
950 unsigned int val;
951
952 if (!spec->pll_nid)
953 return;
954 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
955 spec->pll_coef_idx);
956 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
957 AC_VERB_GET_PROC_COEF, 0);
958 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
959 spec->pll_coef_idx);
960 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
961 val & ~(1 << spec->pll_coef_bit));
962}
963
964static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
965 unsigned int coef_idx, unsigned int coef_bit)
966{
967 struct alc_spec *spec = codec->spec;
968 spec->pll_nid = nid;
969 spec->pll_coef_idx = coef_idx;
970 spec->pll_coef_bit = coef_bit;
971 alc_fix_pll(codec);
972}
973
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200974static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200975{
976 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200977 unsigned int nid = spec->autocfg.hp_pins[0];
978 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200979
Takashi Iwaiad87c642009-11-02 14:23:15 +0100980 if (!nid)
981 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800982 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200983 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
984 nid = spec->autocfg.speaker_pins[i];
985 if (!nid)
986 break;
987 snd_hda_codec_write(codec, nid, 0,
988 AC_VERB_SET_PIN_WIDGET_CONTROL,
989 spec->jack_present ? 0 : PIN_OUT);
990 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200991}
992
Takashi Iwai6c819492009-08-10 18:47:44 +0200993static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
994 hda_nid_t nid)
995{
996 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
997 int i, nums;
998
999 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1000 for (i = 0; i < nums; i++)
1001 if (conn[i] == nid)
1002 return i;
1003 return -1;
1004}
1005
Kailang Yang7fb0d782008-10-15 11:12:35 +02001006static void alc_mic_automute(struct hda_codec *codec)
1007{
1008 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001009 struct alc_mic_route *dead, *alive;
1010 unsigned int present, type;
1011 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001012
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001013 if (!spec->auto_mic)
1014 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001015 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1016 return;
1017 if (snd_BUG_ON(!spec->adc_nids))
1018 return;
1019
1020 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1021
Wu Fengguang864f92b2009-11-18 12:38:02 +08001022 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001023 if (present) {
1024 alive = &spec->ext_mic;
1025 dead = &spec->int_mic;
1026 } else {
1027 alive = &spec->int_mic;
1028 dead = &spec->ext_mic;
1029 }
1030
Takashi Iwai6c819492009-08-10 18:47:44 +02001031 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1032 if (type == AC_WID_AUD_MIX) {
1033 /* Matrix-mixer style (e.g. ALC882) */
1034 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1035 alive->mux_idx,
1036 HDA_AMP_MUTE, 0);
1037 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1038 dead->mux_idx,
1039 HDA_AMP_MUTE, HDA_AMP_MUTE);
1040 } else {
1041 /* MUX style (e.g. ALC880) */
1042 snd_hda_codec_write_cache(codec, cap_nid, 0,
1043 AC_VERB_SET_CONNECT_SEL,
1044 alive->mux_idx);
1045 }
1046
1047 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001048}
1049
Kailang Yangc9b58002007-10-16 14:30:01 +02001050/* unsolicited event for HP jack sensing */
1051static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1052{
1053 if (codec->vendor_id == 0x10ec0880)
1054 res >>= 28;
1055 else
1056 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001057 switch (res) {
1058 case ALC880_HP_EVENT:
1059 alc_automute_pin(codec);
1060 break;
1061 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001062 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001063 break;
1064 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001065}
1066
1067static void alc_inithook(struct hda_codec *codec)
1068{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001069 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001070 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001071}
1072
Kailang Yangf9423e72008-05-27 12:32:25 +02001073/* additional initialization for ALC888 variants */
1074static void alc888_coef_init(struct hda_codec *codec)
1075{
1076 unsigned int tmp;
1077
1078 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1079 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1080 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001081 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001082 /* alc888S-VC */
1083 snd_hda_codec_read(codec, 0x20, 0,
1084 AC_VERB_SET_PROC_COEF, 0x830);
1085 else
1086 /* alc888-VB */
1087 snd_hda_codec_read(codec, 0x20, 0,
1088 AC_VERB_SET_PROC_COEF, 0x3030);
1089}
1090
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001091static void alc889_coef_init(struct hda_codec *codec)
1092{
1093 unsigned int tmp;
1094
1095 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1096 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1097 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1098 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1099}
1100
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001101/* turn on/off EAPD control (only if available) */
1102static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1103{
1104 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1105 return;
1106 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1107 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1108 on ? 2 : 0);
1109}
1110
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001111static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001112{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001113 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001114
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001115 switch (type) {
1116 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001117 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1118 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001119 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001120 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1121 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001122 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001123 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1124 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001125 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001126 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001128 set_eapd(codec, 0x0f, 1);
1129 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 break;
1131 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001132 case 0x10ec0267:
1133 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001135 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001136 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001137 case 0x10ec0660:
1138 case 0x10ec0662:
1139 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001140 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001141 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001142 set_eapd(codec, 0x14, 1);
1143 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001144 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001145 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001146 switch (codec->vendor_id) {
1147 case 0x10ec0260:
1148 snd_hda_codec_write(codec, 0x1a, 0,
1149 AC_VERB_SET_COEF_INDEX, 7);
1150 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1151 AC_VERB_GET_PROC_COEF, 0);
1152 snd_hda_codec_write(codec, 0x1a, 0,
1153 AC_VERB_SET_COEF_INDEX, 7);
1154 snd_hda_codec_write(codec, 0x1a, 0,
1155 AC_VERB_SET_PROC_COEF,
1156 tmp | 0x2010);
1157 break;
1158 case 0x10ec0262:
1159 case 0x10ec0880:
1160 case 0x10ec0882:
1161 case 0x10ec0883:
1162 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001163 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001164 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001165 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001166 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001167 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001168 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001169 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001170#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001171 case 0x10ec0267:
1172 case 0x10ec0268:
1173 snd_hda_codec_write(codec, 0x20, 0,
1174 AC_VERB_SET_COEF_INDEX, 7);
1175 tmp = snd_hda_codec_read(codec, 0x20, 0,
1176 AC_VERB_GET_PROC_COEF, 0);
1177 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001178 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001179 snd_hda_codec_write(codec, 0x20, 0,
1180 AC_VERB_SET_PROC_COEF,
1181 tmp | 0x3000);
1182 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001183#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001184 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001185 break;
1186 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001187}
Kailang Yangea1fb292008-08-26 12:58:38 +02001188
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001189static void alc_init_auto_hp(struct hda_codec *codec)
1190{
1191 struct alc_spec *spec = codec->spec;
1192
1193 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001194 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001195
Kailang Yangc9b58002007-10-16 14:30:01 +02001196 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001197 if (spec->autocfg.line_out_pins[0] &&
1198 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001199 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001200 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001201 else
1202 return;
1203 }
1204
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001205 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1206 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001207 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1208 AC_VERB_SET_UNSOLICITED_ENABLE,
1209 AC_USRSP_EN | ALC880_HP_EVENT);
1210 spec->unsol_event = alc_sku_unsol_event;
1211}
1212
Takashi Iwai6c819492009-08-10 18:47:44 +02001213static void alc_init_auto_mic(struct hda_codec *codec)
1214{
1215 struct alc_spec *spec = codec->spec;
1216 struct auto_pin_cfg *cfg = &spec->autocfg;
1217 hda_nid_t fixed, ext;
1218 int i;
1219
1220 /* there must be only two mic inputs exclusively */
1221 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1222 if (cfg->input_pins[i])
1223 return;
1224
1225 fixed = ext = 0;
1226 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1227 hda_nid_t nid = cfg->input_pins[i];
1228 unsigned int defcfg;
1229 if (!nid)
1230 return;
1231 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1232 switch (get_defcfg_connect(defcfg)) {
1233 case AC_JACK_PORT_FIXED:
1234 if (fixed)
1235 return; /* already occupied */
1236 fixed = nid;
1237 break;
1238 case AC_JACK_PORT_COMPLEX:
1239 if (ext)
1240 return; /* already occupied */
1241 ext = nid;
1242 break;
1243 default:
1244 return; /* invalid entry */
1245 }
1246 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001247 if (!ext || !fixed)
1248 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001249 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1250 return; /* no unsol support */
1251 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1252 ext, fixed);
1253 spec->ext_mic.pin = ext;
1254 spec->int_mic.pin = fixed;
1255 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1256 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1257 spec->auto_mic = 1;
1258 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1259 AC_VERB_SET_UNSOLICITED_ENABLE,
1260 AC_USRSP_EN | ALC880_MIC_EVENT);
1261 spec->unsol_event = alc_sku_unsol_event;
1262}
1263
Kailang Yangda00c242010-03-19 11:23:45 +01001264static int alc_auto_parse_customize_define(struct hda_codec *codec)
1265{
1266 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001267 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001268 struct alc_spec *spec = codec->spec;
1269
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001270 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1271
Kailang Yangda00c242010-03-19 11:23:45 +01001272 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001273 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001274 goto do_sku;
1275
1276 nid = 0x1d;
1277 if (codec->vendor_id == 0x10ec0260)
1278 nid = 0x17;
1279 ass = snd_hda_codec_get_pincfg(codec, nid);
1280
1281 if (!(ass & 1)) {
1282 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1283 codec->chip_name, ass);
1284 return -1;
1285 }
1286
1287 /* check sum */
1288 tmp = 0;
1289 for (i = 1; i < 16; i++) {
1290 if ((ass >> i) & 1)
1291 tmp++;
1292 }
1293 if (((ass >> 16) & 0xf) != tmp)
1294 return -1;
1295
1296 spec->cdefine.port_connectivity = ass >> 30;
1297 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1298 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1299 spec->cdefine.customization = ass >> 8;
1300do_sku:
1301 spec->cdefine.sku_cfg = ass;
1302 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1303 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1304 spec->cdefine.swap = (ass & 0x2) >> 1;
1305 spec->cdefine.override = ass & 0x1;
1306
1307 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1308 nid, spec->cdefine.sku_cfg);
1309 snd_printd("SKU: port_connectivity=0x%x\n",
1310 spec->cdefine.port_connectivity);
1311 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1312 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1313 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1314 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1315 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1316 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1317 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1318
1319 return 0;
1320}
1321
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001322/* check subsystem ID and set up device-specific initialization;
1323 * return 1 if initialized, 0 if invalid SSID
1324 */
1325/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1326 * 31 ~ 16 : Manufacture ID
1327 * 15 ~ 8 : SKU ID
1328 * 7 ~ 0 : Assembly ID
1329 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1330 */
1331static int alc_subsystem_id(struct hda_codec *codec,
1332 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001333 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001334{
1335 unsigned int ass, tmp, i;
1336 unsigned nid;
1337 struct alc_spec *spec = codec->spec;
1338
1339 ass = codec->subsystem_id & 0xffff;
1340 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1341 goto do_sku;
1342
1343 /* invalid SSID, check the special NID pin defcfg instead */
1344 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001345 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001346 * 29~21 : reserve
1347 * 20 : PCBEEP input
1348 * 19~16 : Check sum (15:1)
1349 * 15~1 : Custom
1350 * 0 : override
1351 */
1352 nid = 0x1d;
1353 if (codec->vendor_id == 0x10ec0260)
1354 nid = 0x17;
1355 ass = snd_hda_codec_get_pincfg(codec, nid);
1356 snd_printd("realtek: No valid SSID, "
1357 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001358 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001359 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001360 return 0;
1361 if ((ass >> 30) != 1) /* no physical connection */
1362 return 0;
1363
1364 /* check sum */
1365 tmp = 0;
1366 for (i = 1; i < 16; i++) {
1367 if ((ass >> i) & 1)
1368 tmp++;
1369 }
1370 if (((ass >> 16) & 0xf) != tmp)
1371 return 0;
1372do_sku:
1373 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1374 ass & 0xffff, codec->vendor_id);
1375 /*
1376 * 0 : override
1377 * 1 : Swap Jack
1378 * 2 : 0 --> Desktop, 1 --> Laptop
1379 * 3~5 : External Amplifier control
1380 * 7~6 : Reserved
1381 */
1382 tmp = (ass & 0x38) >> 3; /* external Amp control */
1383 switch (tmp) {
1384 case 1:
1385 spec->init_amp = ALC_INIT_GPIO1;
1386 break;
1387 case 3:
1388 spec->init_amp = ALC_INIT_GPIO2;
1389 break;
1390 case 7:
1391 spec->init_amp = ALC_INIT_GPIO3;
1392 break;
1393 case 5:
1394 spec->init_amp = ALC_INIT_DEFAULT;
1395 break;
1396 }
1397
1398 /* is laptop or Desktop and enable the function "Mute internal speaker
1399 * when the external headphone out jack is plugged"
1400 */
1401 if (!(ass & 0x8000))
1402 return 1;
1403 /*
1404 * 10~8 : Jack location
1405 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1406 * 14~13: Resvered
1407 * 15 : 1 --> enable the function "Mute internal speaker
1408 * when the external headphone out jack is plugged"
1409 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001410 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001411 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001412 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1413 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001414 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001415 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001416 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001417 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001418 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001419 else if (tmp == 3)
1420 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001421 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001422 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001423 for (i = 0; i < spec->autocfg.line_outs; i++)
1424 if (spec->autocfg.line_out_pins[i] == nid)
1425 return 1;
1426 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001427 }
1428
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001429 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001430 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001431 return 1;
1432}
Kailang Yangea1fb292008-08-26 12:58:38 +02001433
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001434static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001435 hda_nid_t porta, hda_nid_t porte,
1436 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001437{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001438 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001439 struct alc_spec *spec = codec->spec;
1440 snd_printd("realtek: "
1441 "Enable default setup for auto mode as fallback\n");
1442 spec->init_amp = ALC_INIT_DEFAULT;
1443 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001444 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001445 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001446}
1447
Takashi Iwai41e41f12005-06-08 14:48:49 +02001448/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001449 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001450 */
1451
1452struct alc_pincfg {
1453 hda_nid_t nid;
1454 u32 val;
1455};
1456
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001457struct alc_fixup {
1458 const struct alc_pincfg *pins;
1459 const struct hda_verb *verbs;
1460};
1461
1462static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001463 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001464 const struct alc_fixup *fix,
1465 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001466{
1467 const struct alc_pincfg *cfg;
1468
1469 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1470 if (!quirk)
1471 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001472 fix += quirk->value;
1473 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001474 if (pre_init && cfg) {
1475#ifdef CONFIG_SND_DEBUG_VERBOSE
1476 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1477 codec->chip_name, quirk->name);
1478#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001479 for (; cfg->nid; cfg++)
1480 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1481 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001482 if (!pre_init && fix->verbs) {
1483#ifdef CONFIG_SND_DEBUG_VERBOSE
1484 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1485 codec->chip_name, quirk->name);
1486#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001487 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001488 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001489}
1490
Kailang Yang274693f2009-12-03 10:07:50 +01001491static int alc_read_coef_idx(struct hda_codec *codec,
1492 unsigned int coef_idx)
1493{
1494 unsigned int val;
1495 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1496 coef_idx);
1497 val = snd_hda_codec_read(codec, 0x20, 0,
1498 AC_VERB_GET_PROC_COEF, 0);
1499 return val;
1500}
1501
Takashi Iwaif95474e2007-07-10 00:47:43 +02001502/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001503 * ALC888
1504 */
1505
1506/*
1507 * 2ch mode
1508 */
1509static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1510/* Mic-in jack as mic in */
1511 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1512 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1513/* Line-in jack as Line in */
1514 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1515 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1516/* Line-Out as Front */
1517 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1518 { } /* end */
1519};
1520
1521/*
1522 * 4ch mode
1523 */
1524static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1525/* Mic-in jack as mic in */
1526 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1527 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1528/* Line-in jack as Surround */
1529 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1530 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1531/* Line-Out as Front */
1532 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1533 { } /* end */
1534};
1535
1536/*
1537 * 6ch mode
1538 */
1539static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1540/* Mic-in jack as CLFE */
1541 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1542 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1543/* Line-in jack as Surround */
1544 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1545 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1546/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1547 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1548 { } /* end */
1549};
1550
1551/*
1552 * 8ch mode
1553 */
1554static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1555/* Mic-in jack as CLFE */
1556 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1557 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1558/* Line-in jack as Surround */
1559 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1560 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1561/* Line-Out as Side */
1562 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1563 { } /* end */
1564};
1565
1566static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1567 { 2, alc888_4ST_ch2_intel_init },
1568 { 4, alc888_4ST_ch4_intel_init },
1569 { 6, alc888_4ST_ch6_intel_init },
1570 { 8, alc888_4ST_ch8_intel_init },
1571};
1572
1573/*
1574 * ALC888 Fujitsu Siemens Amillo xa3530
1575 */
1576
1577static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1578/* Front Mic: set to PIN_IN (empty by default) */
1579 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1580/* Connect Internal HP to Front */
1581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1582 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1583 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1584/* Connect Bass HP to Front */
1585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1587 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1588/* Connect Line-Out side jack (SPDIF) to Side */
1589 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1590 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1591 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1592/* Connect Mic jack to CLFE */
1593 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1594 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1595 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1596/* Connect Line-in jack to Surround */
1597 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1598 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1599 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1600/* Connect HP out jack to Front */
1601 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1602 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1603 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1604/* Enable unsolicited event for HP jack and Line-out jack */
1605 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1606 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1607 {}
1608};
1609
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001610static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001611{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001612 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001613 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001614 hda_nid_t nid;
1615 int i;
1616
1617 spec->jack_present = 0;
1618 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1619 nid = spec->autocfg.hp_pins[i];
1620 if (!nid)
1621 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001622 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001623 spec->jack_present = 1;
1624 break;
1625 }
1626 }
1627
1628 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001629 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001630 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1631 nid = spec->autocfg.speaker_pins[i];
1632 if (!nid)
1633 break;
1634 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1635 HDA_AMP_MUTE, mute);
1636 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001637}
1638
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001639static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1640 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001641{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001642 if (codec->vendor_id == 0x10ec0880)
1643 res >>= 28;
1644 else
1645 res >>= 26;
1646 if (res == ALC880_HP_EVENT)
1647 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001648}
1649
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001650static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001651{
1652 struct alc_spec *spec = codec->spec;
1653
1654 spec->autocfg.hp_pins[0] = 0x15;
1655 spec->autocfg.speaker_pins[0] = 0x14;
1656 spec->autocfg.speaker_pins[1] = 0x16;
1657 spec->autocfg.speaker_pins[2] = 0x17;
1658 spec->autocfg.speaker_pins[3] = 0x19;
1659 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001660}
1661
1662static void alc889_intel_init_hook(struct hda_codec *codec)
1663{
1664 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001665 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001666}
1667
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001668static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001669{
1670 struct alc_spec *spec = codec->spec;
1671
1672 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1673 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1674 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1675 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001676}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001677
1678/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001679 * ALC888 Acer Aspire 4930G model
1680 */
1681
1682static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1683/* Front Mic: set to PIN_IN (empty by default) */
1684 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1685/* Unselect Front Mic by default in input mixer 3 */
1686 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001687/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001688 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1689/* Connect Internal HP to front */
1690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1693/* Connect HP out to front */
1694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1696 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1697 { }
1698};
1699
Hector Martin3b315d72009-06-02 10:54:19 +02001700/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001701 * ALC888 Acer Aspire 6530G model
1702 */
1703
1704static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001705/* Route to built-in subwoofer as well as speakers */
1706 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1708 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001710/* Bias voltage on for external mic port */
1711 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001712/* Front Mic: set to PIN_IN (empty by default) */
1713 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1714/* Unselect Front Mic by default in input mixer 3 */
1715 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001716/* Enable unsolicited event for HP jack */
1717 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1718/* Enable speaker output */
1719 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1720 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001721 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001722/* Enable headphone output */
1723 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1725 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001726 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001727 { }
1728};
1729
1730/*
Hector Martin018df412009-06-04 00:13:40 +02001731 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001732 */
1733
Hector Martin018df412009-06-04 00:13:40 +02001734static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001735/* Front Mic: set to PIN_IN (empty by default) */
1736 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1737/* Unselect Front Mic by default in input mixer 3 */
1738 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1739/* Enable unsolicited event for HP jack */
1740 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1741/* Connect Internal Front to Front */
1742 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1744 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1745/* Connect Internal Rear to Rear */
1746 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1747 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1748 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1749/* Connect Internal CLFE to CLFE */
1750 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1751 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1752 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1753/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001754 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1757/* Enable all DACs */
1758/* DAC DISABLE/MUTE 1? */
1759/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1760 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1761 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1762/* DAC DISABLE/MUTE 2? */
1763/* some bit here disables the other DACs. Init=0x4900 */
1764 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1765 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001766/* DMIC fix
1767 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1768 * which makes the stereo useless. However, either the mic or the ALC889
1769 * makes the signal become a difference/sum signal instead of standard
1770 * stereo, which is annoying. So instead we flip this bit which makes the
1771 * codec replicate the sum signal to both channels, turning it into a
1772 * normal mono mic.
1773 */
1774/* DMIC_CONTROL? Init value = 0x0001 */
1775 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1776 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001777 { }
1778};
1779
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001780static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001781 /* Front mic only available on one ADC */
1782 {
1783 .num_items = 4,
1784 .items = {
1785 { "Mic", 0x0 },
1786 { "Line", 0x2 },
1787 { "CD", 0x4 },
1788 { "Front Mic", 0xb },
1789 },
1790 },
1791 {
1792 .num_items = 3,
1793 .items = {
1794 { "Mic", 0x0 },
1795 { "Line", 0x2 },
1796 { "CD", 0x4 },
1797 },
1798 }
1799};
1800
Tony Vroond2fd4b02009-06-21 00:40:10 +01001801static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1802 /* Interal mic only available on one ADC */
1803 {
Tony Vroon684a8842009-06-26 09:27:50 +01001804 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001805 .items = {
1806 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001807 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001808 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001809 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001810 { "Int Mic", 0xb },
1811 },
1812 },
1813 {
Tony Vroon684a8842009-06-26 09:27:50 +01001814 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001815 .items = {
1816 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001817 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001818 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001819 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001820 },
1821 }
1822};
1823
Hector Martin018df412009-06-04 00:13:40 +02001824static struct hda_input_mux alc889_capture_sources[3] = {
1825 /* Digital mic only available on first "ADC" */
1826 {
1827 .num_items = 5,
1828 .items = {
1829 { "Mic", 0x0 },
1830 { "Line", 0x2 },
1831 { "CD", 0x4 },
1832 { "Front Mic", 0xb },
1833 { "Input Mix", 0xa },
1834 },
1835 },
1836 {
1837 .num_items = 4,
1838 .items = {
1839 { "Mic", 0x0 },
1840 { "Line", 0x2 },
1841 { "CD", 0x4 },
1842 { "Input Mix", 0xa },
1843 },
1844 },
1845 {
1846 .num_items = 4,
1847 .items = {
1848 { "Mic", 0x0 },
1849 { "Line", 0x2 },
1850 { "CD", 0x4 },
1851 { "Input Mix", 0xa },
1852 },
1853 }
1854};
1855
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001856static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001857 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1858 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1859 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1860 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1861 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1862 HDA_OUTPUT),
1863 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1864 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1865 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1866 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1867 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1868 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001875 { } /* end */
1876};
1877
Hector Martin556eea92009-12-20 22:51:23 +01001878static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1882 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1883 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1884 HDA_OUTPUT),
1885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1888 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1889 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1893 { } /* end */
1894};
1895
1896
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001897static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001898{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001899 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001900
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001901 spec->autocfg.hp_pins[0] = 0x15;
1902 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001903 spec->autocfg.speaker_pins[1] = 0x16;
1904 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001905}
1906
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001907static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001908{
1909 struct alc_spec *spec = codec->spec;
1910
1911 spec->autocfg.hp_pins[0] = 0x15;
1912 spec->autocfg.speaker_pins[0] = 0x14;
1913 spec->autocfg.speaker_pins[1] = 0x16;
1914 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001915}
1916
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001917static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001918{
1919 struct alc_spec *spec = codec->spec;
1920
1921 spec->autocfg.hp_pins[0] = 0x15;
1922 spec->autocfg.speaker_pins[0] = 0x14;
1923 spec->autocfg.speaker_pins[1] = 0x16;
1924 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001925}
1926
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001927/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001928 * ALC880 3-stack model
1929 *
1930 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001931 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1932 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933 */
1934
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001935static hda_nid_t alc880_dac_nids[4] = {
1936 /* front, rear, clfe, rear_surr */
1937 0x02, 0x05, 0x04, 0x03
1938};
1939
1940static hda_nid_t alc880_adc_nids[3] = {
1941 /* ADC0-2 */
1942 0x07, 0x08, 0x09,
1943};
1944
1945/* The datasheet says the node 0x07 is connected from inputs,
1946 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001947 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001948 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001949static hda_nid_t alc880_adc_nids_alt[2] = {
1950 /* ADC1-2 */
1951 0x08, 0x09,
1952};
1953
1954#define ALC880_DIGOUT_NID 0x06
1955#define ALC880_DIGIN_NID 0x0a
1956
1957static struct hda_input_mux alc880_capture_source = {
1958 .num_items = 4,
1959 .items = {
1960 { "Mic", 0x0 },
1961 { "Front Mic", 0x3 },
1962 { "Line", 0x2 },
1963 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001965};
1966
1967/* channel source setting (2/6 channel selection for 3-stack) */
1968/* 2ch mode */
1969static struct hda_verb alc880_threestack_ch2_init[] = {
1970 /* set line-in to input, mute it */
1971 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1972 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1973 /* set mic-in to input vref 80%, mute it */
1974 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1975 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001976 { } /* end */
1977};
1978
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001979/* 6ch mode */
1980static struct hda_verb alc880_threestack_ch6_init[] = {
1981 /* set line-in to output, unmute it */
1982 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1983 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1984 /* set mic-in to output, unmute it */
1985 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1986 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1987 { } /* end */
1988};
1989
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001990static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001991 { 2, alc880_threestack_ch2_init },
1992 { 6, alc880_threestack_ch6_init },
1993};
1994
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001995static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001996 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001997 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001998 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001999 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002000 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2001 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002002 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2003 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002004 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2005 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2006 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2007 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2010 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2011 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002013 {
2014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2015 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002016 .info = alc_ch_mode_info,
2017 .get = alc_ch_mode_get,
2018 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002019 },
2020 { } /* end */
2021};
2022
2023/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002024static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2025 struct snd_ctl_elem_info *uinfo)
2026{
2027 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2028 struct alc_spec *spec = codec->spec;
2029 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002030
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002031 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002032 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2033 HDA_INPUT);
2034 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002035 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002036 return err;
2037}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002039static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2040 unsigned int size, unsigned int __user *tlv)
2041{
2042 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2043 struct alc_spec *spec = codec->spec;
2044 int err;
2045
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002046 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002047 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2048 HDA_INPUT);
2049 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002050 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002051 return err;
2052}
2053
2054typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2055 struct snd_ctl_elem_value *ucontrol);
2056
2057static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2058 struct snd_ctl_elem_value *ucontrol,
2059 getput_call_t func)
2060{
2061 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2062 struct alc_spec *spec = codec->spec;
2063 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2064 int err;
2065
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002066 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002067 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2068 3, 0, HDA_INPUT);
2069 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002070 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002071 return err;
2072}
2073
2074static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2075 struct snd_ctl_elem_value *ucontrol)
2076{
2077 return alc_cap_getput_caller(kcontrol, ucontrol,
2078 snd_hda_mixer_amp_volume_get);
2079}
2080
2081static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2082 struct snd_ctl_elem_value *ucontrol)
2083{
2084 return alc_cap_getput_caller(kcontrol, ucontrol,
2085 snd_hda_mixer_amp_volume_put);
2086}
2087
2088/* capture mixer elements */
2089#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2090
2091static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2092 struct snd_ctl_elem_value *ucontrol)
2093{
2094 return alc_cap_getput_caller(kcontrol, ucontrol,
2095 snd_hda_mixer_amp_switch_get);
2096}
2097
2098static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2099 struct snd_ctl_elem_value *ucontrol)
2100{
2101 return alc_cap_getput_caller(kcontrol, ucontrol,
2102 snd_hda_mixer_amp_switch_put);
2103}
2104
Takashi Iwaia23b6882009-03-23 15:21:36 +01002105#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002106 { \
2107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2108 .name = "Capture Switch", \
2109 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2110 .count = num, \
2111 .info = alc_cap_sw_info, \
2112 .get = alc_cap_sw_get, \
2113 .put = alc_cap_sw_put, \
2114 }, \
2115 { \
2116 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2117 .name = "Capture Volume", \
2118 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2119 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2120 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2121 .count = num, \
2122 .info = alc_cap_vol_info, \
2123 .get = alc_cap_vol_get, \
2124 .put = alc_cap_vol_put, \
2125 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002126 }
2127
2128#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002129 { \
2130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2131 /* .name = "Capture Source", */ \
2132 .name = "Input Source", \
2133 .count = num, \
2134 .info = alc_mux_enum_info, \
2135 .get = alc_mux_enum_get, \
2136 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002137 }
2138
2139#define DEFINE_CAPMIX(num) \
2140static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2141 _DEFINE_CAPMIX(num), \
2142 _DEFINE_CAPSRC(num), \
2143 { } /* end */ \
2144}
2145
2146#define DEFINE_CAPMIX_NOSRC(num) \
2147static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2148 _DEFINE_CAPMIX(num), \
2149 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002150}
2151
2152/* up to three ADCs */
2153DEFINE_CAPMIX(1);
2154DEFINE_CAPMIX(2);
2155DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002156DEFINE_CAPMIX_NOSRC(1);
2157DEFINE_CAPMIX_NOSRC(2);
2158DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002159
2160/*
2161 * ALC880 5-stack model
2162 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002163 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2164 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002165 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2166 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2167 */
2168
2169/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002170static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002171 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002172 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173 { } /* end */
2174};
2175
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002176/* channel source setting (6/8 channel selection for 5-stack) */
2177/* 6ch mode */
2178static struct hda_verb alc880_fivestack_ch6_init[] = {
2179 /* set line-in to input, mute it */
2180 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2181 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002182 { } /* end */
2183};
2184
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002185/* 8ch mode */
2186static struct hda_verb alc880_fivestack_ch8_init[] = {
2187 /* set line-in to output, unmute it */
2188 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2189 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2190 { } /* end */
2191};
2192
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002193static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 { 6, alc880_fivestack_ch6_init },
2195 { 8, alc880_fivestack_ch8_init },
2196};
2197
2198
2199/*
2200 * ALC880 6-stack model
2201 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002202 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2203 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002204 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2205 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2206 */
2207
2208static hda_nid_t alc880_6st_dac_nids[4] = {
2209 /* front, rear, clfe, rear_surr */
2210 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002211};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002212
2213static struct hda_input_mux alc880_6stack_capture_source = {
2214 .num_items = 4,
2215 .items = {
2216 { "Mic", 0x0 },
2217 { "Front Mic", 0x1 },
2218 { "Line", 0x2 },
2219 { "CD", 0x4 },
2220 },
2221};
2222
2223/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002224static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002225 { 8, NULL },
2226};
2227
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002228static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002229 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002230 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002231 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002232 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002233 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2234 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002235 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2236 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002237 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002238 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002239 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2240 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2245 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2246 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002247 {
2248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2249 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002250 .info = alc_ch_mode_info,
2251 .get = alc_ch_mode_get,
2252 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002253 },
2254 { } /* end */
2255};
2256
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002257
2258/*
2259 * ALC880 W810 model
2260 *
2261 * W810 has rear IO for:
2262 * Front (DAC 02)
2263 * Surround (DAC 03)
2264 * Center/LFE (DAC 04)
2265 * Digital out (06)
2266 *
2267 * The system also has a pair of internal speakers, and a headphone jack.
2268 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002269 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002270 * There is a variable resistor to control the speaker or headphone
2271 * volume. This is a hardware-only device without a software API.
2272 *
2273 * Plugging headphones in will disable the internal speakers. This is
2274 * implemented in hardware, not via the driver using jack sense. In
2275 * a similar fashion, plugging into the rear socket marked "front" will
2276 * disable both the speakers and headphones.
2277 *
2278 * For input, there's a microphone jack, and an "audio in" jack.
2279 * These may not do anything useful with this driver yet, because I
2280 * haven't setup any initialization verbs for these yet...
2281 */
2282
2283static hda_nid_t alc880_w810_dac_nids[3] = {
2284 /* front, rear/surround, clfe */
2285 0x02, 0x03, 0x04
2286};
2287
2288/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002289static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002290 { 6, NULL }
2291};
2292
2293/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002294static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002295 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002296 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002297 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002298 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002299 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2300 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002301 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2302 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002303 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2304 { } /* end */
2305};
2306
2307
2308/*
2309 * Z710V model
2310 *
2311 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002312 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2313 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002314 */
2315
2316static hda_nid_t alc880_z71v_dac_nids[1] = {
2317 0x02
2318};
2319#define ALC880_Z71V_HP_DAC 0x03
2320
2321/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002322static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002323 { 2, NULL }
2324};
2325
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002326static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002327 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002328 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002329 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002330 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2334 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2335 { } /* end */
2336};
2337
2338
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002339/*
2340 * ALC880 F1734 model
2341 *
2342 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2343 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2344 */
2345
2346static hda_nid_t alc880_f1734_dac_nids[1] = {
2347 0x03
2348};
2349#define ALC880_F1734_HP_DAC 0x02
2350
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002351static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002352 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002353 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002354 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2355 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002360 { } /* end */
2361};
2362
Takashi Iwai937b4162008-02-11 14:52:36 +01002363static struct hda_input_mux alc880_f1734_capture_source = {
2364 .num_items = 2,
2365 .items = {
2366 { "Mic", 0x1 },
2367 { "CD", 0x4 },
2368 },
2369};
2370
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002371
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002372/*
2373 * ALC880 ASUS model
2374 *
2375 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2376 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2377 * Mic = 0x18, Line = 0x1a
2378 */
2379
2380#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2381#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2382
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002383static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002384 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002385 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002386 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002387 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002388 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2389 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002390 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2391 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002392 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2393 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2394 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2395 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002398 {
2399 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2400 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002401 .info = alc_ch_mode_info,
2402 .get = alc_ch_mode_get,
2403 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002404 },
2405 { } /* end */
2406};
2407
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002408/*
2409 * ALC880 ASUS W1V model
2410 *
2411 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2412 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2413 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2414 */
2415
2416/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002417static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002418 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2419 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002420 { } /* end */
2421};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002422
Kailang Yangdf694da2005-12-05 19:42:22 +01002423/* TCL S700 */
2424static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2425 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2426 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2429 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2432 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2433 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002434 { } /* end */
2435};
2436
Kailang Yangccc656c2006-10-17 12:32:26 +02002437/* Uniwill */
2438static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002439 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2440 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2441 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2442 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002443 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2444 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2445 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2446 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2449 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2450 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2451 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2452 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2453 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2454 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002455 {
2456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2457 .name = "Channel Mode",
2458 .info = alc_ch_mode_info,
2459 .get = alc_ch_mode_get,
2460 .put = alc_ch_mode_put,
2461 },
2462 { } /* end */
2463};
2464
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002465static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2466 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2467 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2468 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2469 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2470 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2471 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2472 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2473 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2474 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2475 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2476 { } /* end */
2477};
2478
Kailang Yangccc656c2006-10-17 12:32:26 +02002479static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002480 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2481 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2482 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2483 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2486 { } /* end */
2487};
2488
Linus Torvalds1da177e2005-04-16 15:20:36 -07002489/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002490 * virtual master controls
2491 */
2492
2493/*
2494 * slave controls for virtual master
2495 */
2496static const char *alc_slave_vols[] = {
2497 "Front Playback Volume",
2498 "Surround Playback Volume",
2499 "Center Playback Volume",
2500 "LFE Playback Volume",
2501 "Side Playback Volume",
2502 "Headphone Playback Volume",
2503 "Speaker Playback Volume",
2504 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002505 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002506 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002507 NULL,
2508};
2509
2510static const char *alc_slave_sws[] = {
2511 "Front Playback Switch",
2512 "Surround Playback Switch",
2513 "Center Playback Switch",
2514 "LFE Playback Switch",
2515 "Side Playback Switch",
2516 "Headphone Playback Switch",
2517 "Speaker Playback Switch",
2518 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002519 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002520 "Line-Out Playback Switch",
2521 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002522 NULL,
2523};
2524
2525/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002528
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002529#define NID_MAPPING (-1)
2530
2531#define SUBDEV_SPEAKER_ (0 << 6)
2532#define SUBDEV_HP_ (1 << 6)
2533#define SUBDEV_LINE_ (2 << 6)
2534#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2535#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2536#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2537
Takashi Iwai603c4012008-07-30 15:01:44 +02002538static void alc_free_kctls(struct hda_codec *codec);
2539
Takashi Iwai67d634c2009-11-16 15:35:59 +01002540#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002541/* additional beep mixers; the actual parameters are overwritten at build */
2542static struct snd_kcontrol_new alc_beep_mixer[] = {
2543 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002544 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002545 { } /* end */
2546};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002547#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002548
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549static int alc_build_controls(struct hda_codec *codec)
2550{
2551 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002552 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002553 struct snd_kcontrol_new *knew;
2554 int i, j, err;
2555 unsigned int u;
2556 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002557
2558 for (i = 0; i < spec->num_mixers; i++) {
2559 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2560 if (err < 0)
2561 return err;
2562 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002563 if (spec->cap_mixer) {
2564 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2565 if (err < 0)
2566 return err;
2567 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002568 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002569 err = snd_hda_create_spdif_out_ctls(codec,
2570 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 if (err < 0)
2572 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002573 if (!spec->no_analog) {
2574 err = snd_hda_create_spdif_share_sw(codec,
2575 &spec->multiout);
2576 if (err < 0)
2577 return err;
2578 spec->multiout.share_spdif = 1;
2579 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580 }
2581 if (spec->dig_in_nid) {
2582 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2583 if (err < 0)
2584 return err;
2585 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002586
Takashi Iwai67d634c2009-11-16 15:35:59 +01002587#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002588 /* create beep controls if needed */
2589 if (spec->beep_amp) {
2590 struct snd_kcontrol_new *knew;
2591 for (knew = alc_beep_mixer; knew->name; knew++) {
2592 struct snd_kcontrol *kctl;
2593 kctl = snd_ctl_new1(knew, codec);
2594 if (!kctl)
2595 return -ENOMEM;
2596 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002597 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002598 if (err < 0)
2599 return err;
2600 }
2601 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002602#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002603
Takashi Iwai2134ea42008-01-10 16:53:55 +01002604 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002605 if (!spec->no_analog &&
2606 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002607 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002608 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002609 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002610 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002611 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002612 if (err < 0)
2613 return err;
2614 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002615 if (!spec->no_analog &&
2616 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002617 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2618 NULL, alc_slave_sws);
2619 if (err < 0)
2620 return err;
2621 }
2622
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002623 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002624 if (spec->capsrc_nids || spec->adc_nids) {
2625 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2626 if (!kctl)
2627 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2628 for (i = 0; kctl && i < kctl->count; i++) {
2629 hda_nid_t *nids = spec->capsrc_nids;
2630 if (!nids)
2631 nids = spec->adc_nids;
2632 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2633 if (err < 0)
2634 return err;
2635 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002636 }
2637 if (spec->cap_mixer) {
2638 const char *kname = kctl ? kctl->id.name : NULL;
2639 for (knew = spec->cap_mixer; knew->name; knew++) {
2640 if (kname && strcmp(knew->name, kname) == 0)
2641 continue;
2642 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2643 for (i = 0; kctl && i < kctl->count; i++) {
2644 err = snd_hda_add_nid(codec, kctl, i,
2645 spec->adc_nids[i]);
2646 if (err < 0)
2647 return err;
2648 }
2649 }
2650 }
2651
2652 /* other nid->control mapping */
2653 for (i = 0; i < spec->num_mixers; i++) {
2654 for (knew = spec->mixers[i]; knew->name; knew++) {
2655 if (knew->iface != NID_MAPPING)
2656 continue;
2657 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2658 if (kctl == NULL)
2659 continue;
2660 u = knew->subdevice;
2661 for (j = 0; j < 4; j++, u >>= 8) {
2662 nid = u & 0x3f;
2663 if (nid == 0)
2664 continue;
2665 switch (u & 0xc0) {
2666 case SUBDEV_SPEAKER_:
2667 nid = spec->autocfg.speaker_pins[nid];
2668 break;
2669 case SUBDEV_LINE_:
2670 nid = spec->autocfg.line_out_pins[nid];
2671 break;
2672 case SUBDEV_HP_:
2673 nid = spec->autocfg.hp_pins[nid];
2674 break;
2675 default:
2676 continue;
2677 }
2678 err = snd_hda_add_nid(codec, kctl, 0, nid);
2679 if (err < 0)
2680 return err;
2681 }
2682 u = knew->private_value;
2683 for (j = 0; j < 4; j++, u >>= 8) {
2684 nid = u & 0xff;
2685 if (nid == 0)
2686 continue;
2687 err = snd_hda_add_nid(codec, kctl, 0, nid);
2688 if (err < 0)
2689 return err;
2690 }
2691 }
2692 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002693
2694 alc_free_kctls(codec); /* no longer needed */
2695
Linus Torvalds1da177e2005-04-16 15:20:36 -07002696 return 0;
2697}
2698
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002699
Linus Torvalds1da177e2005-04-16 15:20:36 -07002700/*
2701 * initialize the codec volumes, etc
2702 */
2703
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704/*
2705 * generic initialization of ADC, input mixers and output mixers
2706 */
2707static struct hda_verb alc880_volume_init_verbs[] = {
2708 /*
2709 * Unmute ADC0-2 and set the default input to mic-in
2710 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002711 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002713 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002714 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002715 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002716 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002717
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002718 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2719 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002720 * Note: PASD motherboards uses the Line In 2 as the input for front
2721 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002722 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002723 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002731
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002732 /*
2733 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002734 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002735 /* set vol=0 to output mixers */
2736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2737 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2739 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2740 /* set up input amps for analog loopback */
2741 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002746 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002748 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2749 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002750
2751 { }
2752};
2753
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002754/*
2755 * 3-stack pin configuration:
2756 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2757 */
2758static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2759 /*
2760 * preset connection lists of input pins
2761 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2762 */
2763 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2764 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2765 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2766
2767 /*
2768 * Set pin mode and muting
2769 */
2770 /* set front pin widgets 0x14 for output */
2771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2773 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2776 /* Mic2 (as headphone out) for HP output */
2777 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2779 /* Line In pin widget for input */
2780 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2782 /* Line2 (as front mic) pin widget for input and vref at 80% */
2783 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2784 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2785 /* CD pin widget for input */
2786 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2787
2788 { }
2789};
2790
2791/*
2792 * 5-stack pin configuration:
2793 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2794 * line-in/side = 0x1a, f-mic = 0x1b
2795 */
2796static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2797 /*
2798 * preset connection lists of input pins
2799 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2800 */
2801 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2802 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2803
2804 /*
2805 * Set pin mode and muting
2806 */
2807 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002808 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2810 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2811 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812 /* unmute pins for output (no gain on this amp) */
2813 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2815 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2816 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2817
Linus Torvalds1da177e2005-04-16 15:20:36 -07002818 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002819 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2821 /* Mic2 (as headphone out) for HP output */
2822 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002823 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002824 /* Line In pin widget for input */
2825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2827 /* Line2 (as front mic) pin widget for input and vref at 80% */
2828 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2829 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2830 /* CD pin widget for input */
2831 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002832
2833 { }
2834};
2835
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002836/*
2837 * W810 pin configuration:
2838 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2839 */
2840static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002841 /* hphone/speaker input selector: front DAC */
2842 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2843
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2849 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2850
2851 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002852 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002853
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854 { }
2855};
2856
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002857/*
2858 * Z71V pin configuration:
2859 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2860 */
2861static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002862 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002866
Takashi Iwai16ded522005-06-10 19:58:24 +02002867 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002868 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002869 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002870 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002871
2872 { }
2873};
2874
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002875/*
2876 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002877 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2878 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002879 */
2880static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2881 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2882
Takashi Iwai16ded522005-06-10 19:58:24 +02002883 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002885 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002887 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002889 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002890 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2891
Takashi Iwai16ded522005-06-10 19:58:24 +02002892 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002893 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002894 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002895 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002896 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002898 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002899 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002900 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002901
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002902 { }
2903};
Takashi Iwai16ded522005-06-10 19:58:24 +02002904
Kailang Yangccc656c2006-10-17 12:32:26 +02002905/*
2906 * Uniwill pin configuration:
2907 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2908 * line = 0x1a
2909 */
2910static struct hda_verb alc880_uniwill_init_verbs[] = {
2911 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2912
2913 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2918 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2920 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2923 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2924 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2927
2928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2934 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2935 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2937
2938 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2939 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2940
2941 { }
2942};
2943
2944/*
2945* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002946* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002947 */
2948static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2949 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2950
2951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2955 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2956 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2963
2964 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2965 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2966 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2967 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2968 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2969 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2970
2971 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2972 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2973
2974 { }
2975};
2976
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002977static struct hda_verb alc880_beep_init_verbs[] = {
2978 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2979 { }
2980};
2981
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002982/* auto-toggle front mic */
2983static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2984{
2985 unsigned int present;
2986 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002987
Wu Fengguang864f92b2009-11-18 12:38:02 +08002988 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002989 bits = present ? HDA_AMP_MUTE : 0;
2990 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002991}
2992
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002993static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002994{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002995 struct alc_spec *spec = codec->spec;
2996
2997 spec->autocfg.hp_pins[0] = 0x14;
2998 spec->autocfg.speaker_pins[0] = 0x15;
2999 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003000}
3001
3002static void alc880_uniwill_init_hook(struct hda_codec *codec)
3003{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003004 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003005 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003006}
3007
3008static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3009 unsigned int res)
3010{
3011 /* Looks like the unsol event is incompatible with the standard
3012 * definition. 4bit tag is placed at 28 bit!
3013 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003014 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003015 case ALC880_MIC_EVENT:
3016 alc880_uniwill_mic_automute(codec);
3017 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003018 default:
3019 alc_automute_amp_unsol_event(codec, res);
3020 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003021 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003022}
3023
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003024static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003025{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003026 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003027
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003028 spec->autocfg.hp_pins[0] = 0x14;
3029 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003030}
3031
3032static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3033{
3034 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003035
Kailang Yangccc656c2006-10-17 12:32:26 +02003036 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003037 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3038 present &= HDA_AMP_VOLMASK;
3039 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3040 HDA_AMP_VOLMASK, present);
3041 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3042 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003043}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003044
Kailang Yangccc656c2006-10-17 12:32:26 +02003045static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3046 unsigned int res)
3047{
3048 /* Looks like the unsol event is incompatible with the standard
3049 * definition. 4bit tag is placed at 28 bit!
3050 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003051 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003052 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003053 else
3054 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003055}
3056
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003057/*
3058 * F1734 pin configuration:
3059 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3060 */
3061static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003062 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003063 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3064 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3065 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3066 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3067
3068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3069 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3070 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3072
3073 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003075 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3077 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3080 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3081 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003082
Takashi Iwai937b4162008-02-11 14:52:36 +01003083 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3084 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3085
Takashi Iwai16ded522005-06-10 19:58:24 +02003086 { }
3087};
3088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089/*
3090 * ASUS pin configuration:
3091 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3092 */
3093static struct hda_verb alc880_pin_asus_init_verbs[] = {
3094 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3095 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3096 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3097 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3098
3099 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3100 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3102 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3103 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3105 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3106 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3107
3108 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3109 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3110 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3111 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3112 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3113 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3115 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3116 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003117
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118 { }
3119};
3120
3121/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003122#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3123#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003124#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003125
Kailang Yangdf694da2005-12-05 19:42:22 +01003126/* Clevo m520g init */
3127static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3128 /* headphone output */
3129 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3130 /* line-out */
3131 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3132 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3133 /* Line-in */
3134 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3136 /* CD */
3137 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3138 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3139 /* Mic1 (rear panel) */
3140 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3141 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3142 /* Mic2 (front panel) */
3143 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3144 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3145 /* headphone */
3146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3148 /* change to EAPD mode */
3149 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3150 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3151
3152 { }
3153};
3154
3155static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003156 /* change to EAPD mode */
3157 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3158 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3159
Kailang Yangdf694da2005-12-05 19:42:22 +01003160 /* Headphone output */
3161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3162 /* Front output*/
3163 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3164 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3165
3166 /* Line In pin widget for input */
3167 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3168 /* CD pin widget for input */
3169 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3170 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3171 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3172
3173 /* change to EAPD mode */
3174 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3175 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3176
3177 { }
3178};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003179
3180/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003181 * LG m1 express dual
3182 *
3183 * Pin assignment:
3184 * Rear Line-In/Out (blue): 0x14
3185 * Build-in Mic-In: 0x15
3186 * Speaker-out: 0x17
3187 * HP-Out (green): 0x1b
3188 * Mic-In/Out (red): 0x19
3189 * SPDIF-Out: 0x1e
3190 */
3191
3192/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3193static hda_nid_t alc880_lg_dac_nids[3] = {
3194 0x05, 0x02, 0x03
3195};
3196
3197/* seems analog CD is not working */
3198static struct hda_input_mux alc880_lg_capture_source = {
3199 .num_items = 3,
3200 .items = {
3201 { "Mic", 0x1 },
3202 { "Line", 0x5 },
3203 { "Internal Mic", 0x6 },
3204 },
3205};
3206
3207/* 2,4,6 channel modes */
3208static struct hda_verb alc880_lg_ch2_init[] = {
3209 /* set line-in and mic-in to input */
3210 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3211 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3212 { }
3213};
3214
3215static struct hda_verb alc880_lg_ch4_init[] = {
3216 /* set line-in to out and mic-in to input */
3217 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3218 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3219 { }
3220};
3221
3222static struct hda_verb alc880_lg_ch6_init[] = {
3223 /* set line-in and mic-in to output */
3224 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3225 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3226 { }
3227};
3228
3229static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3230 { 2, alc880_lg_ch2_init },
3231 { 4, alc880_lg_ch4_init },
3232 { 6, alc880_lg_ch6_init },
3233};
3234
3235static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3237 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003238 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3239 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3240 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3241 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3242 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3243 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3247 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3248 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3249 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3250 {
3251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3252 .name = "Channel Mode",
3253 .info = alc_ch_mode_info,
3254 .get = alc_ch_mode_get,
3255 .put = alc_ch_mode_put,
3256 },
3257 { } /* end */
3258};
3259
3260static struct hda_verb alc880_lg_init_verbs[] = {
3261 /* set capture source to mic-in */
3262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3264 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3265 /* mute all amp mixer inputs */
3266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003269 /* line-in to input */
3270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3272 /* built-in mic */
3273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3275 /* speaker-out */
3276 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3277 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3278 /* mic-in to input */
3279 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3281 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3282 /* HP-out */
3283 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3284 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3285 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3286 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003287 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003288 { }
3289};
3290
3291/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003292static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003293{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003294 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003295
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003296 spec->autocfg.hp_pins[0] = 0x1b;
3297 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003298}
3299
3300/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003301 * LG LW20
3302 *
3303 * Pin assignment:
3304 * Speaker-out: 0x14
3305 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003306 * Built-in Mic-In: 0x19
3307 * Line-In: 0x1b
3308 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003309 * SPDIF-Out: 0x1e
3310 */
3311
Takashi Iwaid6815182006-03-23 16:06:23 +01003312static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003313 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003314 .items = {
3315 { "Mic", 0x0 },
3316 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003317 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003318 },
3319};
3320
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003321#define alc880_lg_lw_modes alc880_threestack_modes
3322
Takashi Iwaid6815182006-03-23 16:06:23 +01003323static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3325 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3326 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3327 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3328 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3329 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3330 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3331 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3336 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3337 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003338 {
3339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3340 .name = "Channel Mode",
3341 .info = alc_ch_mode_info,
3342 .get = alc_ch_mode_get,
3343 .put = alc_ch_mode_put,
3344 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003345 { } /* end */
3346};
3347
3348static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003349 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3350 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3351 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3352
Takashi Iwaid6815182006-03-23 16:06:23 +01003353 /* set capture source to mic-in */
3354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3356 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003358 /* speaker-out */
3359 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3360 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3361 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3363 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3364 /* mic-in to input */
3365 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3367 /* built-in mic */
3368 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3369 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3370 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003371 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003372 { }
3373};
3374
3375/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003376static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003377{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003378 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003379
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003380 spec->autocfg.hp_pins[0] = 0x1b;
3381 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003382}
3383
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003384static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3385 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3386 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3387 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3388 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3389 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3390 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3391 { } /* end */
3392};
3393
3394static struct hda_input_mux alc880_medion_rim_capture_source = {
3395 .num_items = 2,
3396 .items = {
3397 { "Mic", 0x0 },
3398 { "Internal Mic", 0x1 },
3399 },
3400};
3401
3402static struct hda_verb alc880_medion_rim_init_verbs[] = {
3403 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3404
3405 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3406 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3407
3408 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3409 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3410 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3411 /* Mic2 (as headphone out) for HP output */
3412 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3413 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3414 /* Internal Speaker */
3415 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3416 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3417
3418 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3419 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3420
3421 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3422 { }
3423};
3424
3425/* toggle speaker-output according to the hp-jack state */
3426static void alc880_medion_rim_automute(struct hda_codec *codec)
3427{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003428 struct alc_spec *spec = codec->spec;
3429 alc_automute_amp(codec);
3430 /* toggle EAPD */
3431 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003432 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3433 else
3434 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3435}
3436
3437static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3438 unsigned int res)
3439{
3440 /* Looks like the unsol event is incompatible with the standard
3441 * definition. 4bit tag is placed at 28 bit!
3442 */
3443 if ((res >> 28) == ALC880_HP_EVENT)
3444 alc880_medion_rim_automute(codec);
3445}
3446
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003447static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003448{
3449 struct alc_spec *spec = codec->spec;
3450
3451 spec->autocfg.hp_pins[0] = 0x14;
3452 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003453}
3454
Takashi Iwaicb53c622007-08-10 17:21:45 +02003455#ifdef CONFIG_SND_HDA_POWER_SAVE
3456static struct hda_amp_list alc880_loopbacks[] = {
3457 { 0x0b, HDA_INPUT, 0 },
3458 { 0x0b, HDA_INPUT, 1 },
3459 { 0x0b, HDA_INPUT, 2 },
3460 { 0x0b, HDA_INPUT, 3 },
3461 { 0x0b, HDA_INPUT, 4 },
3462 { } /* end */
3463};
3464
3465static struct hda_amp_list alc880_lg_loopbacks[] = {
3466 { 0x0b, HDA_INPUT, 1 },
3467 { 0x0b, HDA_INPUT, 6 },
3468 { 0x0b, HDA_INPUT, 7 },
3469 { } /* end */
3470};
3471#endif
3472
Takashi Iwaid6815182006-03-23 16:06:23 +01003473/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003474 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003475 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003476
Linus Torvalds1da177e2005-04-16 15:20:36 -07003477static int alc_init(struct hda_codec *codec)
3478{
3479 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003480 unsigned int i;
3481
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003482 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003483 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003485 for (i = 0; i < spec->num_init_verbs; i++)
3486 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003487
3488 if (spec->init_hook)
3489 spec->init_hook(codec);
3490
Takashi Iwaiad358792010-03-30 18:00:59 +02003491#ifdef CONFIG_SND_HDA_POWER_SAVE
3492 if (codec->patch_ops.check_power_status)
3493 codec->patch_ops.check_power_status(codec, 0x01);
3494#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003495 return 0;
3496}
3497
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003498static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3499{
3500 struct alc_spec *spec = codec->spec;
3501
3502 if (spec->unsol_event)
3503 spec->unsol_event(codec, res);
3504}
3505
Takashi Iwaicb53c622007-08-10 17:21:45 +02003506#ifdef CONFIG_SND_HDA_POWER_SAVE
3507static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3508{
3509 struct alc_spec *spec = codec->spec;
3510 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3511}
3512#endif
3513
Linus Torvalds1da177e2005-04-16 15:20:36 -07003514/*
3515 * Analog playback callbacks
3516 */
3517static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3518 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003519 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003520{
3521 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003522 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3523 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003524}
3525
3526static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3527 struct hda_codec *codec,
3528 unsigned int stream_tag,
3529 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003530 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003531{
3532 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003533 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3534 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003535}
3536
3537static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3538 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003539 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003540{
3541 struct alc_spec *spec = codec->spec;
3542 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3543}
3544
3545/*
3546 * Digital out
3547 */
3548static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3549 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003550 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003551{
3552 struct alc_spec *spec = codec->spec;
3553 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3554}
3555
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003556static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3557 struct hda_codec *codec,
3558 unsigned int stream_tag,
3559 unsigned int format,
3560 struct snd_pcm_substream *substream)
3561{
3562 struct alc_spec *spec = codec->spec;
3563 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3564 stream_tag, format, substream);
3565}
3566
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003567static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3568 struct hda_codec *codec,
3569 struct snd_pcm_substream *substream)
3570{
3571 struct alc_spec *spec = codec->spec;
3572 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3573}
3574
Linus Torvalds1da177e2005-04-16 15:20:36 -07003575static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3576 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003577 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003578{
3579 struct alc_spec *spec = codec->spec;
3580 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3581}
3582
3583/*
3584 * Analog capture
3585 */
Takashi Iwai63300792008-01-24 15:31:36 +01003586static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003587 struct hda_codec *codec,
3588 unsigned int stream_tag,
3589 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003590 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003591{
3592 struct alc_spec *spec = codec->spec;
3593
Takashi Iwai63300792008-01-24 15:31:36 +01003594 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003595 stream_tag, 0, format);
3596 return 0;
3597}
3598
Takashi Iwai63300792008-01-24 15:31:36 +01003599static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003600 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003601 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003602{
3603 struct alc_spec *spec = codec->spec;
3604
Takashi Iwai888afa12008-03-18 09:57:50 +01003605 snd_hda_codec_cleanup_stream(codec,
3606 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003607 return 0;
3608}
3609
3610
3611/*
3612 */
3613static struct hda_pcm_stream alc880_pcm_analog_playback = {
3614 .substreams = 1,
3615 .channels_min = 2,
3616 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003617 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003618 .ops = {
3619 .open = alc880_playback_pcm_open,
3620 .prepare = alc880_playback_pcm_prepare,
3621 .cleanup = alc880_playback_pcm_cleanup
3622 },
3623};
3624
3625static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003626 .substreams = 1,
3627 .channels_min = 2,
3628 .channels_max = 2,
3629 /* NID is set in alc_build_pcms */
3630};
3631
3632static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3633 .substreams = 1,
3634 .channels_min = 2,
3635 .channels_max = 2,
3636 /* NID is set in alc_build_pcms */
3637};
3638
3639static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3640 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003641 .channels_min = 2,
3642 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003643 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003644 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003645 .prepare = alc880_alt_capture_pcm_prepare,
3646 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003647 },
3648};
3649
3650static struct hda_pcm_stream alc880_pcm_digital_playback = {
3651 .substreams = 1,
3652 .channels_min = 2,
3653 .channels_max = 2,
3654 /* NID is set in alc_build_pcms */
3655 .ops = {
3656 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003657 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003658 .prepare = alc880_dig_playback_pcm_prepare,
3659 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003660 },
3661};
3662
3663static struct hda_pcm_stream alc880_pcm_digital_capture = {
3664 .substreams = 1,
3665 .channels_min = 2,
3666 .channels_max = 2,
3667 /* NID is set in alc_build_pcms */
3668};
3669
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003670/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003671static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003672 .substreams = 0,
3673 .channels_min = 0,
3674 .channels_max = 0,
3675};
3676
Linus Torvalds1da177e2005-04-16 15:20:36 -07003677static int alc_build_pcms(struct hda_codec *codec)
3678{
3679 struct alc_spec *spec = codec->spec;
3680 struct hda_pcm *info = spec->pcm_rec;
3681 int i;
3682
3683 codec->num_pcms = 1;
3684 codec->pcm_info = info;
3685
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003686 if (spec->no_analog)
3687 goto skip_analog;
3688
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003689 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3690 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003691 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003692
Takashi Iwai4a471b72005-12-07 13:56:29 +01003693 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003694 if (snd_BUG_ON(!spec->multiout.dac_nids))
3695 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003696 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3697 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3698 }
3699 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003700 if (snd_BUG_ON(!spec->adc_nids))
3701 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003702 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3703 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3704 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705
Takashi Iwai4a471b72005-12-07 13:56:29 +01003706 if (spec->channel_mode) {
3707 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3708 for (i = 0; i < spec->num_channel_mode; i++) {
3709 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3710 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3711 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003712 }
3713 }
3714
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003715 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003716 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003717 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003718 snprintf(spec->stream_name_digital,
3719 sizeof(spec->stream_name_digital),
3720 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003721 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003722 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003723 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003724 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003725 if (spec->dig_out_type)
3726 info->pcm_type = spec->dig_out_type;
3727 else
3728 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003729 if (spec->multiout.dig_out_nid &&
3730 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003731 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3732 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3733 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003734 if (spec->dig_in_nid &&
3735 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003736 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3737 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3738 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003739 /* FIXME: do we need this for all Realtek codec models? */
3740 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003741 }
3742
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003743 if (spec->no_analog)
3744 return 0;
3745
Takashi Iwaie08a0072006-09-07 17:52:14 +02003746 /* If the use of more than one ADC is requested for the current
3747 * model, configure a second analog capture-only PCM.
3748 */
3749 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003750 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3751 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003752 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003753 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003754 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003755 if (spec->alt_dac_nid) {
3756 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3757 *spec->stream_analog_alt_playback;
3758 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3759 spec->alt_dac_nid;
3760 } else {
3761 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3762 alc_pcm_null_stream;
3763 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3764 }
3765 if (spec->num_adc_nids > 1) {
3766 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3767 *spec->stream_analog_alt_capture;
3768 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3769 spec->adc_nids[1];
3770 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3771 spec->num_adc_nids - 1;
3772 } else {
3773 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3774 alc_pcm_null_stream;
3775 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003776 }
3777 }
3778
Linus Torvalds1da177e2005-04-16 15:20:36 -07003779 return 0;
3780}
3781
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003782static inline void alc_shutup(struct hda_codec *codec)
3783{
3784 snd_hda_shutup_pins(codec);
3785}
3786
Takashi Iwai603c4012008-07-30 15:01:44 +02003787static void alc_free_kctls(struct hda_codec *codec)
3788{
3789 struct alc_spec *spec = codec->spec;
3790
3791 if (spec->kctls.list) {
3792 struct snd_kcontrol_new *kctl = spec->kctls.list;
3793 int i;
3794 for (i = 0; i < spec->kctls.used; i++)
3795 kfree(kctl[i].name);
3796 }
3797 snd_array_free(&spec->kctls);
3798}
3799
Linus Torvalds1da177e2005-04-16 15:20:36 -07003800static void alc_free(struct hda_codec *codec)
3801{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003802 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003803
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003804 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003805 return;
3806
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003807 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003808 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003809 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003810 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003811}
3812
Hector Martinf5de24b2009-12-20 22:51:31 +01003813#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003814static void alc_power_eapd(struct hda_codec *codec)
3815{
3816 /* We currently only handle front, HP */
3817 switch (codec->vendor_id) {
3818 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003819 set_eapd(codec, 0x0f, 0);
3820 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003821 break;
3822 case 0x10ec0262:
3823 case 0x10ec0267:
3824 case 0x10ec0268:
3825 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003826 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003827 case 0x10ec0272:
3828 case 0x10ec0660:
3829 case 0x10ec0662:
3830 case 0x10ec0663:
3831 case 0x10ec0862:
3832 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003833 set_eapd(codec, 0x14, 0);
3834 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003835 break;
3836 }
3837}
3838
Hector Martinf5de24b2009-12-20 22:51:31 +01003839static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3840{
3841 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003842 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003843 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003844 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003845 return 0;
3846}
3847#endif
3848
Takashi Iwaie044c392008-10-27 16:56:24 +01003849#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003850static int alc_resume(struct hda_codec *codec)
3851{
Takashi Iwaie044c392008-10-27 16:56:24 +01003852 codec->patch_ops.init(codec);
3853 snd_hda_codec_resume_amp(codec);
3854 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02003855#ifdef CONFIG_SND_HDA_POWER_SAVE
3856 if (codec->patch_ops.check_power_status)
3857 codec->patch_ops.check_power_status(codec, 0x01);
3858#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003859 return 0;
3860}
Takashi Iwaie044c392008-10-27 16:56:24 +01003861#endif
3862
Linus Torvalds1da177e2005-04-16 15:20:36 -07003863/*
3864 */
3865static struct hda_codec_ops alc_patch_ops = {
3866 .build_controls = alc_build_controls,
3867 .build_pcms = alc_build_pcms,
3868 .init = alc_init,
3869 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003870 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003871#ifdef SND_HDA_NEEDS_RESUME
3872 .resume = alc_resume,
3873#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003874#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003875 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003876 .check_power_status = alc_check_power_status,
3877#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003878 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003879};
3880
Kailang Yangc027ddc2010-03-19 11:33:06 +01003881/* replace the codec chip_name with the given string */
3882static int alc_codec_rename(struct hda_codec *codec, const char *name)
3883{
3884 kfree(codec->chip_name);
3885 codec->chip_name = kstrdup(name, GFP_KERNEL);
3886 if (!codec->chip_name) {
3887 alc_free(codec);
3888 return -ENOMEM;
3889 }
3890 return 0;
3891}
3892
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003893/*
3894 * Test configuration for debugging
3895 *
3896 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3897 * enum controls.
3898 */
3899#ifdef CONFIG_SND_DEBUG
3900static hda_nid_t alc880_test_dac_nids[4] = {
3901 0x02, 0x03, 0x04, 0x05
3902};
3903
3904static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003905 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003906 .items = {
3907 { "In-1", 0x0 },
3908 { "In-2", 0x1 },
3909 { "In-3", 0x2 },
3910 { "In-4", 0x3 },
3911 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003912 { "Front", 0x5 },
3913 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003914 },
3915};
3916
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003917static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003918 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003919 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003920 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003921 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003922};
3923
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003924static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3925 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003926{
3927 static char *texts[] = {
3928 "N/A", "Line Out", "HP Out",
3929 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3930 };
3931 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3932 uinfo->count = 1;
3933 uinfo->value.enumerated.items = 8;
3934 if (uinfo->value.enumerated.item >= 8)
3935 uinfo->value.enumerated.item = 7;
3936 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3937 return 0;
3938}
3939
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003940static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3941 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003942{
3943 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3944 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3945 unsigned int pin_ctl, item = 0;
3946
3947 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3948 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3949 if (pin_ctl & AC_PINCTL_OUT_EN) {
3950 if (pin_ctl & AC_PINCTL_HP_EN)
3951 item = 2;
3952 else
3953 item = 1;
3954 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3955 switch (pin_ctl & AC_PINCTL_VREFEN) {
3956 case AC_PINCTL_VREF_HIZ: item = 3; break;
3957 case AC_PINCTL_VREF_50: item = 4; break;
3958 case AC_PINCTL_VREF_GRD: item = 5; break;
3959 case AC_PINCTL_VREF_80: item = 6; break;
3960 case AC_PINCTL_VREF_100: item = 7; break;
3961 }
3962 }
3963 ucontrol->value.enumerated.item[0] = item;
3964 return 0;
3965}
3966
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003967static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3968 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003969{
3970 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3971 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3972 static unsigned int ctls[] = {
3973 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3974 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3975 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3976 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3977 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3978 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3979 };
3980 unsigned int old_ctl, new_ctl;
3981
3982 old_ctl = snd_hda_codec_read(codec, nid, 0,
3983 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3984 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3985 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003986 int val;
3987 snd_hda_codec_write_cache(codec, nid, 0,
3988 AC_VERB_SET_PIN_WIDGET_CONTROL,
3989 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003990 val = ucontrol->value.enumerated.item[0] >= 3 ?
3991 HDA_AMP_MUTE : 0;
3992 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3993 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003994 return 1;
3995 }
3996 return 0;
3997}
3998
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003999static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4000 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004001{
4002 static char *texts[] = {
4003 "Front", "Surround", "CLFE", "Side"
4004 };
4005 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4006 uinfo->count = 1;
4007 uinfo->value.enumerated.items = 4;
4008 if (uinfo->value.enumerated.item >= 4)
4009 uinfo->value.enumerated.item = 3;
4010 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4011 return 0;
4012}
4013
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004014static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4015 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004016{
4017 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4018 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4019 unsigned int sel;
4020
4021 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4022 ucontrol->value.enumerated.item[0] = sel & 3;
4023 return 0;
4024}
4025
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004026static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4027 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004028{
4029 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4030 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4031 unsigned int sel;
4032
4033 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4034 if (ucontrol->value.enumerated.item[0] != sel) {
4035 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004036 snd_hda_codec_write_cache(codec, nid, 0,
4037 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004038 return 1;
4039 }
4040 return 0;
4041}
4042
4043#define PIN_CTL_TEST(xname,nid) { \
4044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4045 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004046 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004047 .info = alc_test_pin_ctl_info, \
4048 .get = alc_test_pin_ctl_get, \
4049 .put = alc_test_pin_ctl_put, \
4050 .private_value = nid \
4051 }
4052
4053#define PIN_SRC_TEST(xname,nid) { \
4054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4055 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004056 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004057 .info = alc_test_pin_src_info, \
4058 .get = alc_test_pin_src_get, \
4059 .put = alc_test_pin_src_put, \
4060 .private_value = nid \
4061 }
4062
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004063static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004064 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4065 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4066 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4067 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004068 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4069 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4070 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4071 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004072 PIN_CTL_TEST("Front Pin Mode", 0x14),
4073 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4074 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4075 PIN_CTL_TEST("Side Pin Mode", 0x17),
4076 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4077 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4078 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4079 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4080 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4081 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4082 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4083 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4084 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4085 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4086 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4087 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4088 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4089 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4090 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4091 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004094 {
4095 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4096 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004097 .info = alc_ch_mode_info,
4098 .get = alc_ch_mode_get,
4099 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004100 },
4101 { } /* end */
4102};
4103
4104static struct hda_verb alc880_test_init_verbs[] = {
4105 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4113 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004114 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4118 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004119 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004120 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4121 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4122 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4123 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004124 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4127 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4128 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004129 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004130 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004132 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4133 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4134 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004135 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004140 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004142 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004143 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004144 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004146 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004147 /* Analog input/passthru */
4148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004153 { }
4154};
4155#endif
4156
Linus Torvalds1da177e2005-04-16 15:20:36 -07004157/*
4158 */
4159
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004160static const char *alc880_models[ALC880_MODEL_LAST] = {
4161 [ALC880_3ST] = "3stack",
4162 [ALC880_TCL_S700] = "tcl",
4163 [ALC880_3ST_DIG] = "3stack-digout",
4164 [ALC880_CLEVO] = "clevo",
4165 [ALC880_5ST] = "5stack",
4166 [ALC880_5ST_DIG] = "5stack-digout",
4167 [ALC880_W810] = "w810",
4168 [ALC880_Z71V] = "z71v",
4169 [ALC880_6ST] = "6stack",
4170 [ALC880_6ST_DIG] = "6stack-digout",
4171 [ALC880_ASUS] = "asus",
4172 [ALC880_ASUS_W1V] = "asus-w1v",
4173 [ALC880_ASUS_DIG] = "asus-dig",
4174 [ALC880_ASUS_DIG2] = "asus-dig2",
4175 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004176 [ALC880_UNIWILL_P53] = "uniwill-p53",
4177 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004178 [ALC880_F1734] = "F1734",
4179 [ALC880_LG] = "lg",
4180 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004181 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004182#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004183 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004184#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004185 [ALC880_AUTO] = "auto",
4186};
4187
4188static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004189 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004190 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4191 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4192 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4193 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4194 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4195 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4196 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4197 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004198 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4199 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004200 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4201 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4202 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4203 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4204 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4205 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4206 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4207 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4208 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4209 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004210 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004211 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4212 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4213 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004214 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004215 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004216 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4217 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004218 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4219 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004220 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4221 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4222 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4223 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004224 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4225 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004226 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004227 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004228 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004229 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004230 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4231 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004232 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004233 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004234 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004235 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004236 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004237 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004238 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004239 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004240 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004241 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4242 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004243 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004244 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4245 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4246 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4247 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004248 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4249 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004250 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004251 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004252 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4253 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004254 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4255 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4256 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004257 /* default Intel */
4258 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004259 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4260 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004261 {}
4262};
4263
Takashi Iwai16ded522005-06-10 19:58:24 +02004264/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004265 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004266 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004267static struct alc_config_preset alc880_presets[] = {
4268 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004269 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004270 .init_verbs = { alc880_volume_init_verbs,
4271 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004272 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004273 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004274 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4275 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004276 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004277 .input_mux = &alc880_capture_source,
4278 },
4279 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004280 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004281 .init_verbs = { alc880_volume_init_verbs,
4282 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004283 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004284 .dac_nids = alc880_dac_nids,
4285 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004286 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4287 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004288 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004289 .input_mux = &alc880_capture_source,
4290 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004291 [ALC880_TCL_S700] = {
4292 .mixers = { alc880_tcl_s700_mixer },
4293 .init_verbs = { alc880_volume_init_verbs,
4294 alc880_pin_tcl_S700_init_verbs,
4295 alc880_gpio2_init_verbs },
4296 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4297 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004298 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4299 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004300 .hp_nid = 0x03,
4301 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4302 .channel_mode = alc880_2_jack_modes,
4303 .input_mux = &alc880_capture_source,
4304 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004305 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004306 .mixers = { alc880_three_stack_mixer,
4307 alc880_five_stack_mixer},
4308 .init_verbs = { alc880_volume_init_verbs,
4309 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004310 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4311 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004312 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4313 .channel_mode = alc880_fivestack_modes,
4314 .input_mux = &alc880_capture_source,
4315 },
4316 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004317 .mixers = { alc880_three_stack_mixer,
4318 alc880_five_stack_mixer },
4319 .init_verbs = { alc880_volume_init_verbs,
4320 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004321 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4322 .dac_nids = alc880_dac_nids,
4323 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004324 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4325 .channel_mode = alc880_fivestack_modes,
4326 .input_mux = &alc880_capture_source,
4327 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004328 [ALC880_6ST] = {
4329 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004330 .init_verbs = { alc880_volume_init_verbs,
4331 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004332 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4333 .dac_nids = alc880_6st_dac_nids,
4334 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4335 .channel_mode = alc880_sixstack_modes,
4336 .input_mux = &alc880_6stack_capture_source,
4337 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004338 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004339 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004340 .init_verbs = { alc880_volume_init_verbs,
4341 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004342 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4343 .dac_nids = alc880_6st_dac_nids,
4344 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004345 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4346 .channel_mode = alc880_sixstack_modes,
4347 .input_mux = &alc880_6stack_capture_source,
4348 },
4349 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004351 .init_verbs = { alc880_volume_init_verbs,
4352 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004353 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004354 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4355 .dac_nids = alc880_w810_dac_nids,
4356 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004357 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4358 .channel_mode = alc880_w810_modes,
4359 .input_mux = &alc880_capture_source,
4360 },
4361 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004362 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004363 .init_verbs = { alc880_volume_init_verbs,
4364 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004365 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4366 .dac_nids = alc880_z71v_dac_nids,
4367 .dig_out_nid = ALC880_DIGOUT_NID,
4368 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4370 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004371 .input_mux = &alc880_capture_source,
4372 },
4373 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004374 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004375 .init_verbs = { alc880_volume_init_verbs,
4376 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004377 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4378 .dac_nids = alc880_f1734_dac_nids,
4379 .hp_nid = 0x02,
4380 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4381 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004382 .input_mux = &alc880_f1734_capture_source,
4383 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004384 .setup = alc880_uniwill_p53_setup,
4385 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004386 },
4387 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004388 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004389 .init_verbs = { alc880_volume_init_verbs,
4390 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004391 alc880_gpio1_init_verbs },
4392 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4393 .dac_nids = alc880_asus_dac_nids,
4394 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4395 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004396 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004397 .input_mux = &alc880_capture_source,
4398 },
4399 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004401 .init_verbs = { alc880_volume_init_verbs,
4402 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004403 alc880_gpio1_init_verbs },
4404 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4405 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004406 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004407 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4408 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004409 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004410 .input_mux = &alc880_capture_source,
4411 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004412 [ALC880_ASUS_DIG2] = {
4413 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004414 .init_verbs = { alc880_volume_init_verbs,
4415 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004416 alc880_gpio2_init_verbs }, /* use GPIO2 */
4417 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4418 .dac_nids = alc880_asus_dac_nids,
4419 .dig_out_nid = ALC880_DIGOUT_NID,
4420 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4421 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004422 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004423 .input_mux = &alc880_capture_source,
4424 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004425 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004426 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004427 .init_verbs = { alc880_volume_init_verbs,
4428 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429 alc880_gpio1_init_verbs },
4430 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4431 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004432 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004433 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4434 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004435 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004436 .input_mux = &alc880_capture_source,
4437 },
4438 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004439 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004440 .init_verbs = { alc880_volume_init_verbs,
4441 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004442 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4443 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004444 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004445 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4446 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004447 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004448 .input_mux = &alc880_capture_source,
4449 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004450 [ALC880_UNIWILL] = {
4451 .mixers = { alc880_uniwill_mixer },
4452 .init_verbs = { alc880_volume_init_verbs,
4453 alc880_uniwill_init_verbs },
4454 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4455 .dac_nids = alc880_asus_dac_nids,
4456 .dig_out_nid = ALC880_DIGOUT_NID,
4457 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4458 .channel_mode = alc880_threestack_modes,
4459 .need_dac_fix = 1,
4460 .input_mux = &alc880_capture_source,
4461 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004462 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004463 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004464 },
4465 [ALC880_UNIWILL_P53] = {
4466 .mixers = { alc880_uniwill_p53_mixer },
4467 .init_verbs = { alc880_volume_init_verbs,
4468 alc880_uniwill_p53_init_verbs },
4469 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4470 .dac_nids = alc880_asus_dac_nids,
4471 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004472 .channel_mode = alc880_threestack_modes,
4473 .input_mux = &alc880_capture_source,
4474 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004475 .setup = alc880_uniwill_p53_setup,
4476 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004477 },
4478 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004479 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004480 .init_verbs = { alc880_volume_init_verbs,
4481 alc880_uniwill_p53_init_verbs,
4482 alc880_beep_init_verbs },
4483 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4484 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004485 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004486 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4487 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004488 .input_mux = &alc880_capture_source,
4489 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004490 .setup = alc880_uniwill_p53_setup,
4491 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004492 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004493 [ALC880_CLEVO] = {
4494 .mixers = { alc880_three_stack_mixer },
4495 .init_verbs = { alc880_volume_init_verbs,
4496 alc880_pin_clevo_init_verbs },
4497 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4498 .dac_nids = alc880_dac_nids,
4499 .hp_nid = 0x03,
4500 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4501 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004502 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004503 .input_mux = &alc880_capture_source,
4504 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004505 [ALC880_LG] = {
4506 .mixers = { alc880_lg_mixer },
4507 .init_verbs = { alc880_volume_init_verbs,
4508 alc880_lg_init_verbs },
4509 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4510 .dac_nids = alc880_lg_dac_nids,
4511 .dig_out_nid = ALC880_DIGOUT_NID,
4512 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4513 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004514 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004515 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004516 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004517 .setup = alc880_lg_setup,
4518 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004519#ifdef CONFIG_SND_HDA_POWER_SAVE
4520 .loopbacks = alc880_lg_loopbacks,
4521#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004522 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004523 [ALC880_LG_LW] = {
4524 .mixers = { alc880_lg_lw_mixer },
4525 .init_verbs = { alc880_volume_init_verbs,
4526 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004527 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004528 .dac_nids = alc880_dac_nids,
4529 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004530 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4531 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004532 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004533 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004534 .setup = alc880_lg_lw_setup,
4535 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004536 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004537 [ALC880_MEDION_RIM] = {
4538 .mixers = { alc880_medion_rim_mixer },
4539 .init_verbs = { alc880_volume_init_verbs,
4540 alc880_medion_rim_init_verbs,
4541 alc_gpio2_init_verbs },
4542 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4543 .dac_nids = alc880_dac_nids,
4544 .dig_out_nid = ALC880_DIGOUT_NID,
4545 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4546 .channel_mode = alc880_2_jack_modes,
4547 .input_mux = &alc880_medion_rim_capture_source,
4548 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004549 .setup = alc880_medion_rim_setup,
4550 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004551 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004552#ifdef CONFIG_SND_DEBUG
4553 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004554 .mixers = { alc880_test_mixer },
4555 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004556 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4557 .dac_nids = alc880_test_dac_nids,
4558 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004559 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4560 .channel_mode = alc880_test_modes,
4561 .input_mux = &alc880_test_capture_source,
4562 },
4563#endif
4564};
4565
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004566/*
4567 * Automatic parse of I/O pins from the BIOS configuration
4568 */
4569
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004570enum {
4571 ALC_CTL_WIDGET_VOL,
4572 ALC_CTL_WIDGET_MUTE,
4573 ALC_CTL_BIND_MUTE,
4574};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004575static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004576 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4577 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004578 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004579};
4580
4581/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004582static int add_control(struct alc_spec *spec, int type, const char *name,
4583 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004585 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004586
Takashi Iwai603c4012008-07-30 15:01:44 +02004587 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4588 knew = snd_array_new(&spec->kctls);
4589 if (!knew)
4590 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004591 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004592 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004593 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004594 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004595 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004596 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004597 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004598 return 0;
4599}
4600
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004601static int add_control_with_pfx(struct alc_spec *spec, int type,
4602 const char *pfx, const char *dir,
4603 const char *sfx, unsigned long val)
4604{
4605 char name[32];
4606 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4607 return add_control(spec, type, name, val);
4608}
4609
4610#define add_pb_vol_ctrl(spec, type, pfx, val) \
4611 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4612#define add_pb_sw_ctrl(spec, type, pfx, val) \
4613 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4614
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004615#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4616#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4617#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4618#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004619#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4620#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4621#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4622#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4623#define ALC880_PIN_CD_NID 0x1c
4624
4625/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004626static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4627 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004628{
4629 hda_nid_t nid;
4630 int assigned[4];
4631 int i, j;
4632
4633 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004634 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004635
4636 /* check the pins hardwired to audio widget */
4637 for (i = 0; i < cfg->line_outs; i++) {
4638 nid = cfg->line_out_pins[i];
4639 if (alc880_is_fixed_pin(nid)) {
4640 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004641 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642 assigned[idx] = 1;
4643 }
4644 }
4645 /* left pins can be connect to any audio widget */
4646 for (i = 0; i < cfg->line_outs; i++) {
4647 nid = cfg->line_out_pins[i];
4648 if (alc880_is_fixed_pin(nid))
4649 continue;
4650 /* search for an empty channel */
4651 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004652 if (!assigned[j]) {
4653 spec->multiout.dac_nids[i] =
4654 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004655 assigned[j] = 1;
4656 break;
4657 }
4658 }
4659 }
4660 spec->multiout.num_dacs = cfg->line_outs;
4661 return 0;
4662}
4663
4664/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004665static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4666 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004667{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004668 static const char *chname[4] = {
4669 "Front", "Surround", NULL /*CLFE*/, "Side"
4670 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004671 hda_nid_t nid;
4672 int i, err;
4673
4674 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004675 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004676 continue;
4677 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4678 if (i == 2) {
4679 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004680 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4681 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004682 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4683 HDA_OUTPUT));
4684 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004685 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004686 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4687 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004688 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4689 HDA_OUTPUT));
4690 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004691 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004692 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4693 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004694 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4695 HDA_INPUT));
4696 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004697 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004698 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4699 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004700 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4701 HDA_INPUT));
4702 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004703 return err;
4704 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004705 const char *pfx;
4706 if (cfg->line_outs == 1 &&
4707 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4708 pfx = "Speaker";
4709 else
4710 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004711 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004712 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4713 HDA_OUTPUT));
4714 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004716 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004717 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4718 HDA_INPUT));
4719 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004720 return err;
4721 }
4722 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004723 return 0;
4724}
4725
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004726/* add playback controls for speaker and HP outputs */
4727static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4728 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004729{
4730 hda_nid_t nid;
4731 int err;
4732
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004733 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004734 return 0;
4735
4736 if (alc880_is_fixed_pin(pin)) {
4737 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004738 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004739 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004740 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004741 else
4742 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004743 /* control HP volume/switch on the output mixer amp */
4744 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004745 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004746 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4747 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004748 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004749 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004750 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4751 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004752 return err;
4753 } else if (alc880_is_multi_pin(pin)) {
4754 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004755 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004756 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004757 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4758 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004759 return err;
4760 }
4761 return 0;
4762}
4763
4764/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004765static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4766 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004767 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004768{
Kailang Yangdf694da2005-12-05 19:42:22 +01004769 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004770
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004771 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, 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;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004775 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004776 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4777 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004778 return err;
4779 return 0;
4780}
4781
Takashi Iwai05f5f472009-08-25 13:10:18 +02004782static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004783{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004784 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4785 return (pincap & AC_PINCAP_IN) != 0;
4786}
4787
4788/* create playback/capture controls for input pins */
4789static int alc_auto_create_input_ctls(struct hda_codec *codec,
4790 const struct auto_pin_cfg *cfg,
4791 hda_nid_t mixer,
4792 hda_nid_t cap1, hda_nid_t cap2)
4793{
4794 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004795 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004796 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004797
4798 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004799 hda_nid_t pin;
4800
4801 pin = cfg->input_pins[i];
4802 if (!alc_is_input_pin(codec, pin))
4803 continue;
4804
4805 if (mixer) {
4806 idx = get_connection_index(codec, mixer, pin);
4807 if (idx >= 0) {
4808 err = new_analog_input(spec, pin,
4809 auto_pin_cfg_labels[i],
4810 idx, mixer);
4811 if (err < 0)
4812 return err;
4813 }
4814 }
4815
4816 if (!cap1)
4817 continue;
4818 idx = get_connection_index(codec, cap1, pin);
4819 if (idx < 0 && cap2)
4820 idx = get_connection_index(codec, cap2, pin);
4821 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004822 imux->items[imux->num_items].label =
4823 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004824 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004825 imux->num_items++;
4826 }
4827 }
4828 return 0;
4829}
4830
Takashi Iwai05f5f472009-08-25 13:10:18 +02004831static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4832 const struct auto_pin_cfg *cfg)
4833{
4834 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4835}
4836
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004837static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4838 unsigned int pin_type)
4839{
4840 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4841 pin_type);
4842 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004843 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4844 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004845}
4846
Kailang Yangdf694da2005-12-05 19:42:22 +01004847static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4848 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004849 int dac_idx)
4850{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004851 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004852 /* need the manual connection? */
4853 if (alc880_is_multi_pin(nid)) {
4854 struct alc_spec *spec = codec->spec;
4855 int idx = alc880_multi_pin_idx(nid);
4856 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4857 AC_VERB_SET_CONNECT_SEL,
4858 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4859 }
4860}
4861
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004862static int get_pin_type(int line_out_type)
4863{
4864 if (line_out_type == AUTO_PIN_HP_OUT)
4865 return PIN_HP;
4866 else
4867 return PIN_OUT;
4868}
4869
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004870static void alc880_auto_init_multi_out(struct hda_codec *codec)
4871{
4872 struct alc_spec *spec = codec->spec;
4873 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004874
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004875 for (i = 0; i < spec->autocfg.line_outs; i++) {
4876 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004877 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4878 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004879 }
4880}
4881
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004882static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004883{
4884 struct alc_spec *spec = codec->spec;
4885 hda_nid_t pin;
4886
Takashi Iwai82bc9552006-03-21 11:24:42 +01004887 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004888 if (pin) /* connect to front */
4889 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004890 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004891 if (pin) /* connect to front */
4892 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4893}
4894
4895static void alc880_auto_init_analog_input(struct hda_codec *codec)
4896{
4897 struct alc_spec *spec = codec->spec;
4898 int i;
4899
4900 for (i = 0; i < AUTO_PIN_LAST; i++) {
4901 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004902 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004903 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004904 if (nid != ALC880_PIN_CD_NID &&
4905 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004906 snd_hda_codec_write(codec, nid, 0,
4907 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004908 AMP_OUT_MUTE);
4909 }
4910 }
4911}
4912
Takashi Iwai7f311a42010-04-09 17:32:23 +02004913static void alc880_auto_init_input_src(struct hda_codec *codec)
4914{
4915 struct alc_spec *spec = codec->spec;
4916 int c;
4917
4918 for (c = 0; c < spec->num_adc_nids; c++) {
4919 unsigned int mux_idx;
4920 const struct hda_input_mux *imux;
4921 mux_idx = c >= spec->num_mux_defs ? 0 : c;
4922 imux = &spec->input_mux[mux_idx];
4923 if (!imux->num_items && mux_idx > 0)
4924 imux = &spec->input_mux[0];
4925 if (imux)
4926 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
4927 AC_VERB_SET_CONNECT_SEL,
4928 imux->items[0].index);
4929 }
4930}
4931
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004932/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004933/* return 1 if successful, 0 if the proper config is not found,
4934 * or a negative error code
4935 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004936static int alc880_parse_auto_config(struct hda_codec *codec)
4937{
4938 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004939 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004940 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004941
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004942 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4943 alc880_ignore);
4944 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004945 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004946 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004947 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004948
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004949 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4950 if (err < 0)
4951 return err;
4952 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4953 if (err < 0)
4954 return err;
4955 err = alc880_auto_create_extra_out(spec,
4956 spec->autocfg.speaker_pins[0],
4957 "Speaker");
4958 if (err < 0)
4959 return err;
4960 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4961 "Headphone");
4962 if (err < 0)
4963 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004964 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004965 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004966 return err;
4967
4968 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4969
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004970 /* check multiple SPDIF-out (for recent codecs) */
4971 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4972 hda_nid_t dig_nid;
4973 err = snd_hda_get_connections(codec,
4974 spec->autocfg.dig_out_pins[i],
4975 &dig_nid, 1);
4976 if (err < 0)
4977 continue;
4978 if (!i)
4979 spec->multiout.dig_out_nid = dig_nid;
4980 else {
4981 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004982 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004983 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004984 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004985 }
4986 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004987 if (spec->autocfg.dig_in_pin)
4988 spec->dig_in_nid = ALC880_DIGIN_NID;
4989
Takashi Iwai603c4012008-07-30 15:01:44 +02004990 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004991 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004992
Takashi Iwaid88897e2008-10-31 15:01:37 +01004993 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004994
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004995 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004996 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004997
Kailang Yang6227cdc2010-02-25 08:36:52 +01004998 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004999
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 return 1;
5001}
5002
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005003/* additional initialization for auto-configuration model */
5004static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005005{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005006 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005007 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005008 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005009 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005010 alc880_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005011 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005012 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005013}
5014
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005015/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5016 * one of two digital mic pins, e.g. on ALC272
5017 */
5018static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005019{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005020 struct alc_spec *spec = codec->spec;
5021 int i;
5022
5023 for (i = 0; i < spec->num_adc_nids; i++) {
5024 hda_nid_t cap = spec->capsrc_nids ?
5025 spec->capsrc_nids[i] : spec->adc_nids[i];
5026 int iidx, eidx;
5027
5028 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5029 if (iidx < 0)
5030 continue;
5031 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5032 if (eidx < 0)
5033 continue;
5034 spec->int_mic.mux_idx = iidx;
5035 spec->ext_mic.mux_idx = eidx;
5036 if (spec->capsrc_nids)
5037 spec->capsrc_nids += i;
5038 spec->adc_nids += i;
5039 spec->num_adc_nids = 1;
5040 return;
5041 }
5042 snd_printd(KERN_INFO "hda_codec: %s: "
5043 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5044 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5045 spec->auto_mic = 0; /* disable auto-mic to be sure */
5046}
5047
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005048/* choose the ADC/MUX containing the input pin and initialize the setup */
5049static void fixup_single_adc(struct hda_codec *codec)
5050{
5051 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01005052 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005053 int i;
5054
5055 /* search for the input pin; there must be only one */
5056 for (i = 0; i < AUTO_PIN_LAST; i++) {
5057 if (spec->autocfg.input_pins[i]) {
5058 pin = spec->autocfg.input_pins[i];
5059 break;
5060 }
5061 }
5062 if (!pin)
5063 return;
5064
5065 /* set the default connection to that pin */
5066 for (i = 0; i < spec->num_adc_nids; i++) {
5067 hda_nid_t cap = spec->capsrc_nids ?
5068 spec->capsrc_nids[i] : spec->adc_nids[i];
5069 int idx;
5070
5071 idx = get_connection_index(codec, cap, pin);
5072 if (idx < 0)
5073 continue;
5074 /* use only this ADC */
5075 if (spec->capsrc_nids)
5076 spec->capsrc_nids += i;
5077 spec->adc_nids += i;
5078 spec->num_adc_nids = 1;
5079 /* select or unmute this route */
5080 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5081 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5082 HDA_AMP_MUTE, 0);
5083 } else {
5084 snd_hda_codec_write_cache(codec, cap, 0,
5085 AC_VERB_SET_CONNECT_SEL, idx);
5086 }
5087 return;
5088 }
5089}
5090
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005091static void set_capture_mixer(struct hda_codec *codec)
5092{
5093 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005094 static struct snd_kcontrol_new *caps[2][3] = {
5095 { alc_capture_mixer_nosrc1,
5096 alc_capture_mixer_nosrc2,
5097 alc_capture_mixer_nosrc3 },
5098 { alc_capture_mixer1,
5099 alc_capture_mixer2,
5100 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005101 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005102 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005103 int mux = 0;
5104 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005105 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005106 else if (spec->input_mux) {
5107 if (spec->input_mux->num_items > 1)
5108 mux = 1;
5109 else if (spec->input_mux->num_items == 1)
5110 fixup_single_adc(codec);
5111 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01005112 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
5113 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005114}
5115
Takashi Iwai66946352010-03-29 17:21:45 +02005116/* fill adc_nids (and capsrc_nids) containing all active input pins */
5117static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5118 int num_nids)
5119{
5120 struct alc_spec *spec = codec->spec;
5121 int n;
5122 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5123
5124 for (n = 0; n < num_nids; n++) {
5125 hda_nid_t adc, cap;
5126 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5127 int nconns, i, j;
5128
5129 adc = nids[n];
5130 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5131 continue;
5132 cap = adc;
5133 nconns = snd_hda_get_connections(codec, cap, conn,
5134 ARRAY_SIZE(conn));
5135 if (nconns == 1) {
5136 cap = conn[0];
5137 nconns = snd_hda_get_connections(codec, cap, conn,
5138 ARRAY_SIZE(conn));
5139 }
5140 if (nconns <= 0)
5141 continue;
5142 if (!fallback_adc) {
5143 fallback_adc = adc;
5144 fallback_cap = cap;
5145 }
5146 for (i = 0; i < AUTO_PIN_LAST; i++) {
5147 hda_nid_t nid = spec->autocfg.input_pins[i];
5148 if (!nid)
5149 continue;
5150 for (j = 0; j < nconns; j++) {
5151 if (conn[j] == nid)
5152 break;
5153 }
5154 if (j >= nconns)
5155 break;
5156 }
5157 if (i >= AUTO_PIN_LAST) {
5158 int num_adcs = spec->num_adc_nids;
5159 spec->private_adc_nids[num_adcs] = adc;
5160 spec->private_capsrc_nids[num_adcs] = cap;
5161 spec->num_adc_nids++;
5162 spec->adc_nids = spec->private_adc_nids;
5163 if (adc != cap)
5164 spec->capsrc_nids = spec->private_capsrc_nids;
5165 }
5166 }
5167 if (!spec->num_adc_nids) {
5168 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005169 " using fallback 0x%x\n",
5170 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005171 spec->private_adc_nids[0] = fallback_adc;
5172 spec->adc_nids = spec->private_adc_nids;
5173 if (fallback_adc != fallback_cap) {
5174 spec->private_capsrc_nids[0] = fallback_cap;
5175 spec->capsrc_nids = spec->private_adc_nids;
5176 }
5177 }
5178}
5179
Takashi Iwai67d634c2009-11-16 15:35:59 +01005180#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005181#define set_beep_amp(spec, nid, idx, dir) \
5182 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005183
5184static struct snd_pci_quirk beep_white_list[] = {
5185 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
5186 {}
5187};
5188
5189static inline int has_cdefine_beep(struct hda_codec *codec)
5190{
5191 struct alc_spec *spec = codec->spec;
5192 const struct snd_pci_quirk *q;
5193 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5194 if (q)
5195 return q->value;
5196 return spec->cdefine.enable_pcbeep;
5197}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005198#else
5199#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005200#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005201#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005202
5203/*
5204 * OK, here we have finally the patch for ALC880
5205 */
5206
Linus Torvalds1da177e2005-04-16 15:20:36 -07005207static int patch_alc880(struct hda_codec *codec)
5208{
5209 struct alc_spec *spec;
5210 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005211 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005212
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005213 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005214 if (spec == NULL)
5215 return -ENOMEM;
5216
5217 codec->spec = spec;
5218
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005219 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5220 alc880_models,
5221 alc880_cfg_tbl);
5222 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005223 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5224 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005225 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005226 }
5227
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005228 if (board_config == ALC880_AUTO) {
5229 /* automatic parse from the BIOS config */
5230 err = alc880_parse_auto_config(codec);
5231 if (err < 0) {
5232 alc_free(codec);
5233 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005234 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005235 printk(KERN_INFO
5236 "hda_codec: Cannot set up configuration "
5237 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005238 board_config = ALC880_3ST;
5239 }
5240 }
5241
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005242 err = snd_hda_attach_beep_device(codec, 0x1);
5243 if (err < 0) {
5244 alc_free(codec);
5245 return err;
5246 }
5247
Kailang Yangdf694da2005-12-05 19:42:22 +01005248 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005249 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005250
Linus Torvalds1da177e2005-04-16 15:20:36 -07005251 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5252 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005253 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005254
Linus Torvalds1da177e2005-04-16 15:20:36 -07005255 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5256 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5257
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005258 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005259 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005260 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005261 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005262 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005263 if (wcap != AC_WID_AUD_IN) {
5264 spec->adc_nids = alc880_adc_nids_alt;
5265 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005266 } else {
5267 spec->adc_nids = alc880_adc_nids;
5268 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005269 }
5270 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005271 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005272 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005273
Takashi Iwai2134ea42008-01-10 16:53:55 +01005274 spec->vmaster_nid = 0x0c;
5275
Linus Torvalds1da177e2005-04-16 15:20:36 -07005276 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005277 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005278 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005279#ifdef CONFIG_SND_HDA_POWER_SAVE
5280 if (!spec->loopback.amplist)
5281 spec->loopback.amplist = alc880_loopbacks;
5282#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005283
5284 return 0;
5285}
5286
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005287
Linus Torvalds1da177e2005-04-16 15:20:36 -07005288/*
5289 * ALC260 support
5290 */
5291
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005292static hda_nid_t alc260_dac_nids[1] = {
5293 /* front */
5294 0x02,
5295};
5296
5297static hda_nid_t alc260_adc_nids[1] = {
5298 /* ADC0 */
5299 0x04,
5300};
5301
Kailang Yangdf694da2005-12-05 19:42:22 +01005302static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005303 /* ADC1 */
5304 0x05,
5305};
5306
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005307/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5308 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5309 */
5310static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005311 /* ADC0, ADC1 */
5312 0x04, 0x05
5313};
5314
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005315#define ALC260_DIGOUT_NID 0x03
5316#define ALC260_DIGIN_NID 0x06
5317
5318static struct hda_input_mux alc260_capture_source = {
5319 .num_items = 4,
5320 .items = {
5321 { "Mic", 0x0 },
5322 { "Front Mic", 0x1 },
5323 { "Line", 0x2 },
5324 { "CD", 0x4 },
5325 },
5326};
5327
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005328/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005329 * headphone jack and the internal CD lines since these are the only pins at
5330 * which audio can appear. For flexibility, also allow the option of
5331 * recording the mixer output on the second ADC (ADC0 doesn't have a
5332 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005333 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005334static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5335 {
5336 .num_items = 3,
5337 .items = {
5338 { "Mic/Line", 0x0 },
5339 { "CD", 0x4 },
5340 { "Headphone", 0x2 },
5341 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005342 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005343 {
5344 .num_items = 4,
5345 .items = {
5346 { "Mic/Line", 0x0 },
5347 { "CD", 0x4 },
5348 { "Headphone", 0x2 },
5349 { "Mixer", 0x5 },
5350 },
5351 },
5352
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005353};
5354
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005355/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5356 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005357 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005358static struct hda_input_mux alc260_acer_capture_sources[2] = {
5359 {
5360 .num_items = 4,
5361 .items = {
5362 { "Mic", 0x0 },
5363 { "Line", 0x2 },
5364 { "CD", 0x4 },
5365 { "Headphone", 0x5 },
5366 },
5367 },
5368 {
5369 .num_items = 5,
5370 .items = {
5371 { "Mic", 0x0 },
5372 { "Line", 0x2 },
5373 { "CD", 0x4 },
5374 { "Headphone", 0x6 },
5375 { "Mixer", 0x5 },
5376 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005377 },
5378};
Michael Schwingencc959482009-02-22 18:58:45 +01005379
5380/* Maxdata Favorit 100XS */
5381static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5382 {
5383 .num_items = 2,
5384 .items = {
5385 { "Line/Mic", 0x0 },
5386 { "CD", 0x4 },
5387 },
5388 },
5389 {
5390 .num_items = 3,
5391 .items = {
5392 { "Line/Mic", 0x0 },
5393 { "CD", 0x4 },
5394 { "Mixer", 0x5 },
5395 },
5396 },
5397};
5398
Linus Torvalds1da177e2005-04-16 15:20:36 -07005399/*
5400 * This is just place-holder, so there's something for alc_build_pcms to look
5401 * at when it calculates the maximum number of channels. ALC260 has no mixer
5402 * element which allows changing the channel mode, so the verb list is
5403 * never used.
5404 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005405static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005406 { 2, NULL },
5407};
5408
Kailang Yangdf694da2005-12-05 19:42:22 +01005409
5410/* Mixer combinations
5411 *
5412 * basic: base_output + input + pc_beep + capture
5413 * HP: base_output + input + capture_alt
5414 * HP_3013: hp_3013 + input + capture
5415 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005416 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005417 */
5418
5419static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005420 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005421 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005422 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5423 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5424 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5425 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5426 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005427};
Kailang Yangdf694da2005-12-05 19:42:22 +01005428
5429static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005430 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5431 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5432 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5433 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5434 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5435 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5436 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5437 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005438 { } /* end */
5439};
5440
Takashi Iwaibec15c32008-01-28 18:16:30 +01005441/* update HP, line and mono out pins according to the master switch */
5442static void alc260_hp_master_update(struct hda_codec *codec,
5443 hda_nid_t hp, hda_nid_t line,
5444 hda_nid_t mono)
5445{
5446 struct alc_spec *spec = codec->spec;
5447 unsigned int val = spec->master_sw ? PIN_HP : 0;
5448 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005449 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005450 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005451 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005452 val);
5453 /* mono (speaker) depending on the HP jack sense */
5454 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005455 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005456 val);
5457}
5458
5459static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5460 struct snd_ctl_elem_value *ucontrol)
5461{
5462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5463 struct alc_spec *spec = codec->spec;
5464 *ucontrol->value.integer.value = spec->master_sw;
5465 return 0;
5466}
5467
5468static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5469 struct snd_ctl_elem_value *ucontrol)
5470{
5471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5472 struct alc_spec *spec = codec->spec;
5473 int val = !!*ucontrol->value.integer.value;
5474 hda_nid_t hp, line, mono;
5475
5476 if (val == spec->master_sw)
5477 return 0;
5478 spec->master_sw = val;
5479 hp = (kcontrol->private_value >> 16) & 0xff;
5480 line = (kcontrol->private_value >> 8) & 0xff;
5481 mono = kcontrol->private_value & 0xff;
5482 alc260_hp_master_update(codec, hp, line, mono);
5483 return 1;
5484}
5485
5486static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5487 {
5488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5489 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005490 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005491 .info = snd_ctl_boolean_mono_info,
5492 .get = alc260_hp_master_sw_get,
5493 .put = alc260_hp_master_sw_put,
5494 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5495 },
5496 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5497 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5498 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5499 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5500 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5501 HDA_OUTPUT),
5502 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5503 { } /* end */
5504};
5505
5506static struct hda_verb alc260_hp_unsol_verbs[] = {
5507 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5508 {},
5509};
5510
5511static void alc260_hp_automute(struct hda_codec *codec)
5512{
5513 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005514
Wu Fengguang864f92b2009-11-18 12:38:02 +08005515 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005516 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5517}
5518
5519static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5520{
5521 if ((res >> 26) == ALC880_HP_EVENT)
5522 alc260_hp_automute(codec);
5523}
5524
Kailang Yangdf694da2005-12-05 19:42:22 +01005525static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005526 {
5527 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5528 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005529 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005530 .info = snd_ctl_boolean_mono_info,
5531 .get = alc260_hp_master_sw_get,
5532 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005533 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005534 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005535 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5536 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5537 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5538 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5539 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5540 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005541 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5542 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005543 { } /* end */
5544};
5545
Kailang Yang3f878302008-08-26 13:02:23 +02005546static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5547 .ops = &snd_hda_bind_vol,
5548 .values = {
5549 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5550 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5551 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5552 0
5553 },
5554};
5555
5556static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5557 .ops = &snd_hda_bind_sw,
5558 .values = {
5559 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5560 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5561 0
5562 },
5563};
5564
5565static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5566 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5567 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5568 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5569 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5570 { } /* end */
5571};
5572
Takashi Iwaibec15c32008-01-28 18:16:30 +01005573static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5574 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5575 {},
5576};
5577
5578static void alc260_hp_3013_automute(struct hda_codec *codec)
5579{
5580 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005581
Wu Fengguang864f92b2009-11-18 12:38:02 +08005582 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005583 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005584}
5585
5586static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5587 unsigned int res)
5588{
5589 if ((res >> 26) == ALC880_HP_EVENT)
5590 alc260_hp_3013_automute(codec);
5591}
5592
Kailang Yang3f878302008-08-26 13:02:23 +02005593static void alc260_hp_3012_automute(struct hda_codec *codec)
5594{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005595 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005596
Kailang Yang3f878302008-08-26 13:02:23 +02005597 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5598 bits);
5599 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5600 bits);
5601 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5602 bits);
5603}
5604
5605static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5606 unsigned int res)
5607{
5608 if ((res >> 26) == ALC880_HP_EVENT)
5609 alc260_hp_3012_automute(codec);
5610}
5611
5612/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005613 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5614 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01005615static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005616 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005617 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005618 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005619 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5620 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5621 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5622 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005623 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005624 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5625 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005626 { } /* end */
5627};
5628
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005629/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5630 * versions of the ALC260 don't act on requests to enable mic bias from NID
5631 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5632 * datasheet doesn't mention this restriction. At this stage it's not clear
5633 * whether this behaviour is intentional or is a hardware bug in chip
5634 * revisions available in early 2006. Therefore for now allow the
5635 * "Headphone Jack Mode" control to span all choices, but if it turns out
5636 * that the lack of mic bias for this NID is intentional we could change the
5637 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5638 *
5639 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5640 * don't appear to make the mic bias available from the "line" jack, even
5641 * though the NID used for this jack (0x14) can supply it. The theory is
5642 * that perhaps Acer have included blocking capacitors between the ALC260
5643 * and the output jack. If this turns out to be the case for all such
5644 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5645 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005646 *
5647 * The C20x Tablet series have a mono internal speaker which is controlled
5648 * via the chip's Mono sum widget and pin complex, so include the necessary
5649 * controls for such models. On models without a "mono speaker" the control
5650 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005651 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005652static struct snd_kcontrol_new alc260_acer_mixer[] = {
5653 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5654 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005655 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005656 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005657 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005658 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005659 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005660 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5661 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5662 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5663 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5664 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5665 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5666 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5667 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005668 { } /* end */
5669};
5670
Michael Schwingencc959482009-02-22 18:58:45 +01005671/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5672 */
5673static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5674 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5675 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5676 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5677 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5678 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5679 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5680 { } /* end */
5681};
5682
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005683/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5684 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5685 */
5686static struct snd_kcontrol_new alc260_will_mixer[] = {
5687 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5688 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5689 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5690 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5691 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5692 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5693 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5694 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5695 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5696 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005697 { } /* end */
5698};
5699
5700/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5701 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5702 */
5703static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5704 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5705 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5707 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5708 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5709 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5710 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5711 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5712 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5713 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5714 { } /* end */
5715};
5716
Kailang Yangdf694da2005-12-05 19:42:22 +01005717/*
5718 * initialization verbs
5719 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005720static struct hda_verb alc260_init_verbs[] = {
5721 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005723 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005724 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005725 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005726 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005727 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005728 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005729 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005731 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005732 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005733 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005734 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005735 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005736 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005737 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005738 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5739 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005740 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005741 /* set connection select to line in (default select for this ADC) */
5742 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005743 /* mute capture amp left and right */
5744 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5745 /* set connection select to line in (default select for this ADC) */
5746 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005747 /* set vol=0 Line-Out mixer amp left and right */
5748 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5749 /* unmute pin widget amp left and right (no gain on this amp) */
5750 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5751 /* set vol=0 HP mixer amp left and right */
5752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5753 /* unmute pin widget amp left and right (no gain on this amp) */
5754 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5755 /* set vol=0 Mono mixer amp left and right */
5756 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5757 /* unmute pin widget amp left and right (no gain on this amp) */
5758 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5759 /* unmute LINE-2 out pin */
5760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005761 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5762 * Line In 2 = 0x03
5763 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005764 /* mute analog inputs */
5765 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5766 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5767 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5768 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5769 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005770 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005771 /* mute Front out path */
5772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5773 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5774 /* mute Headphone out path */
5775 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5776 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5777 /* mute Mono out path */
5778 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5779 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005780 { }
5781};
5782
Takashi Iwai474167d2006-05-17 17:17:43 +02005783#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005784static struct hda_verb alc260_hp_init_verbs[] = {
5785 /* Headphone and output */
5786 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5787 /* mono output */
5788 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5789 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5790 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5791 /* Mic2 (front panel) pin widget for input and vref at 80% */
5792 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5793 /* Line In pin widget for input */
5794 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5795 /* Line-2 pin widget for output */
5796 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5797 /* CD pin widget for input */
5798 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5799 /* unmute amp left and right */
5800 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5801 /* set connection select to line in (default select for this ADC) */
5802 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5803 /* unmute Line-Out mixer amp left and right (volume = 0) */
5804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5805 /* mute pin widget amp left and right (no gain on this amp) */
5806 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5807 /* unmute HP mixer amp left and right (volume = 0) */
5808 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5809 /* mute pin widget amp left and right (no gain on this amp) */
5810 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005811 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5812 * Line In 2 = 0x03
5813 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005814 /* mute analog inputs */
5815 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5816 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5817 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005820 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5821 /* Unmute Front out path */
5822 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5823 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5824 /* Unmute Headphone out path */
5825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5826 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5827 /* Unmute Mono out path */
5828 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5829 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5830 { }
5831};
Takashi Iwai474167d2006-05-17 17:17:43 +02005832#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005833
5834static struct hda_verb alc260_hp_3013_init_verbs[] = {
5835 /* Line out and output */
5836 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5837 /* mono output */
5838 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5839 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5840 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5841 /* Mic2 (front panel) pin widget for input and vref at 80% */
5842 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5843 /* Line In pin widget for input */
5844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5845 /* Headphone pin widget for output */
5846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5847 /* CD pin widget for input */
5848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5849 /* unmute amp left and right */
5850 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5851 /* set connection select to line in (default select for this ADC) */
5852 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5853 /* unmute Line-Out mixer amp left and right (volume = 0) */
5854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5855 /* mute pin widget amp left and right (no gain on this amp) */
5856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5857 /* unmute HP mixer amp left and right (volume = 0) */
5858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5859 /* mute pin widget amp left and right (no gain on this amp) */
5860 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005861 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5862 * Line In 2 = 0x03
5863 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005864 /* mute analog inputs */
5865 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5866 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5867 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5868 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5869 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005870 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5871 /* Unmute Front out path */
5872 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5873 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5874 /* Unmute Headphone out path */
5875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5876 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5877 /* Unmute Mono out path */
5878 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5879 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5880 { }
5881};
5882
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005883/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005884 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5885 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005886 */
5887static struct hda_verb alc260_fujitsu_init_verbs[] = {
5888 /* Disable all GPIOs */
5889 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5890 /* Internal speaker is connected to headphone pin */
5891 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5892 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5893 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005894 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5895 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5896 /* Ensure all other unused pins are disabled and muted. */
5897 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5898 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005899 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005900 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005901 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005902 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5903 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5904 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005905
Jonathan Woithef7ace402006-02-28 11:46:14 +01005906 /* Disable digital (SPDIF) pins */
5907 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5908 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005909
Kailang Yangea1fb292008-08-26 12:58:38 +02005910 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005911 * when acting as an output.
5912 */
5913 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5914
5915 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5917 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5918 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5919 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5920 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5921 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5922 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5923 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5924 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005925
Jonathan Woithef7ace402006-02-28 11:46:14 +01005926 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5927 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5928 /* Unmute Line1 pin widget output buffer since it starts as an output.
5929 * If the pin mode is changed by the user the pin mode control will
5930 * take care of enabling the pin's input/output buffers as needed.
5931 * Therefore there's no need to enable the input buffer at this
5932 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005933 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005934 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005935 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005936 * mixer ctrl)
5937 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005938 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005939
Jonathan Woithef7ace402006-02-28 11:46:14 +01005940 /* Mute capture amp left and right */
5941 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005942 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005943 * in (on mic1 pin)
5944 */
5945 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005946
Jonathan Woithef7ace402006-02-28 11:46:14 +01005947 /* Do the same for the second ADC: mute capture input amp and
5948 * set ADC connection to line in (on mic1 pin)
5949 */
5950 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5951 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005952
Jonathan Woithef7ace402006-02-28 11:46:14 +01005953 /* Mute all inputs to mixer widget (even unconnected ones) */
5954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5955 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5958 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5959 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5960 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005962
5963 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005964};
5965
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005966/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5967 * similar laptops (adapted from Fujitsu init verbs).
5968 */
5969static struct hda_verb alc260_acer_init_verbs[] = {
5970 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5971 * the headphone jack. Turn this on and rely on the standard mute
5972 * methods whenever the user wants to turn these outputs off.
5973 */
5974 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5975 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5976 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5977 /* Internal speaker/Headphone jack is connected to Line-out pin */
5978 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5979 /* Internal microphone/Mic jack is connected to Mic1 pin */
5980 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5981 /* Line In jack is connected to Line1 pin */
5982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005983 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5984 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005985 /* Ensure all other unused pins are disabled and muted. */
5986 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5987 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005988 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5989 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5990 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5991 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5992 /* Disable digital (SPDIF) pins */
5993 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5994 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5995
Kailang Yangea1fb292008-08-26 12:58:38 +02005996 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005997 * bus when acting as outputs.
5998 */
5999 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6000 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6001
6002 /* Start with output sum widgets muted and their output gains at min */
6003 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6004 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6005 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6006 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6007 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6008 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6009 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6010 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6011 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6012
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006013 /* Unmute Line-out pin widget amp left and right
6014 * (no equiv mixer ctrl)
6015 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006016 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006017 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6018 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006019 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6020 * inputs. If the pin mode is changed by the user the pin mode control
6021 * will take care of enabling the pin's input/output buffers as needed.
6022 * Therefore there's no need to enable the input buffer at this
6023 * stage.
6024 */
6025 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6026 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6027
6028 /* Mute capture amp left and right */
6029 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6030 /* Set ADC connection select to match default mixer setting - mic
6031 * (on mic1 pin)
6032 */
6033 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6034
6035 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006036 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006037 */
6038 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006039 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006040
6041 /* Mute all inputs to mixer widget (even unconnected ones) */
6042 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6043 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6044 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6046 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6047 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6048 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6049 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6050
6051 { }
6052};
6053
Michael Schwingencc959482009-02-22 18:58:45 +01006054/* Initialisation sequence for Maxdata Favorit 100XS
6055 * (adapted from Acer init verbs).
6056 */
6057static struct hda_verb alc260_favorit100_init_verbs[] = {
6058 /* GPIO 0 enables the output jack.
6059 * Turn this on and rely on the standard mute
6060 * methods whenever the user wants to turn these outputs off.
6061 */
6062 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6063 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6064 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6065 /* Line/Mic input jack is connected to Mic1 pin */
6066 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6067 /* Ensure all other unused pins are disabled and muted. */
6068 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6069 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6070 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6071 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6072 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6073 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6074 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6075 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6078 /* Disable digital (SPDIF) pins */
6079 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6080 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6081
6082 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6083 * bus when acting as outputs.
6084 */
6085 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6086 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6087
6088 /* Start with output sum widgets muted and their output gains at min */
6089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6090 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6091 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6093 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6094 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6095 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6096 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6097 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6098
6099 /* Unmute Line-out pin widget amp left and right
6100 * (no equiv mixer ctrl)
6101 */
6102 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6103 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6104 * inputs. If the pin mode is changed by the user the pin mode control
6105 * will take care of enabling the pin's input/output buffers as needed.
6106 * Therefore there's no need to enable the input buffer at this
6107 * stage.
6108 */
6109 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6110
6111 /* Mute capture amp left and right */
6112 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6113 /* Set ADC connection select to match default mixer setting - mic
6114 * (on mic1 pin)
6115 */
6116 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6117
6118 /* Do similar with the second ADC: mute capture input amp and
6119 * set ADC connection to mic to match ALSA's default state.
6120 */
6121 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6122 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6123
6124 /* Mute all inputs to mixer widget (even unconnected ones) */
6125 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6127 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6133
6134 { }
6135};
6136
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006137static struct hda_verb alc260_will_verbs[] = {
6138 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6139 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6140 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6141 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6142 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6143 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6144 {}
6145};
6146
6147static struct hda_verb alc260_replacer_672v_verbs[] = {
6148 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6149 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6150 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6151
6152 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6153 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6154 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6155
6156 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6157 {}
6158};
6159
6160/* toggle speaker-output according to the hp-jack state */
6161static void alc260_replacer_672v_automute(struct hda_codec *codec)
6162{
6163 unsigned int present;
6164
6165 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006166 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006167 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006168 snd_hda_codec_write_cache(codec, 0x01, 0,
6169 AC_VERB_SET_GPIO_DATA, 1);
6170 snd_hda_codec_write_cache(codec, 0x0f, 0,
6171 AC_VERB_SET_PIN_WIDGET_CONTROL,
6172 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006173 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006174 snd_hda_codec_write_cache(codec, 0x01, 0,
6175 AC_VERB_SET_GPIO_DATA, 0);
6176 snd_hda_codec_write_cache(codec, 0x0f, 0,
6177 AC_VERB_SET_PIN_WIDGET_CONTROL,
6178 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006179 }
6180}
6181
6182static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6183 unsigned int res)
6184{
6185 if ((res >> 26) == ALC880_HP_EVENT)
6186 alc260_replacer_672v_automute(codec);
6187}
6188
Kailang Yang3f878302008-08-26 13:02:23 +02006189static struct hda_verb alc260_hp_dc7600_verbs[] = {
6190 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6191 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6192 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6193 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6194 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6196 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6197 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6198 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6199 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6200 {}
6201};
6202
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006203/* Test configuration for debugging, modelled after the ALC880 test
6204 * configuration.
6205 */
6206#ifdef CONFIG_SND_DEBUG
6207static hda_nid_t alc260_test_dac_nids[1] = {
6208 0x02,
6209};
6210static hda_nid_t alc260_test_adc_nids[2] = {
6211 0x04, 0x05,
6212};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006213/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006214 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006215 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006216 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006217static struct hda_input_mux alc260_test_capture_sources[2] = {
6218 {
6219 .num_items = 7,
6220 .items = {
6221 { "MIC1 pin", 0x0 },
6222 { "MIC2 pin", 0x1 },
6223 { "LINE1 pin", 0x2 },
6224 { "LINE2 pin", 0x3 },
6225 { "CD pin", 0x4 },
6226 { "LINE-OUT pin", 0x5 },
6227 { "HP-OUT pin", 0x6 },
6228 },
6229 },
6230 {
6231 .num_items = 8,
6232 .items = {
6233 { "MIC1 pin", 0x0 },
6234 { "MIC2 pin", 0x1 },
6235 { "LINE1 pin", 0x2 },
6236 { "LINE2 pin", 0x3 },
6237 { "CD pin", 0x4 },
6238 { "Mixer", 0x5 },
6239 { "LINE-OUT pin", 0x6 },
6240 { "HP-OUT pin", 0x7 },
6241 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006242 },
6243};
6244static struct snd_kcontrol_new alc260_test_mixer[] = {
6245 /* Output driver widgets */
6246 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6247 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6248 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6249 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6250 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6251 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6252
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006253 /* Modes for retasking pin widgets
6254 * Note: the ALC260 doesn't seem to act on requests to enable mic
6255 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6256 * mention this restriction. At this stage it's not clear whether
6257 * this behaviour is intentional or is a hardware bug in chip
6258 * revisions available at least up until early 2006. Therefore for
6259 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6260 * choices, but if it turns out that the lack of mic bias for these
6261 * NIDs is intentional we could change their modes from
6262 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6263 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006264 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6265 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6266 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6267 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6268 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6269 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6270
6271 /* Loopback mixer controls */
6272 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6273 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6274 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6275 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6276 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6277 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6278 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6279 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6280 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6281 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006282 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6283 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6284 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6285 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006286
6287 /* Controls for GPIO pins, assuming they are configured as outputs */
6288 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6289 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6290 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6291 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6292
Jonathan Woithe92621f12006-02-28 11:47:47 +01006293 /* Switches to allow the digital IO pins to be enabled. The datasheet
6294 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006295 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006296 */
6297 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6298 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6299
Jonathan Woithef8225f62008-01-08 12:16:54 +01006300 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6301 * this output to turn on an external amplifier.
6302 */
6303 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6304 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6305
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006306 { } /* end */
6307};
6308static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006309 /* Enable all GPIOs as outputs with an initial value of 0 */
6310 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6311 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6312 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6313
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006314 /* Enable retasking pins as output, initially without power amp */
6315 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6316 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6319 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6320 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6321
Jonathan Woithe92621f12006-02-28 11:47:47 +01006322 /* Disable digital (SPDIF) pins initially, but users can enable
6323 * them via a mixer switch. In the case of SPDIF-out, this initverb
6324 * payload also sets the generation to 0, output to be in "consumer"
6325 * PCM format, copyright asserted, no pre-emphasis and no validity
6326 * control.
6327 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006328 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6329 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6330
Kailang Yangea1fb292008-08-26 12:58:38 +02006331 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006332 * OUT1 sum bus when acting as an output.
6333 */
6334 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6335 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6336 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6337 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6338
6339 /* Start with output sum widgets muted and their output gains at min */
6340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6341 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6342 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6344 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6345 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6347 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6348 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6349
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006350 /* Unmute retasking pin widget output buffers since the default
6351 * state appears to be output. As the pin mode is changed by the
6352 * user the pin mode control will take care of enabling the pin's
6353 * input/output buffers as needed.
6354 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006355 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6356 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6357 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6358 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6359 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6360 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6361 /* Also unmute the mono-out pin widget */
6362 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6363
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006364 /* Mute capture amp left and right */
6365 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006366 /* Set ADC connection select to match default mixer setting (mic1
6367 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006368 */
6369 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6370
6371 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006372 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006373 */
6374 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6375 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6376
6377 /* Mute all inputs to mixer widget (even unconnected ones) */
6378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6386
6387 { }
6388};
6389#endif
6390
Takashi Iwai63300792008-01-24 15:31:36 +01006391#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6392#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006393
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006394#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6395#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6396
Kailang Yangdf694da2005-12-05 19:42:22 +01006397/*
6398 * for BIOS auto-configuration
6399 */
6400
6401static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006402 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006403{
6404 hda_nid_t nid_vol;
6405 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006406 int err;
6407
6408 if (nid >= 0x0f && nid < 0x11) {
6409 nid_vol = nid - 0x7;
6410 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6411 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6412 } else if (nid == 0x11) {
6413 nid_vol = nid - 0x7;
6414 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6415 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6416 } else if (nid >= 0x12 && nid <= 0x15) {
6417 nid_vol = 0x08;
6418 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6419 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6420 } else
6421 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006422
Takashi Iwai863b4512008-10-21 17:01:47 +02006423 if (!(*vol_bits & (1 << nid_vol))) {
6424 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006425 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006426 if (err < 0)
6427 return err;
6428 *vol_bits |= (1 << nid_vol);
6429 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006430 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006431 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006432 return err;
6433 return 1;
6434}
6435
6436/* add playback controls from the parsed DAC table */
6437static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6438 const struct auto_pin_cfg *cfg)
6439{
6440 hda_nid_t nid;
6441 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006442 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006443
6444 spec->multiout.num_dacs = 1;
6445 spec->multiout.dac_nids = spec->private_dac_nids;
6446 spec->multiout.dac_nids[0] = 0x02;
6447
6448 nid = cfg->line_out_pins[0];
6449 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006450 const char *pfx;
6451 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6452 pfx = "Master";
6453 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6454 pfx = "Speaker";
6455 else
6456 pfx = "Front";
6457 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006458 if (err < 0)
6459 return err;
6460 }
6461
Takashi Iwai82bc9552006-03-21 11:24:42 +01006462 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006463 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006464 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006465 if (err < 0)
6466 return err;
6467 }
6468
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006469 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006470 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006471 err = alc260_add_playback_controls(spec, nid, "Headphone",
6472 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006473 if (err < 0)
6474 return err;
6475 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006476 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006477}
6478
6479/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006480static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006481 const struct auto_pin_cfg *cfg)
6482{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006483 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006484}
6485
6486static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6487 hda_nid_t nid, int pin_type,
6488 int sel_idx)
6489{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006490 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006491 /* need the manual connection? */
6492 if (nid >= 0x12) {
6493 int idx = nid - 0x12;
6494 snd_hda_codec_write(codec, idx + 0x0b, 0,
6495 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006496 }
6497}
6498
6499static void alc260_auto_init_multi_out(struct hda_codec *codec)
6500{
6501 struct alc_spec *spec = codec->spec;
6502 hda_nid_t nid;
6503
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006504 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006505 if (nid) {
6506 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6507 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6508 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006509
Takashi Iwai82bc9552006-03-21 11:24:42 +01006510 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006511 if (nid)
6512 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6513
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006514 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006515 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006516 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006517}
Kailang Yangdf694da2005-12-05 19:42:22 +01006518
6519#define ALC260_PIN_CD_NID 0x16
6520static void alc260_auto_init_analog_input(struct hda_codec *codec)
6521{
6522 struct alc_spec *spec = codec->spec;
6523 int i;
6524
6525 for (i = 0; i < AUTO_PIN_LAST; i++) {
6526 hda_nid_t nid = spec->autocfg.input_pins[i];
6527 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006528 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006529 if (nid != ALC260_PIN_CD_NID &&
6530 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006531 snd_hda_codec_write(codec, nid, 0,
6532 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006533 AMP_OUT_MUTE);
6534 }
6535 }
6536}
6537
Takashi Iwai7f311a42010-04-09 17:32:23 +02006538#define alc260_auto_init_input_src alc880_auto_init_input_src
6539
Kailang Yangdf694da2005-12-05 19:42:22 +01006540/*
6541 * generic initialization of ADC, input mixers and output mixers
6542 */
6543static struct hda_verb alc260_volume_init_verbs[] = {
6544 /*
6545 * Unmute ADC0-1 and set the default input to mic-in
6546 */
6547 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6548 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6549 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6550 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006551
Kailang Yangdf694da2005-12-05 19:42:22 +01006552 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6553 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006554 * Note: PASD motherboards uses the Line In 2 as the input for
6555 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006556 */
6557 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006558 /* mute analog inputs */
6559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6560 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6561 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6562 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006564
6565 /*
6566 * Set up output mixers (0x08 - 0x0a)
6567 */
6568 /* set vol=0 to output mixers */
6569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6570 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6571 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6572 /* set up input amps for analog loopback */
6573 /* Amp Indices: DAC = 0, mixer = 1 */
6574 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6576 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6578 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6579 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006580
Kailang Yangdf694da2005-12-05 19:42:22 +01006581 { }
6582};
6583
6584static int alc260_parse_auto_config(struct hda_codec *codec)
6585{
6586 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006587 int err;
6588 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6589
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006590 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6591 alc260_ignore);
6592 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006593 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006594 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6595 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006596 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006597 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006598 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006599 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006600 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006601 return err;
6602
6603 spec->multiout.max_channels = 2;
6604
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006605 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006606 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006607 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006608 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006609
Takashi Iwaid88897e2008-10-31 15:01:37 +01006610 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006611
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006612 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006613 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006614
Kailang Yang6227cdc2010-02-25 08:36:52 +01006615 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006616
Kailang Yangdf694da2005-12-05 19:42:22 +01006617 return 1;
6618}
6619
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006620/* additional initialization for auto-configuration model */
6621static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006622{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006623 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006624 alc260_auto_init_multi_out(codec);
6625 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006626 alc260_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006627 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006628 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006629}
6630
Takashi Iwaicb53c622007-08-10 17:21:45 +02006631#ifdef CONFIG_SND_HDA_POWER_SAVE
6632static struct hda_amp_list alc260_loopbacks[] = {
6633 { 0x07, HDA_INPUT, 0 },
6634 { 0x07, HDA_INPUT, 1 },
6635 { 0x07, HDA_INPUT, 2 },
6636 { 0x07, HDA_INPUT, 3 },
6637 { 0x07, HDA_INPUT, 4 },
6638 { } /* end */
6639};
6640#endif
6641
Kailang Yangdf694da2005-12-05 19:42:22 +01006642/*
6643 * ALC260 configurations
6644 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006645static const char *alc260_models[ALC260_MODEL_LAST] = {
6646 [ALC260_BASIC] = "basic",
6647 [ALC260_HP] = "hp",
6648 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006649 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006650 [ALC260_FUJITSU_S702X] = "fujitsu",
6651 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006652 [ALC260_WILL] = "will",
6653 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006654 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006655#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006656 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006657#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006658 [ALC260_AUTO] = "auto",
6659};
6660
6661static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006662 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006663 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006664 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006665 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006666 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006667 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006668 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006669 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006670 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006671 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6672 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6673 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6674 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6675 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6676 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6677 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6678 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6679 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006680 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006681 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006682 {}
6683};
6684
Kailang Yangdf694da2005-12-05 19:42:22 +01006685static struct alc_config_preset alc260_presets[] = {
6686 [ALC260_BASIC] = {
6687 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006688 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006689 .init_verbs = { alc260_init_verbs },
6690 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6691 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006692 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006693 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006694 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6695 .channel_mode = alc260_modes,
6696 .input_mux = &alc260_capture_source,
6697 },
6698 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006699 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006700 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006701 .init_verbs = { alc260_init_verbs,
6702 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006703 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6704 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006705 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6706 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006707 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6708 .channel_mode = alc260_modes,
6709 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006710 .unsol_event = alc260_hp_unsol_event,
6711 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006712 },
Kailang Yang3f878302008-08-26 13:02:23 +02006713 [ALC260_HP_DC7600] = {
6714 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006715 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006716 .init_verbs = { alc260_init_verbs,
6717 alc260_hp_dc7600_verbs },
6718 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6719 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006720 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6721 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006722 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6723 .channel_mode = alc260_modes,
6724 .input_mux = &alc260_capture_source,
6725 .unsol_event = alc260_hp_3012_unsol_event,
6726 .init_hook = alc260_hp_3012_automute,
6727 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006728 [ALC260_HP_3013] = {
6729 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006730 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006731 .init_verbs = { alc260_hp_3013_init_verbs,
6732 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006733 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6734 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006735 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6736 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006737 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6738 .channel_mode = alc260_modes,
6739 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006740 .unsol_event = alc260_hp_3013_unsol_event,
6741 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006742 },
6743 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006744 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006745 .init_verbs = { alc260_fujitsu_init_verbs },
6746 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6747 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006748 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6749 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006750 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6751 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006752 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6753 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006754 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006755 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006756 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006757 .init_verbs = { alc260_acer_init_verbs },
6758 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6759 .dac_nids = alc260_dac_nids,
6760 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6761 .adc_nids = alc260_dual_adc_nids,
6762 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6763 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006764 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6765 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006766 },
Michael Schwingencc959482009-02-22 18:58:45 +01006767 [ALC260_FAVORIT100] = {
6768 .mixers = { alc260_favorit100_mixer },
6769 .init_verbs = { alc260_favorit100_init_verbs },
6770 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6771 .dac_nids = alc260_dac_nids,
6772 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6773 .adc_nids = alc260_dual_adc_nids,
6774 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6775 .channel_mode = alc260_modes,
6776 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6777 .input_mux = alc260_favorit100_capture_sources,
6778 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006779 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006780 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006781 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6782 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6783 .dac_nids = alc260_dac_nids,
6784 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6785 .adc_nids = alc260_adc_nids,
6786 .dig_out_nid = ALC260_DIGOUT_NID,
6787 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6788 .channel_mode = alc260_modes,
6789 .input_mux = &alc260_capture_source,
6790 },
6791 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006792 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006793 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6794 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6795 .dac_nids = alc260_dac_nids,
6796 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6797 .adc_nids = alc260_adc_nids,
6798 .dig_out_nid = ALC260_DIGOUT_NID,
6799 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6800 .channel_mode = alc260_modes,
6801 .input_mux = &alc260_capture_source,
6802 .unsol_event = alc260_replacer_672v_unsol_event,
6803 .init_hook = alc260_replacer_672v_automute,
6804 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006805#ifdef CONFIG_SND_DEBUG
6806 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006807 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006808 .init_verbs = { alc260_test_init_verbs },
6809 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6810 .dac_nids = alc260_test_dac_nids,
6811 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6812 .adc_nids = alc260_test_adc_nids,
6813 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6814 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006815 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6816 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006817 },
6818#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006819};
6820
Linus Torvalds1da177e2005-04-16 15:20:36 -07006821static int patch_alc260(struct hda_codec *codec)
6822{
6823 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006824 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006825
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006826 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006827 if (spec == NULL)
6828 return -ENOMEM;
6829
6830 codec->spec = spec;
6831
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006832 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6833 alc260_models,
6834 alc260_cfg_tbl);
6835 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006836 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006837 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006838 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006839 }
6840
Kailang Yangdf694da2005-12-05 19:42:22 +01006841 if (board_config == ALC260_AUTO) {
6842 /* automatic parse from the BIOS config */
6843 err = alc260_parse_auto_config(codec);
6844 if (err < 0) {
6845 alc_free(codec);
6846 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006847 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006848 printk(KERN_INFO
6849 "hda_codec: Cannot set up configuration "
6850 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006851 board_config = ALC260_BASIC;
6852 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006853 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006854
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006855 err = snd_hda_attach_beep_device(codec, 0x1);
6856 if (err < 0) {
6857 alc_free(codec);
6858 return err;
6859 }
6860
Kailang Yangdf694da2005-12-05 19:42:22 +01006861 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006862 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006863
Linus Torvalds1da177e2005-04-16 15:20:36 -07006864 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6865 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6866
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006867 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6868 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6869
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006870 if (!spec->adc_nids && spec->input_mux) {
6871 /* check whether NID 0x04 is valid */
6872 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006873 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006874 /* get type */
6875 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6876 spec->adc_nids = alc260_adc_nids_alt;
6877 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6878 } else {
6879 spec->adc_nids = alc260_adc_nids;
6880 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6881 }
6882 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006883 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006884 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006885
Takashi Iwai2134ea42008-01-10 16:53:55 +01006886 spec->vmaster_nid = 0x08;
6887
Linus Torvalds1da177e2005-04-16 15:20:36 -07006888 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006889 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006890 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006891#ifdef CONFIG_SND_HDA_POWER_SAVE
6892 if (!spec->loopback.amplist)
6893 spec->loopback.amplist = alc260_loopbacks;
6894#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006895
6896 return 0;
6897}
6898
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006899
Linus Torvalds1da177e2005-04-16 15:20:36 -07006900/*
Takashi Iwai49535502009-06-30 15:28:30 +02006901 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006902 *
6903 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6904 * configuration. Each pin widget can choose any input DACs and a mixer.
6905 * Each ADC is connected from a mixer of all inputs. This makes possible
6906 * 6-channel independent captures.
6907 *
6908 * In addition, an independent DAC for the multi-playback (not used in this
6909 * driver yet).
6910 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006911#define ALC882_DIGOUT_NID 0x06
6912#define ALC882_DIGIN_NID 0x0a
Takashi Iwai49535502009-06-30 15:28:30 +02006913#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6914#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6915#define ALC1200_DIGOUT_NID 0x10
6916
Linus Torvalds1da177e2005-04-16 15:20:36 -07006917
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006918static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006919 { 8, NULL }
6920};
6921
Takashi Iwai49535502009-06-30 15:28:30 +02006922/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006923static hda_nid_t alc882_dac_nids[4] = {
6924 /* front, rear, clfe, rear_surr */
6925 0x02, 0x03, 0x04, 0x05
6926};
Takashi Iwai49535502009-06-30 15:28:30 +02006927#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006928
Takashi Iwai49535502009-06-30 15:28:30 +02006929/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006930#define alc882_adc_nids alc880_adc_nids
6931#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai49535502009-06-30 15:28:30 +02006932#define alc883_adc_nids alc882_adc_nids_alt
6933static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6934static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6935#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006936
Takashi Iwaie1406342008-02-11 18:32:32 +01006937static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6938static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai49535502009-06-30 15:28:30 +02006939#define alc883_capsrc_nids alc882_capsrc_nids_alt
6940static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6941#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006942
Linus Torvalds1da177e2005-04-16 15:20:36 -07006943/* input MUX */
6944/* FIXME: should be a matrix-type input source selection */
6945
6946static struct hda_input_mux alc882_capture_source = {
6947 .num_items = 4,
6948 .items = {
6949 { "Mic", 0x0 },
6950 { "Front Mic", 0x1 },
6951 { "Line", 0x2 },
6952 { "CD", 0x4 },
6953 },
6954};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006955
Takashi Iwai49535502009-06-30 15:28:30 +02006956#define alc883_capture_source alc882_capture_source
6957
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006958static struct hda_input_mux alc889_capture_source = {
6959 .num_items = 3,
6960 .items = {
6961 { "Front Mic", 0x0 },
6962 { "Mic", 0x3 },
6963 { "Line", 0x2 },
6964 },
6965};
6966
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006967static struct hda_input_mux mb5_capture_source = {
6968 .num_items = 3,
6969 .items = {
6970 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09306971 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006972 { "CD", 0x4 },
6973 },
6974};
6975
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006976static struct hda_input_mux macmini3_capture_source = {
6977 .num_items = 2,
6978 .items = {
6979 { "Line", 0x2 },
6980 { "CD", 0x4 },
6981 },
6982};
6983
Takashi Iwai49535502009-06-30 15:28:30 +02006984static struct hda_input_mux alc883_3stack_6ch_intel = {
6985 .num_items = 4,
6986 .items = {
6987 { "Mic", 0x1 },
6988 { "Front Mic", 0x0 },
6989 { "Line", 0x2 },
6990 { "CD", 0x4 },
6991 },
6992};
6993
6994static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6995 .num_items = 2,
6996 .items = {
6997 { "Mic", 0x1 },
6998 { "Line", 0x2 },
6999 },
7000};
7001
7002static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7003 .num_items = 4,
7004 .items = {
7005 { "Mic", 0x0 },
7006 { "iMic", 0x1 },
7007 { "Line", 0x2 },
7008 { "CD", 0x4 },
7009 },
7010};
7011
7012static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7013 .num_items = 2,
7014 .items = {
7015 { "Mic", 0x0 },
7016 { "Int Mic", 0x1 },
7017 },
7018};
7019
7020static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7021 .num_items = 3,
7022 .items = {
7023 { "Mic", 0x0 },
7024 { "Front Mic", 0x1 },
7025 { "Line", 0x4 },
7026 },
7027};
7028
7029static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7030 .num_items = 2,
7031 .items = {
7032 { "Mic", 0x0 },
7033 { "Line", 0x2 },
7034 },
7035};
7036
7037static struct hda_input_mux alc889A_mb31_capture_source = {
7038 .num_items = 2,
7039 .items = {
7040 { "Mic", 0x0 },
7041 /* Front Mic (0x01) unused */
7042 { "Line", 0x2 },
7043 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007044 /* CD (0x04) unused? */
Takashi Iwai49535502009-06-30 15:28:30 +02007045 },
7046};
7047
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007048static struct hda_input_mux alc889A_imac91_capture_source = {
7049 .num_items = 2,
7050 .items = {
7051 { "Mic", 0x01 },
7052 { "Line", 0x2 }, /* Not sure! */
7053 },
7054};
7055
Takashi Iwai49535502009-06-30 15:28:30 +02007056/*
7057 * 2ch mode
7058 */
7059static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7060 { 2, NULL }
7061};
7062
Kailang Yangdf694da2005-12-05 19:42:22 +01007063/*
Kailang Yang272a5272007-05-14 11:00:38 +02007064 * 2ch mode
7065 */
7066static struct hda_verb alc882_3ST_ch2_init[] = {
7067 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7068 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7069 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7070 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7071 { } /* end */
7072};
7073
7074/*
Takashi Iwai49535502009-06-30 15:28:30 +02007075 * 4ch mode
7076 */
7077static struct hda_verb alc882_3ST_ch4_init[] = {
7078 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7079 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7080 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7081 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7082 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7083 { } /* end */
7084};
7085
7086/*
Kailang Yang272a5272007-05-14 11:00:38 +02007087 * 6ch mode
7088 */
7089static struct hda_verb alc882_3ST_ch6_init[] = {
7090 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7091 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7092 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7093 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7094 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7095 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7096 { } /* end */
7097};
7098
Takashi Iwai49535502009-06-30 15:28:30 +02007099static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007100 { 2, alc882_3ST_ch2_init },
Takashi Iwai49535502009-06-30 15:28:30 +02007101 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007102 { 6, alc882_3ST_ch6_init },
7103};
7104
Takashi Iwai49535502009-06-30 15:28:30 +02007105#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7106
Kailang Yang272a5272007-05-14 11:00:38 +02007107/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307108 * 2ch mode
7109 */
7110static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7111 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7112 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7113 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7114 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7115 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7116 { } /* end */
7117};
7118
7119/*
7120 * 4ch mode
7121 */
7122static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7123 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7124 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7125 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7126 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7127 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7128 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7129 { } /* end */
7130};
7131
7132/*
7133 * 6ch mode
7134 */
7135static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7136 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7137 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7138 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7139 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7140 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7141 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7142 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7143 { } /* end */
7144};
7145
7146static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7147 { 2, alc883_3ST_ch2_clevo_init },
7148 { 4, alc883_3ST_ch4_clevo_init },
7149 { 6, alc883_3ST_ch6_clevo_init },
7150};
7151
7152
7153/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007154 * 6ch mode
7155 */
7156static struct hda_verb alc882_sixstack_ch6_init[] = {
7157 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7158 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7159 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7160 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7161 { } /* end */
7162};
7163
7164/*
7165 * 8ch mode
7166 */
7167static struct hda_verb alc882_sixstack_ch8_init[] = {
7168 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7169 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7170 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7171 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7172 { } /* end */
7173};
7174
7175static struct hda_channel_mode alc882_sixstack_modes[2] = {
7176 { 6, alc882_sixstack_ch6_init },
7177 { 8, alc882_sixstack_ch8_init },
7178};
7179
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007180
7181/* Macbook Air 2,1 */
7182
7183static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7184 { 2, NULL },
7185};
7186
Takashi Iwai87350ad2007-08-16 18:19:38 +02007187/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007188 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007189 */
7190
7191/*
7192 * 2ch mode
7193 */
7194static struct hda_verb alc885_mbp_ch2_init[] = {
7195 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7196 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7197 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7198 { } /* end */
7199};
7200
7201/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007202 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007203 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007204static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007205 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7206 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7207 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7208 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7209 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7210 { } /* end */
7211};
7212
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007213static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007214 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007215 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007216};
7217
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007218/*
7219 * 2ch
7220 * Speakers/Woofer/HP = Front
7221 * LineIn = Input
7222 */
7223static struct hda_verb alc885_mb5_ch2_init[] = {
7224 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7226 { } /* end */
7227};
7228
7229/*
7230 * 6ch mode
7231 * Speakers/HP = Front
7232 * Woofer = LFE
7233 * LineIn = Surround
7234 */
7235static struct hda_verb alc885_mb5_ch6_init[] = {
7236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7239 { } /* end */
7240};
7241
7242static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7243 { 2, alc885_mb5_ch2_init },
7244 { 6, alc885_mb5_ch6_init },
7245};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007246
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007247#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai49535502009-06-30 15:28:30 +02007248
7249/*
7250 * 2ch mode
7251 */
7252static struct hda_verb alc883_4ST_ch2_init[] = {
7253 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7254 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7255 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7256 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7257 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7258 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7259 { } /* end */
7260};
7261
7262/*
7263 * 4ch mode
7264 */
7265static struct hda_verb alc883_4ST_ch4_init[] = {
7266 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7267 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7268 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7269 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7270 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7271 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7272 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7273 { } /* end */
7274};
7275
7276/*
7277 * 6ch mode
7278 */
7279static struct hda_verb alc883_4ST_ch6_init[] = {
7280 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7281 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7282 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7283 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7284 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7285 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7286 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7287 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7288 { } /* end */
7289};
7290
7291/*
7292 * 8ch mode
7293 */
7294static struct hda_verb alc883_4ST_ch8_init[] = {
7295 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7296 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7297 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7298 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7299 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7300 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7301 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7302 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7303 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7304 { } /* end */
7305};
7306
7307static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7308 { 2, alc883_4ST_ch2_init },
7309 { 4, alc883_4ST_ch4_init },
7310 { 6, alc883_4ST_ch6_init },
7311 { 8, alc883_4ST_ch8_init },
7312};
7313
7314
7315/*
7316 * 2ch mode
7317 */
7318static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7319 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7320 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7321 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7322 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7323 { } /* end */
7324};
7325
7326/*
7327 * 4ch mode
7328 */
7329static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7330 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7331 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7332 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7333 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7334 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7335 { } /* end */
7336};
7337
7338/*
7339 * 6ch mode
7340 */
7341static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7342 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7343 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7344 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7345 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7346 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7347 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7348 { } /* end */
7349};
7350
7351static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7352 { 2, alc883_3ST_ch2_intel_init },
7353 { 4, alc883_3ST_ch4_intel_init },
7354 { 6, alc883_3ST_ch6_intel_init },
7355};
7356
7357/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007358 * 2ch mode
7359 */
7360static struct hda_verb alc889_ch2_intel_init[] = {
7361 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7362 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7363 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7364 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7365 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7366 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7367 { } /* end */
7368};
7369
7370/*
Takashi Iwai49535502009-06-30 15:28:30 +02007371 * 6ch mode
7372 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007373static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007374 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7375 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7376 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7377 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7378 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007379 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7380 { } /* end */
7381};
7382
7383/*
7384 * 8ch mode
7385 */
7386static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007387 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7388 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7389 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7390 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7391 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007392 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7393 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007394 { } /* end */
7395};
7396
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007397static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7398 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007399 { 6, alc889_ch6_intel_init },
7400 { 8, alc889_ch8_intel_init },
7401};
7402
7403/*
7404 * 6ch mode
7405 */
Takashi Iwai49535502009-06-30 15:28:30 +02007406static struct hda_verb alc883_sixstack_ch6_init[] = {
7407 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7408 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7409 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7410 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7411 { } /* end */
7412};
7413
7414/*
7415 * 8ch mode
7416 */
7417static struct hda_verb alc883_sixstack_ch8_init[] = {
7418 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7419 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7420 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7421 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7422 { } /* end */
7423};
7424
7425static struct hda_channel_mode alc883_sixstack_modes[2] = {
7426 { 6, alc883_sixstack_ch6_init },
7427 { 8, alc883_sixstack_ch8_init },
7428};
7429
7430
Linus Torvalds1da177e2005-04-16 15:20:36 -07007431/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7432 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7433 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01007434static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007435 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007436 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007437 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007438 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007439 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7440 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007441 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7442 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007443 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007444 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007445 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7446 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7447 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7448 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7449 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7450 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007451 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007452 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7453 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007454 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007455 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007456 { } /* end */
7457};
7458
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007459/* Macbook Air 2,1 same control for HP and internal Speaker */
7460
7461static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7462 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7463 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7464 { }
7465};
7466
7467
Takashi Iwai87350ad2007-08-16 18:19:38 +02007468static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007469 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7470 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7471 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7472 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7473 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7475 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7477 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007478 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007479 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7480 { } /* end */
7481};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007482
7483static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007484 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7485 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7486 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7487 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7488 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7489 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307490 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7491 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7493 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7495 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7496 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7497 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7498 { } /* end */
7499};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007500
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007501static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7502 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7503 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7504 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7505 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7506 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7507 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7508 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7509 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7510 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7511 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7512 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7513 { } /* end */
7514};
7515
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007516static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007517 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7518 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007519 { } /* end */
7520};
7521
7522
Kailang Yangbdd148a2007-05-08 15:19:08 +02007523static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7524 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7525 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7526 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7527 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7528 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7529 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7531 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007533 { } /* end */
7534};
7535
Kailang Yang272a5272007-05-14 11:00:38 +02007536static struct snd_kcontrol_new alc882_targa_mixer[] = {
7537 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7538 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7539 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7540 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7541 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7542 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7543 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007546 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007547 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7548 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007549 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007550 { } /* end */
7551};
7552
7553/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7554 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7555 */
7556static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7557 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7558 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7559 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7560 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7563 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7564 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7565 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7566 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7567 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7568 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02007569 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007570 { } /* end */
7571};
7572
Takashi Iwai914759b2007-09-06 14:52:04 +02007573static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7574 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7575 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7576 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7577 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7578 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7579 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7580 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7582 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7583 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007584 { } /* end */
7585};
7586
Kailang Yangdf694da2005-12-05 19:42:22 +01007587static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7588 {
7589 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7590 .name = "Channel Mode",
7591 .info = alc_ch_mode_info,
7592 .get = alc_ch_mode_get,
7593 .put = alc_ch_mode_put,
7594 },
7595 { } /* end */
7596};
7597
Takashi Iwai49535502009-06-30 15:28:30 +02007598static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007599 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007602 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007603 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7604 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007605 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007606 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007608 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007609 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7610 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007611
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007612 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007614 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007615 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007616 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007617 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007618 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007619 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007620 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007621 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007622 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007623 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007624 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007625 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007626 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007627 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007628 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007629 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007630 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7631 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007632 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007633 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7634 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007635 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007636 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7637 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7638 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7639 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7640 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007641 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007642 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007643
7644 /* FIXME: use matrix-type input source selection */
7645 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007646 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007647 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007648 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007650 /* ADC2: mute amp left and right */
7651 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007652 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007653 /* ADC3: mute amp left and right */
7654 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007655 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007656
7657 { }
7658};
7659
Takashi Iwai49535502009-06-30 15:28:30 +02007660static struct hda_verb alc882_adc1_init_verbs[] = {
7661 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7666 /* ADC1: mute amp left and right */
7667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7668 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7669 { }
7670};
7671
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007672static struct hda_verb alc882_eapd_verbs[] = {
7673 /* change to EAPD mode */
7674 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007675 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007676 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007677};
7678
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007679static struct hda_verb alc889_eapd_verbs[] = {
7680 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7681 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7682 { }
7683};
7684
Wu Fengguang6732bd02009-07-30 09:19:14 +02007685static struct hda_verb alc_hp15_unsol_verbs[] = {
7686 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7688 {}
7689};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007690
7691static struct hda_verb alc885_init_verbs[] = {
7692 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007695 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007696 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7697 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007698 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007699 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007701 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007702 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7703 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007704
7705 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7708 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7709 /* Front Pin: output 0 (0x0c) */
7710 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7712 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7713 /* Rear Pin: output 1 (0x0d) */
7714 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7715 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7716 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7717 /* CLFE Pin: output 2 (0x0e) */
7718 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7719 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7720 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7721 /* Side Pin: output 3 (0x0f) */
7722 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7723 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7724 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7725 /* Mic (rear) pin: input vref at 80% */
7726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7727 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7728 /* Front Mic pin: input vref at 80% */
7729 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7731 /* Line In pin: input */
7732 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7733 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7734
7735 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7736 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007737 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007738 /* Input mixer2 */
7739 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007740 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007741 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007742 /* ADC2: mute amp left and right */
7743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7744 /* ADC3: mute amp left and right */
7745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7746
7747 { }
7748};
7749
7750static struct hda_verb alc885_init_input_verbs[] = {
7751 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7752 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7754 { }
7755};
7756
7757
7758/* Unmute Selector 24h and set the default input to front mic */
7759static struct hda_verb alc889_init_input_verbs[] = {
7760 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7762 { }
7763};
7764
7765
Takashi Iwai49535502009-06-30 15:28:30 +02007766#define alc883_init_verbs alc882_base_init_verbs
7767
Tobin Davis9102cd12006-12-15 10:02:12 +01007768/* Mac Pro test */
7769static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7770 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7771 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007775 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007776 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7777 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007778 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007779 { } /* end */
7780};
7781
7782static struct hda_verb alc882_macpro_init_verbs[] = {
7783 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7785 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7787 /* Front Pin: output 0 (0x0c) */
7788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7790 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7791 /* Front Mic pin: input vref at 80% */
7792 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7793 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7794 /* Speaker: output */
7795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7797 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7798 /* Headphone output (output 0 - 0x0c) */
7799 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7800 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7801 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7802
7803 /* FIXME: use matrix-type input source selection */
7804 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7805 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7807 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7808 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7809 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7810 /* Input mixer2 */
7811 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7812 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7813 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7814 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7815 /* Input mixer3 */
7816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7820 /* ADC1: mute amp left and right */
7821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7822 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7823 /* ADC2: mute amp left and right */
7824 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7825 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7826 /* ADC3: mute amp left and right */
7827 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7828 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7829
7830 { }
7831};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007832
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007833/* Macbook 5,1 */
7834static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007835 /* DACs */
7836 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7837 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7838 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7839 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007840 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007844 /* Surround mixer */
7845 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7848 /* LFE mixer */
7849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7852 /* HP mixer */
7853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7854 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7855 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7856 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007857 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007859 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7860 /* LFE Pin (0x0e) */
7861 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7862 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7863 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7864 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007865 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7866 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007867 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307868 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007869 /* Front Mic pin: input vref at 80% */
7870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7871 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7872 /* Line In pin */
7873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7875
Alex Murrayb8f171e2010-06-14 12:08:43 +09307876 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
7877 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
7878 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007879 { }
7880};
7881
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007882/* Macmini 3,1 */
7883static struct hda_verb alc885_macmini3_init_verbs[] = {
7884 /* DACs */
7885 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7886 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7887 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7888 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7889 /* Front mixer */
7890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7893 /* Surround mixer */
7894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7896 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7897 /* LFE mixer */
7898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7900 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7901 /* HP mixer */
7902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7903 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7904 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7905 /* Front Pin (0x0c) */
7906 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7907 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7908 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7909 /* LFE Pin (0x0e) */
7910 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7911 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7912 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7913 /* HP Pin (0x0f) */
7914 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7915 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7916 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7917 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7918 /* Line In pin */
7919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7921
7922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7925 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7926 { }
7927};
7928
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007929
7930static struct hda_verb alc885_mba21_init_verbs[] = {
7931 /*Internal and HP Speaker Mixer*/
7932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7935 /*Internal Speaker Pin (0x0c)*/
7936 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7937 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7938 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7939 /* HP Pin: output 0 (0x0e) */
7940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7941 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7942 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7943 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7944 /* Line in (is hp when jack connected)*/
7945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7947
7948 { }
7949 };
7950
7951
Takashi Iwai87350ad2007-08-16 18:19:38 +02007952/* Macbook Pro rev3 */
7953static struct hda_verb alc885_mbp3_init_verbs[] = {
7954 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7958 /* Rear mixer */
7959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007962 /* HP mixer */
7963 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7965 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007966 /* Front Pin: output 0 (0x0c) */
7967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7969 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007970 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7973 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007974 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7975 /* Mic (rear) pin: input vref at 80% */
7976 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7977 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7978 /* Front Mic pin: input vref at 80% */
7979 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7980 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7981 /* Line In pin: use output 1 when in LineOut mode */
7982 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7983 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7984 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7985
7986 /* FIXME: use matrix-type input source selection */
7987 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7988 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7993 /* Input mixer2 */
7994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7998 /* Input mixer3 */
7999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8003 /* ADC1: mute amp left and right */
8004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8005 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8006 /* ADC2: mute amp left and right */
8007 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8008 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8009 /* ADC3: mute amp left and right */
8010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8011 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8012
8013 { }
8014};
8015
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008016/* iMac 9,1 */
8017static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008018 /* Internal Speaker Pin (0x0c) */
8019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8020 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8021 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8022 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8023 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8024 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8025 /* HP Pin: Rear */
8026 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8027 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8028 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8029 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8030 /* Line in Rear */
8031 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8033 /* Front Mic pin: input vref at 80% */
8034 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8035 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008036 /* Rear mixer */
8037 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8038 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8039 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008040 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8041 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8043 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8044 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008049 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8053 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008054 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008059 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8061 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008062 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8064 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008065 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008066 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8067 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008068 { }
8069};
8070
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008071/* iMac 24 mixer. */
8072static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8073 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8074 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8075 { } /* end */
8076};
8077
8078/* iMac 24 init verbs. */
8079static struct hda_verb alc885_imac24_init_verbs[] = {
8080 /* Internal speakers: output 0 (0x0c) */
8081 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8082 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8083 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8084 /* Internal speakers: output 0 (0x0c) */
8085 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8087 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8088 /* Headphone: output 0 (0x0c) */
8089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8091 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8092 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8093 /* Front Mic: input vref at 80% */
8094 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8095 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8096 { }
8097};
8098
8099/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008100static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008101{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008102 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008103
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008104 spec->autocfg.hp_pins[0] = 0x14;
8105 spec->autocfg.speaker_pins[0] = 0x18;
8106 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008107}
8108
Takashi Iwai9d54f082010-02-22 08:34:40 +01008109#define alc885_mb5_setup alc885_imac24_setup
8110#define alc885_macmini3_setup alc885_imac24_setup
8111
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008112/* Macbook Air 2,1 */
8113static void alc885_mba21_setup(struct hda_codec *codec)
8114{
8115 struct alc_spec *spec = codec->spec;
8116
8117 spec->autocfg.hp_pins[0] = 0x14;
8118 spec->autocfg.speaker_pins[0] = 0x18;
8119}
8120
8121
8122
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008123static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008124{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008125 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008126
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008127 spec->autocfg.hp_pins[0] = 0x15;
8128 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008129}
8130
Takashi Iwai9d54f082010-02-22 08:34:40 +01008131static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308132{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008133 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308134
Takashi Iwai9d54f082010-02-22 08:34:40 +01008135 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008136 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008137 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008138}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008139
Kailang Yang272a5272007-05-14 11:00:38 +02008140static struct hda_verb alc882_targa_verbs[] = {
8141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8142 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8143
8144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8145 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008146
Kailang Yang272a5272007-05-14 11:00:38 +02008147 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8148 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8149 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8150
8151 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008152 { } /* end */
8153};
8154
8155/* toggle speaker-output according to the hp-jack state */
8156static void alc882_targa_automute(struct hda_codec *codec)
8157{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008158 struct alc_spec *spec = codec->spec;
8159 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008160 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008161 spec->jack_present ? 1 : 3);
8162}
8163
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008164static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008165{
8166 struct alc_spec *spec = codec->spec;
8167
8168 spec->autocfg.hp_pins[0] = 0x14;
8169 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008170}
8171
8172static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8173{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008174 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008175 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008176}
8177
8178static struct hda_verb alc882_asus_a7j_verbs[] = {
8179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8181
8182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8184 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008185
Kailang Yang272a5272007-05-14 11:00:38 +02008186 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8187 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8188 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8189
8190 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8191 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8192 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8193 { } /* end */
8194};
8195
Takashi Iwai914759b2007-09-06 14:52:04 +02008196static struct hda_verb alc882_asus_a7m_verbs[] = {
8197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8199
8200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8202 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008203
Takashi Iwai914759b2007-09-06 14:52:04 +02008204 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8205 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8206 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8207
8208 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8209 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8210 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8211 { } /* end */
8212};
8213
Tobin Davis9102cd12006-12-15 10:02:12 +01008214static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8215{
8216 unsigned int gpiostate, gpiomask, gpiodir;
8217
8218 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8219 AC_VERB_GET_GPIO_DATA, 0);
8220
8221 if (!muted)
8222 gpiostate |= (1 << pin);
8223 else
8224 gpiostate &= ~(1 << pin);
8225
8226 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8227 AC_VERB_GET_GPIO_MASK, 0);
8228 gpiomask |= (1 << pin);
8229
8230 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8231 AC_VERB_GET_GPIO_DIRECTION, 0);
8232 gpiodir |= (1 << pin);
8233
8234
8235 snd_hda_codec_write(codec, codec->afg, 0,
8236 AC_VERB_SET_GPIO_MASK, gpiomask);
8237 snd_hda_codec_write(codec, codec->afg, 0,
8238 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8239
8240 msleep(1);
8241
8242 snd_hda_codec_write(codec, codec->afg, 0,
8243 AC_VERB_SET_GPIO_DATA, gpiostate);
8244}
8245
Takashi Iwai7debbe52007-08-16 15:01:03 +02008246/* set up GPIO at initialization */
8247static void alc885_macpro_init_hook(struct hda_codec *codec)
8248{
8249 alc882_gpio_mute(codec, 0, 0);
8250 alc882_gpio_mute(codec, 1, 0);
8251}
8252
8253/* set up GPIO and update auto-muting at initialization */
8254static void alc885_imac24_init_hook(struct hda_codec *codec)
8255{
8256 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008257 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008258}
8259
Kailang Yangdf694da2005-12-05 19:42:22 +01008260/*
8261 * generic initialization of ADC, input mixers and output mixers
8262 */
Takashi Iwai49535502009-06-30 15:28:30 +02008263static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008264 /*
8265 * Unmute ADC0-2 and set the default input to mic-in
8266 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008267 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8268 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8269 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8270 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8271
Kailang Yangdf694da2005-12-05 19:42:22 +01008272 /*
8273 * Set up output mixers (0x0c - 0x0f)
8274 */
8275 /* set vol=0 to output mixers */
8276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8277 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8279 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8280 /* set up input amps for analog loopback */
8281 /* Amp Indices: DAC = 0, mixer = 1 */
8282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8285 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8288 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8289 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8290 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8291 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8292
8293 /* FIXME: use matrix-type input source selection */
8294 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008295 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008296 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008297 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008299 { }
8300};
8301
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008302/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8303static struct hda_verb alc889A_mb31_ch2_init[] = {
8304 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8306 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8307 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8308 { } /* end */
8309};
8310
8311/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8312static struct hda_verb alc889A_mb31_ch4_init[] = {
8313 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8314 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8315 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8316 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8317 { } /* end */
8318};
8319
8320/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8321static struct hda_verb alc889A_mb31_ch5_init[] = {
8322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8323 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8324 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8325 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8326 { } /* end */
8327};
8328
8329/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8330static struct hda_verb alc889A_mb31_ch6_init[] = {
8331 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8332 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8333 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8334 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8335 { } /* end */
8336};
8337
8338static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8339 { 2, alc889A_mb31_ch2_init },
8340 { 4, alc889A_mb31_ch4_init },
8341 { 5, alc889A_mb31_ch5_init },
8342 { 6, alc889A_mb31_ch6_init },
8343};
8344
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008345static struct hda_verb alc883_medion_eapd_verbs[] = {
8346 /* eanable EAPD on medion laptop */
8347 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8348 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8349 { }
8350};
8351
Takashi Iwai49535502009-06-30 15:28:30 +02008352#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008353
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008354static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8355 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8356 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8357 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8358 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8359 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8360 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8361 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8363 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8365 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8366 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8367 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008368 { } /* end */
8369};
8370
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008371static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008372 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8373 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8374 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8375 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8377 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8378 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8379 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8380 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8381 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008382 { } /* end */
8383};
8384
Jiang zhefb97dc62008-03-06 11:07:11 +01008385static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8386 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8387 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8388 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8389 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8390 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8391 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8393 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8394 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8395 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008396 { } /* end */
8397};
8398
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008399static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8400 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8401 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8403 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8404 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8405 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8406 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008408 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8410 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008411 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008412 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008413 { } /* end */
8414};
8415
8416static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8417 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8418 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8419 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8420 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8421 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8422 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8423 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8424 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008431 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008434 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008435 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008436 { } /* end */
8437};
8438
Jiang zhe17bba1b2008-06-04 12:11:07 +02008439static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8440 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8441 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8442 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8443 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8444 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8445 HDA_OUTPUT),
8446 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8447 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8448 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8449 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8450 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8451 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8452 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8453 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8454 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8455 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8456 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8457 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8458 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8459 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008460 { } /* end */
8461};
8462
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008463static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8464 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8465 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8466 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8467 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8468 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8469 HDA_OUTPUT),
8470 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8471 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8472 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8473 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8474 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8475 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8476 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8477 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8479 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8480 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8481 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8482 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8484 { } /* end */
8485};
8486
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008487static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008488 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008489 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008490 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008492 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8493 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008494 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8495 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008496 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008502 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008503 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8504 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008505 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008507 { } /* end */
8508};
8509
Sasha Alexandrc2592492009-06-16 14:52:54 -04008510static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008511 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008512 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008513 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008514 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008515 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8516 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8517 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8518 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8519 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8520 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8521 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8522 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8523 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8524 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8525 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008526 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008527 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008528 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008529};
Kailang Yangccc656c2006-10-17 12:32:26 +02008530
Sasha Alexandrc2592492009-06-16 14:52:54 -04008531static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008532 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008533 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008534 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008535 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008536 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8537 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008539 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008541 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8542 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8543 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008544 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008545};
Kailang Yangccc656c2006-10-17 12:32:26 +02008546
Takashi Iwaib99dba32009-09-17 18:23:00 +02008547static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8548 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8549 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8550 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8551 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8552 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8553 { } /* end */
8554};
8555
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008556static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8557 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8558 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008559 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8560 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8562 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8563 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008565 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008566};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008567
Kailang Yang272a5272007-05-14 11:00:38 +02008568static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8569 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8570 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8571 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8572 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8573 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8576 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8577 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008578 { } /* end */
8579};
8580
8581static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8582 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8584 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8585 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8586 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8588 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8589 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8590 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008591 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008592};
Kailang Yang272a5272007-05-14 11:00:38 +02008593
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008594static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8595 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8596 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8597 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8598 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8599 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8600 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8601 { } /* end */
8602};
8603
8604static struct hda_verb alc883_medion_wim2160_verbs[] = {
8605 /* Unmute front mixer */
8606 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8607 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8608
8609 /* Set speaker pin to front mixer */
8610 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8611
8612 /* Init headphone pin */
8613 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8614 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8615 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8616 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8617
8618 { } /* end */
8619};
8620
8621/* toggle speaker-output according to the hp-jack state */
8622static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8623{
8624 struct alc_spec *spec = codec->spec;
8625
8626 spec->autocfg.hp_pins[0] = 0x1a;
8627 spec->autocfg.speaker_pins[0] = 0x15;
8628}
8629
Tobin Davis2880a862007-08-07 11:50:26 +02008630static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008631 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8632 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008634 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8635 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8637 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008639 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008640};
Tobin Davis2880a862007-08-07 11:50:26 +02008641
Tony Vroond2fd4b02009-06-21 00:40:10 +01008642static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8643 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008644 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008647 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8648 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8650 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8651 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8652 { } /* end */
8653};
8654
Kailang Yange2757d52008-08-26 13:17:46 +02008655static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8656 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8657 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8658 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8659 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8660 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8661 0x0d, 1, 0x0, HDA_OUTPUT),
8662 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8663 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8664 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8665 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8666 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008667 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8668 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8673 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8674 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8675 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008677 { } /* end */
8678};
8679
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008680static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8681 /* Output mixers */
8682 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8683 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8684 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8685 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8686 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8687 HDA_OUTPUT),
8688 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8689 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8690 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8691 /* Output switches */
8692 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8693 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8694 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8695 /* Boost mixers */
8696 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8697 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8698 /* Input mixers */
8699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8700 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8701 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8702 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8703 { } /* end */
8704};
8705
Guido Günther3e1647c2009-06-05 00:47:26 +02008706static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8707 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8708 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8709 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8710 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8711 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8712 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8713 { } /* end */
8714};
8715
Kailang Yange2757d52008-08-26 13:17:46 +02008716static struct hda_bind_ctls alc883_bind_cap_vol = {
8717 .ops = &snd_hda_bind_vol,
8718 .values = {
8719 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8720 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8721 0
8722 },
8723};
8724
8725static struct hda_bind_ctls alc883_bind_cap_switch = {
8726 .ops = &snd_hda_bind_sw,
8727 .values = {
8728 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8729 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8730 0
8731 },
8732};
8733
8734static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8735 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8736 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8737 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8738 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8739 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8740 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8741 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008743 { } /* end */
8744};
8745
8746static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008747 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8748 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8749 {
8750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8751 /* .name = "Capture Source", */
8752 .name = "Input Source",
8753 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008754 .info = alc_mux_enum_info,
8755 .get = alc_mux_enum_get,
8756 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008757 },
8758 { } /* end */
8759};
8760
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008761static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8762 {
8763 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8764 .name = "Channel Mode",
8765 .info = alc_ch_mode_info,
8766 .get = alc_ch_mode_get,
8767 .put = alc_ch_mode_put,
8768 },
8769 { } /* end */
8770};
8771
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008772/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008773static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008774{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008775 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008776
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008777 spec->autocfg.hp_pins[0] = 0x15;
8778 spec->autocfg.speaker_pins[0] = 0x14;
8779 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008780}
8781
8782/* auto-toggle front mic */
8783/*
8784static void alc883_mitac_mic_automute(struct hda_codec *codec)
8785{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008786 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008787
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008788 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8789}
8790*/
8791
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008792static struct hda_verb alc883_mitac_verbs[] = {
8793 /* HP */
8794 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8796 /* Subwoofer */
8797 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8798 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8799
8800 /* enable unsolicited event */
8801 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8802 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8803
8804 { } /* end */
8805};
8806
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308807static struct hda_verb alc883_clevo_m540r_verbs[] = {
8808 /* HP */
8809 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8811 /* Int speaker */
8812 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8813
8814 /* enable unsolicited event */
8815 /*
8816 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8817 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8818 */
8819
8820 { } /* end */
8821};
8822
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008823static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008824 /* HP */
8825 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8826 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8827 /* Int speaker */
8828 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8830
8831 /* enable unsolicited event */
8832 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008833 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008834
8835 { } /* end */
8836};
8837
Jiang zhefb97dc62008-03-06 11:07:11 +01008838static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8839 /* HP */
8840 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8841 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8842 /* Subwoofer */
8843 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8845
8846 /* enable unsolicited event */
8847 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8848
8849 { } /* end */
8850};
8851
Sasha Alexandrc2592492009-06-16 14:52:54 -04008852static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8855
8856 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8857 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008858
David Heidelberger64a8be72009-06-08 16:15:18 +02008859/* Connect Line-Out side jack (SPDIF) to Side */
8860 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8861 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8862 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8863/* Connect Mic jack to CLFE */
8864 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8865 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8866 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8867/* Connect Line-in jack to Surround */
8868 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8869 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8870 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8871/* Connect HP out jack to Front */
8872 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8874 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008875
8876 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008877
8878 { } /* end */
8879};
8880
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008881static struct hda_verb alc883_lenovo_101e_verbs[] = {
8882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8883 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8884 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8885 { } /* end */
8886};
8887
Kailang Yang272a5272007-05-14 11:00:38 +02008888static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8889 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8891 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8893 { } /* end */
8894};
8895
8896static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8897 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8898 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8899 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8900 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8901 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8902 { } /* end */
8903};
8904
Kailang Yang189609a2007-08-20 11:31:23 +02008905static struct hda_verb alc883_haier_w66_verbs[] = {
8906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8908
8909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8910
8911 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8912 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8913 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8914 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8915 { } /* end */
8916};
8917
Kailang Yange2757d52008-08-26 13:17:46 +02008918static struct hda_verb alc888_lenovo_sky_verbs[] = {
8919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8924 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8925 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8926 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8927 { } /* end */
8928};
8929
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008930static struct hda_verb alc888_6st_dell_verbs[] = {
8931 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8932 { }
8933};
8934
Guido Günther3e1647c2009-06-05 00:47:26 +02008935static struct hda_verb alc883_vaiott_verbs[] = {
8936 /* HP */
8937 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8939
8940 /* enable unsolicited event */
8941 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8942
8943 { } /* end */
8944};
8945
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008946static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008947{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008948 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008949
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008950 spec->autocfg.hp_pins[0] = 0x1b;
8951 spec->autocfg.speaker_pins[0] = 0x14;
8952 spec->autocfg.speaker_pins[1] = 0x16;
8953 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008954}
8955
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008956static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008957 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008958 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8959 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008960 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008961 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008962};
8963
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008964/*
8965 * 2ch mode
8966 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008967static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008968 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8969 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8970 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8971 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008972 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008973};
8974
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008975/*
8976 * 4ch mode
8977 */
8978static struct hda_verb alc888_3st_hp_4ch_init[] = {
8979 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8980 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8981 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8982 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8983 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8984 { } /* end */
8985};
8986
8987/*
8988 * 6ch mode
8989 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008990static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008991 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8992 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008993 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008994 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8995 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008996 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8997 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008998};
8999
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009000static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009001 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009002 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009003 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009004};
9005
Kailang Yang272a5272007-05-14 11:00:38 +02009006/* toggle front-jack and RCA according to the hp-jack state */
9007static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9008{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009009 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009010
Takashi Iwai47fd8302007-08-10 17:11:07 +02009011 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9012 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9013 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9014 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009015}
9016
9017/* toggle RCA according to the front-jack state */
9018static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9019{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009020 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009021
Takashi Iwai47fd8302007-08-10 17:11:07 +02009022 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9023 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009024}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009025
Kailang Yang272a5272007-05-14 11:00:38 +02009026static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9027 unsigned int res)
9028{
9029 if ((res >> 26) == ALC880_HP_EVENT)
9030 alc888_lenovo_ms7195_front_automute(codec);
9031 if ((res >> 26) == ALC880_FRONT_EVENT)
9032 alc888_lenovo_ms7195_rca_automute(codec);
9033}
9034
9035static struct hda_verb alc883_medion_md2_verbs[] = {
9036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9038
9039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9040
9041 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9042 { } /* end */
9043};
9044
9045/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009046static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009047{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009048 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009049
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009050 spec->autocfg.hp_pins[0] = 0x14;
9051 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009052}
9053
Kailang Yangccc656c2006-10-17 12:32:26 +02009054/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009055#define alc883_targa_init_hook alc882_targa_init_hook
9056#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009057
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009058static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9059{
9060 unsigned int present;
9061
Takashi Iwaid56757a2009-11-18 08:00:14 +01009062 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009063 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9064 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9065}
9066
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009067static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009068{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009069 struct alc_spec *spec = codec->spec;
9070
9071 spec->autocfg.hp_pins[0] = 0x15;
9072 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009073}
9074
9075static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9076{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009077 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009078 alc883_clevo_m720_mic_automute(codec);
9079}
9080
9081static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009082 unsigned int res)
9083{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009084 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009085 case ALC880_MIC_EVENT:
9086 alc883_clevo_m720_mic_automute(codec);
9087 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009088 default:
9089 alc_automute_amp_unsol_event(codec, res);
9090 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009091 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009092}
9093
Jiang zhefb97dc62008-03-06 11:07:11 +01009094/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009095static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009096{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009097 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009098
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009099 spec->autocfg.hp_pins[0] = 0x14;
9100 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009101}
9102
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009103static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009104{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009105 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009106
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009107 spec->autocfg.hp_pins[0] = 0x1b;
9108 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009109}
9110
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009111static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9112{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009113 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009114
Takashi Iwai47fd8302007-08-10 17:11:07 +02009115 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9116 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009117}
9118
9119static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9120{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009121 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009122
Takashi Iwai47fd8302007-08-10 17:11:07 +02009123 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9124 HDA_AMP_MUTE, bits);
9125 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9126 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009127}
9128
9129static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9130 unsigned int res)
9131{
9132 if ((res >> 26) == ALC880_HP_EVENT)
9133 alc883_lenovo_101e_all_automute(codec);
9134 if ((res >> 26) == ALC880_FRONT_EVENT)
9135 alc883_lenovo_101e_ispeaker_automute(codec);
9136}
9137
Takashi Iwai676a9b52007-08-16 15:23:35 +02009138/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009139static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009140{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009141 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009142
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009143 spec->autocfg.hp_pins[0] = 0x14;
9144 spec->autocfg.speaker_pins[0] = 0x15;
9145 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009146}
9147
Kailang Yangd1a991a2007-08-15 16:21:59 +02009148static struct hda_verb alc883_acer_eapd_verbs[] = {
9149 /* HP Pin: output 0 (0x0c) */
9150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9151 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9152 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9153 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009156 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009157 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9158 /* eanable EAPD on medion laptop */
9159 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9160 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009161 /* enable unsolicited event */
9162 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009163 { }
9164};
9165
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009166static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9167 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9168 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9169 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9170 { } /* end */
9171};
9172
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009173static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009174{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009175 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009176
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009177 spec->autocfg.hp_pins[0] = 0x1b;
9178 spec->autocfg.speaker_pins[0] = 0x14;
9179 spec->autocfg.speaker_pins[1] = 0x15;
9180 spec->autocfg.speaker_pins[2] = 0x16;
9181 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009182}
9183
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009184static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009185{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009186 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009187
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009188 spec->autocfg.hp_pins[0] = 0x1b;
9189 spec->autocfg.speaker_pins[0] = 0x14;
9190 spec->autocfg.speaker_pins[1] = 0x15;
9191 spec->autocfg.speaker_pins[2] = 0x16;
9192 spec->autocfg.speaker_pins[3] = 0x17;
9193 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009194}
9195
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009196static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009197{
9198 struct alc_spec *spec = codec->spec;
9199
9200 spec->autocfg.hp_pins[0] = 0x15;
9201 spec->autocfg.speaker_pins[0] = 0x14;
9202 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009203}
9204
Kailang Yange2757d52008-08-26 13:17:46 +02009205static struct hda_verb alc888_asus_m90v_verbs[] = {
9206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9207 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9208 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9209 /* enable unsolicited event */
9210 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9211 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9212 { } /* end */
9213};
9214
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009215static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009216{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009217 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009218
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009219 spec->autocfg.hp_pins[0] = 0x1b;
9220 spec->autocfg.speaker_pins[0] = 0x14;
9221 spec->autocfg.speaker_pins[1] = 0x15;
9222 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009223 spec->ext_mic.pin = 0x18;
9224 spec->int_mic.pin = 0x19;
9225 spec->ext_mic.mux_idx = 0;
9226 spec->int_mic.mux_idx = 1;
9227 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009228}
9229
9230static struct hda_verb alc888_asus_eee1601_verbs[] = {
9231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9233 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9236 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9237 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9238 /* enable unsolicited event */
9239 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9240 { } /* end */
9241};
9242
Kailang Yange2757d52008-08-26 13:17:46 +02009243static void alc883_eee1601_inithook(struct hda_codec *codec)
9244{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009245 struct alc_spec *spec = codec->spec;
9246
9247 spec->autocfg.hp_pins[0] = 0x14;
9248 spec->autocfg.speaker_pins[0] = 0x1b;
9249 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009250}
9251
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009252static struct hda_verb alc889A_mb31_verbs[] = {
9253 /* Init rear pin (used as headphone output) */
9254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9255 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9256 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9257 /* Init line pin (used as output in 4ch and 6ch mode) */
9258 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9259 /* Init line 2 pin (used as headphone out by default) */
9260 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9262 { } /* end */
9263};
9264
9265/* Mute speakers according to the headphone jack state */
9266static void alc889A_mb31_automute(struct hda_codec *codec)
9267{
9268 unsigned int present;
9269
9270 /* Mute only in 2ch or 4ch mode */
9271 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9272 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009273 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009274 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9275 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9276 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9277 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9278 }
9279}
9280
9281static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9282{
9283 if ((res >> 26) == ALC880_HP_EVENT)
9284 alc889A_mb31_automute(codec);
9285}
9286
Takashi Iwai49535502009-06-30 15:28:30 +02009287
Takashi Iwaicb53c622007-08-10 17:21:45 +02009288#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai49535502009-06-30 15:28:30 +02009289#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009290#endif
9291
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009292/* pcm configuration: identical with ALC880 */
Takashi Iwai49535502009-06-30 15:28:30 +02009293#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9294#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9295#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9296#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9297
9298static hda_nid_t alc883_slave_dig_outs[] = {
9299 ALC1200_DIGOUT_NID, 0,
9300};
9301
9302static hda_nid_t alc1200_slave_dig_outs[] = {
9303 ALC883_DIGOUT_NID, 0,
9304};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009305
9306/*
9307 * configuration and preset
9308 */
Takashi Iwai49535502009-06-30 15:28:30 +02009309static const char *alc882_models[ALC882_MODEL_LAST] = {
9310 [ALC882_3ST_DIG] = "3stack-dig",
9311 [ALC882_6ST_DIG] = "6stack-dig",
9312 [ALC882_ARIMA] = "arima",
9313 [ALC882_W2JC] = "w2jc",
9314 [ALC882_TARGA] = "targa",
9315 [ALC882_ASUS_A7J] = "asus-a7j",
9316 [ALC882_ASUS_A7M] = "asus-a7m",
9317 [ALC885_MACPRO] = "macpro",
9318 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009319 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009320 [ALC885_MBA21] = "mba21",
Takashi Iwai49535502009-06-30 15:28:30 +02009321 [ALC885_MBP3] = "mbp3",
9322 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009323 [ALC885_IMAC91] = "imac91",
Takashi Iwai49535502009-06-30 15:28:30 +02009324 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009325 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9326 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai49535502009-06-30 15:28:30 +02009327 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009328 [ALC883_TARGA_DIG] = "targa-dig",
9329 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009330 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009331 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009332 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009333 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009334 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009335 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009336 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009337 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009338 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009339 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009340 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009341 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009342 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9343 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009344 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009345 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009346 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009347 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009348 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309349 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009350 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009351 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009352 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009353 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009354 [ALC889A_INTEL] = "intel-alc889a",
9355 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009356 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009357 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009358 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai49535502009-06-30 15:28:30 +02009359 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009360};
9361
Takashi Iwai49535502009-06-30 15:28:30 +02009362static struct snd_pci_quirk alc882_cfg_tbl[] = {
9363 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9364
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009365 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009366 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009367 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009368 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9369 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009370 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009371 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9372 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009373 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009374 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009375 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9376 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009377 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9378 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai49535502009-06-30 15:28:30 +02009379 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9380 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009381 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009382 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009383 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009384 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009385 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9386 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009387 /* default Acer -- disabled as it causes more problems.
9388 * model=auto should work fine now
9389 */
9390 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai49535502009-06-30 15:28:30 +02009391
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009392 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai49535502009-06-30 15:28:30 +02009393
Tobin Davisfebe3372007-06-12 11:27:46 +02009394 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009395 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9396 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009397 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009398 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009399 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai49535502009-06-30 15:28:30 +02009400
9401 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9402 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9403 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009404 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai49535502009-06-30 15:28:30 +02009405 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9406 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9407 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009408 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009409 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009410 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009411 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai49535502009-06-30 15:28:30 +02009412
9413 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009414 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009415 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009416 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009417 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9418 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009419 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009420 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02009421 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9422
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009423 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9424 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9425 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009426 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009427 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai49535502009-06-30 15:28:30 +02009428 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009429 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009430 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009431 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9432 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9433 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9434 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9435 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9436 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009437 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009438 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9439 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9440 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009441 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009442 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009443 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9444 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009445 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009446 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009447 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009448 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009449 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009450 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009451 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009452 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009453 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009454
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009455 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009456 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009457 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9458 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309459 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009460 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009461 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai49535502009-06-30 15:28:30 +02009462 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009463 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009464 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009465 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009466 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009467 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009468 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009469 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009470 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9471 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009472 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009473 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009474 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009475 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009476 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai49535502009-06-30 15:28:30 +02009477
Jiang zhe17bba1b2008-06-04 12:11:07 +02009478 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9479 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009480 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009481 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9482 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9483 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009484 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai49535502009-06-30 15:28:30 +02009485
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009486 {}
9487};
9488
Takashi Iwai49535502009-06-30 15:28:30 +02009489/* codec SSID table for Intel Mac */
9490static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9491 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9492 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9493 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9494 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9495 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9496 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9497 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009498 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009499 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009500 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009501 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai49535502009-06-30 15:28:30 +02009502 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9503 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9504 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009505 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai49535502009-06-30 15:28:30 +02009506 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009507 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009508 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9509 * so apparently no perfect solution yet
Takashi Iwai49535502009-06-30 15:28:30 +02009510 */
9511 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009512 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009513 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai49535502009-06-30 15:28:30 +02009514 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009515};
9516
Takashi Iwai49535502009-06-30 15:28:30 +02009517static struct alc_config_preset alc882_presets[] = {
9518 [ALC882_3ST_DIG] = {
9519 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009520 .init_verbs = { alc882_base_init_verbs,
9521 alc882_adc1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009522 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9523 .dac_nids = alc882_dac_nids,
9524 .dig_out_nid = ALC882_DIGOUT_NID,
9525 .dig_in_nid = ALC882_DIGIN_NID,
9526 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9527 .channel_mode = alc882_ch_modes,
9528 .need_dac_fix = 1,
9529 .input_mux = &alc882_capture_source,
9530 },
9531 [ALC882_6ST_DIG] = {
9532 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009533 .init_verbs = { alc882_base_init_verbs,
9534 alc882_adc1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009535 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9536 .dac_nids = alc882_dac_nids,
9537 .dig_out_nid = ALC882_DIGOUT_NID,
9538 .dig_in_nid = ALC882_DIGIN_NID,
9539 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9540 .channel_mode = alc882_sixstack_modes,
9541 .input_mux = &alc882_capture_source,
9542 },
9543 [ALC882_ARIMA] = {
9544 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009545 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9546 alc882_eapd_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009547 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9548 .dac_nids = alc882_dac_nids,
9549 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9550 .channel_mode = alc882_sixstack_modes,
9551 .input_mux = &alc882_capture_source,
9552 },
9553 [ALC882_W2JC] = {
9554 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009555 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9556 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai49535502009-06-30 15:28:30 +02009557 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9558 .dac_nids = alc882_dac_nids,
9559 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9560 .channel_mode = alc880_threestack_modes,
9561 .need_dac_fix = 1,
9562 .input_mux = &alc882_capture_source,
9563 .dig_out_nid = ALC882_DIGOUT_NID,
9564 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009565 [ALC885_MBA21] = {
9566 .mixers = { alc885_mba21_mixer },
9567 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9568 .num_dacs = 2,
9569 .dac_nids = alc882_dac_nids,
9570 .channel_mode = alc885_mba21_ch_modes,
9571 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9572 .input_mux = &alc882_capture_source,
9573 .unsol_event = alc_automute_amp_unsol_event,
9574 .setup = alc885_mba21_setup,
9575 .init_hook = alc_automute_amp,
9576 },
Takashi Iwai49535502009-06-30 15:28:30 +02009577 [ALC885_MBP3] = {
9578 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9579 .init_verbs = { alc885_mbp3_init_verbs,
9580 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009581 .num_dacs = 2,
Takashi Iwai49535502009-06-30 15:28:30 +02009582 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009583 .hp_nid = 0x04,
9584 .channel_mode = alc885_mbp_4ch_modes,
9585 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai49535502009-06-30 15:28:30 +02009586 .input_mux = &alc882_capture_source,
9587 .dig_out_nid = ALC882_DIGOUT_NID,
9588 .dig_in_nid = ALC882_DIGIN_NID,
9589 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009590 .setup = alc885_mbp3_setup,
9591 .init_hook = alc_automute_amp,
Takashi Iwai49535502009-06-30 15:28:30 +02009592 },
9593 [ALC885_MB5] = {
9594 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9595 .init_verbs = { alc885_mb5_init_verbs,
9596 alc880_gpio1_init_verbs },
9597 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9598 .dac_nids = alc882_dac_nids,
9599 .channel_mode = alc885_mb5_6ch_modes,
9600 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9601 .input_mux = &mb5_capture_source,
9602 .dig_out_nid = ALC882_DIGOUT_NID,
9603 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009604 .unsol_event = alc_automute_amp_unsol_event,
9605 .setup = alc885_mb5_setup,
9606 .init_hook = alc_automute_amp,
Takashi Iwai49535502009-06-30 15:28:30 +02009607 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009608 [ALC885_MACMINI3] = {
9609 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9610 .init_verbs = { alc885_macmini3_init_verbs,
9611 alc880_gpio1_init_verbs },
9612 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9613 .dac_nids = alc882_dac_nids,
9614 .channel_mode = alc885_macmini3_6ch_modes,
9615 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9616 .input_mux = &macmini3_capture_source,
9617 .dig_out_nid = ALC882_DIGOUT_NID,
9618 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009619 .unsol_event = alc_automute_amp_unsol_event,
9620 .setup = alc885_macmini3_setup,
9621 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009622 },
Takashi Iwai49535502009-06-30 15:28:30 +02009623 [ALC885_MACPRO] = {
9624 .mixers = { alc882_macpro_mixer },
9625 .init_verbs = { alc882_macpro_init_verbs },
9626 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9627 .dac_nids = alc882_dac_nids,
9628 .dig_out_nid = ALC882_DIGOUT_NID,
9629 .dig_in_nid = ALC882_DIGIN_NID,
9630 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9631 .channel_mode = alc882_ch_modes,
9632 .input_mux = &alc882_capture_source,
9633 .init_hook = alc885_macpro_init_hook,
9634 },
9635 [ALC885_IMAC24] = {
9636 .mixers = { alc885_imac24_mixer },
9637 .init_verbs = { alc885_imac24_init_verbs },
9638 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9639 .dac_nids = alc882_dac_nids,
9640 .dig_out_nid = ALC882_DIGOUT_NID,
9641 .dig_in_nid = ALC882_DIGIN_NID,
9642 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9643 .channel_mode = alc882_ch_modes,
9644 .input_mux = &alc882_capture_source,
9645 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009646 .setup = alc885_imac24_setup,
Takashi Iwai49535502009-06-30 15:28:30 +02009647 .init_hook = alc885_imac24_init_hook,
9648 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009649 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009650 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009651 .init_verbs = { alc885_imac91_init_verbs,
9652 alc880_gpio1_init_verbs },
9653 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9654 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009655 .channel_mode = alc885_mba21_ch_modes,
9656 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9657 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009658 .dig_out_nid = ALC882_DIGOUT_NID,
9659 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009660 .unsol_event = alc_automute_amp_unsol_event,
9661 .setup = alc885_imac91_setup,
9662 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009663 },
Takashi Iwai49535502009-06-30 15:28:30 +02009664 [ALC882_TARGA] = {
9665 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009666 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009667 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai49535502009-06-30 15:28:30 +02009668 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9669 .dac_nids = alc882_dac_nids,
9670 .dig_out_nid = ALC882_DIGOUT_NID,
9671 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9672 .adc_nids = alc882_adc_nids,
9673 .capsrc_nids = alc882_capsrc_nids,
9674 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9675 .channel_mode = alc882_3ST_6ch_modes,
9676 .need_dac_fix = 1,
9677 .input_mux = &alc882_capture_source,
9678 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009679 .setup = alc882_targa_setup,
9680 .init_hook = alc882_targa_automute,
Takashi Iwai49535502009-06-30 15:28:30 +02009681 },
9682 [ALC882_ASUS_A7J] = {
9683 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009684 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9685 alc882_asus_a7j_verbs},
Takashi Iwai49535502009-06-30 15:28:30 +02009686 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9687 .dac_nids = alc882_dac_nids,
9688 .dig_out_nid = ALC882_DIGOUT_NID,
9689 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9690 .adc_nids = alc882_adc_nids,
9691 .capsrc_nids = alc882_capsrc_nids,
9692 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9693 .channel_mode = alc882_3ST_6ch_modes,
9694 .need_dac_fix = 1,
9695 .input_mux = &alc882_capture_source,
9696 },
9697 [ALC882_ASUS_A7M] = {
9698 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009699 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9700 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai49535502009-06-30 15:28:30 +02009701 alc882_asus_a7m_verbs },
9702 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9703 .dac_nids = alc882_dac_nids,
9704 .dig_out_nid = ALC882_DIGOUT_NID,
9705 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9706 .channel_mode = alc880_threestack_modes,
9707 .need_dac_fix = 1,
9708 .input_mux = &alc882_capture_source,
9709 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009710 [ALC883_3ST_2ch_DIG] = {
9711 .mixers = { alc883_3ST_2ch_mixer },
9712 .init_verbs = { alc883_init_verbs },
9713 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9714 .dac_nids = alc883_dac_nids,
9715 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009716 .dig_in_nid = ALC883_DIGIN_NID,
9717 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9718 .channel_mode = alc883_3ST_2ch_modes,
9719 .input_mux = &alc883_capture_source,
9720 },
9721 [ALC883_3ST_6ch_DIG] = {
9722 .mixers = { alc883_3ST_6ch_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,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009727 .dig_in_nid = ALC883_DIGIN_NID,
9728 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9729 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009730 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009731 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009732 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009733 [ALC883_3ST_6ch] = {
9734 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9735 .init_verbs = { alc883_init_verbs },
9736 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9737 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009738 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9739 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009740 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009741 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009742 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009743 [ALC883_3ST_6ch_INTEL] = {
9744 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9745 .init_verbs = { alc883_init_verbs },
9746 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9747 .dac_nids = alc883_dac_nids,
9748 .dig_out_nid = ALC883_DIGOUT_NID,
9749 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009750 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009751 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9752 .channel_mode = alc883_3ST_6ch_intel_modes,
9753 .need_dac_fix = 1,
9754 .input_mux = &alc883_3stack_6ch_intel,
9755 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009756 [ALC889A_INTEL] = {
9757 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009758 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9759 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009760 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9761 .dac_nids = alc883_dac_nids,
9762 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9763 .adc_nids = alc889_adc_nids,
9764 .dig_out_nid = ALC883_DIGOUT_NID,
9765 .dig_in_nid = ALC883_DIGIN_NID,
9766 .slave_dig_outs = alc883_slave_dig_outs,
9767 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9768 .channel_mode = alc889_8ch_intel_modes,
9769 .capsrc_nids = alc889_capsrc_nids,
9770 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009771 .setup = alc889_automute_setup,
9772 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009773 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009774 .need_dac_fix = 1,
9775 },
9776 [ALC889_INTEL] = {
9777 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9778 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009779 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009780 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9781 .dac_nids = alc883_dac_nids,
9782 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9783 .adc_nids = alc889_adc_nids,
9784 .dig_out_nid = ALC883_DIGOUT_NID,
9785 .dig_in_nid = ALC883_DIGIN_NID,
9786 .slave_dig_outs = alc883_slave_dig_outs,
9787 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9788 .channel_mode = alc889_8ch_intel_modes,
9789 .capsrc_nids = alc889_capsrc_nids,
9790 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009791 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009792 .init_hook = alc889_intel_init_hook,
9793 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009794 .need_dac_fix = 1,
9795 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009796 [ALC883_6ST_DIG] = {
9797 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9798 .init_verbs = { alc883_init_verbs },
9799 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9800 .dac_nids = alc883_dac_nids,
9801 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009802 .dig_in_nid = ALC883_DIGIN_NID,
9803 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9804 .channel_mode = alc883_sixstack_modes,
9805 .input_mux = &alc883_capture_source,
9806 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009807 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009808 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009809 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9810 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009811 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9812 .dac_nids = alc883_dac_nids,
9813 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009814 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9815 .channel_mode = alc883_3ST_6ch_modes,
9816 .need_dac_fix = 1,
9817 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009818 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009819 .setup = alc882_targa_setup,
9820 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009821 },
9822 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009823 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009824 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9825 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009826 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9827 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009828 .adc_nids = alc883_adc_nids_alt,
9829 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009830 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009831 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009832 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9833 .channel_mode = alc883_3ST_2ch_modes,
9834 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009835 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009836 .setup = alc882_targa_setup,
9837 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009838 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009839 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009840 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9841 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009842 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009843 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009844 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9845 .dac_nids = alc883_dac_nids,
9846 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9847 .adc_nids = alc883_adc_nids_rev,
9848 .capsrc_nids = alc883_capsrc_nids_rev,
9849 .dig_out_nid = ALC883_DIGOUT_NID,
9850 .dig_in_nid = ALC883_DIGIN_NID,
9851 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9852 .channel_mode = alc883_4ST_8ch_modes,
9853 .need_dac_fix = 1,
9854 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009855 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009856 .setup = alc882_targa_setup,
9857 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009858 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009859 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009860 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009861 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9862 * and the headphone jack. Turn this on and rely on the
9863 * standard mute methods whenever the user wants to turn
9864 * these outputs off.
9865 */
9866 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9867 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9868 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009869 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9870 .channel_mode = alc883_3ST_2ch_modes,
9871 .input_mux = &alc883_capture_source,
9872 },
Tobin Davis2880a862007-08-07 11:50:26 +02009873 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009874 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009875 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009876 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9877 .dac_nids = alc883_dac_nids,
9878 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009879 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9880 .channel_mode = alc883_3ST_2ch_modes,
9881 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009882 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009883 .setup = alc883_acer_aspire_setup,
9884 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009885 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009886 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009887 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009888 alc883_chmode_mixer },
9889 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9890 alc888_acer_aspire_4930g_verbs },
9891 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9892 .dac_nids = alc883_dac_nids,
9893 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9894 .adc_nids = alc883_adc_nids_rev,
9895 .capsrc_nids = alc883_capsrc_nids_rev,
9896 .dig_out_nid = ALC883_DIGOUT_NID,
9897 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9898 .channel_mode = alc883_3ST_6ch_modes,
9899 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009900 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009901 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009902 ARRAY_SIZE(alc888_2_capture_sources),
9903 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009904 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009905 .setup = alc888_acer_aspire_4930g_setup,
9906 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009907 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009908 [ALC888_ACER_ASPIRE_6530G] = {
9909 .mixers = { alc888_acer_aspire_6530_mixer },
9910 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9911 alc888_acer_aspire_6530g_verbs },
9912 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9913 .dac_nids = alc883_dac_nids,
9914 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9915 .adc_nids = alc883_adc_nids_rev,
9916 .capsrc_nids = alc883_capsrc_nids_rev,
9917 .dig_out_nid = ALC883_DIGOUT_NID,
9918 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9919 .channel_mode = alc883_3ST_2ch_modes,
9920 .num_mux_defs =
9921 ARRAY_SIZE(alc888_2_capture_sources),
9922 .input_mux = alc888_acer_aspire_6530_sources,
9923 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009924 .setup = alc888_acer_aspire_6530g_setup,
9925 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009926 },
Hector Martin3b315d72009-06-02 10:54:19 +02009927 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009928 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009929 alc883_chmode_mixer },
9930 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009931 alc889_acer_aspire_8930g_verbs,
9932 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009933 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9934 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009935 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9936 .adc_nids = alc889_adc_nids,
9937 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009938 .dig_out_nid = ALC883_DIGOUT_NID,
9939 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9940 .channel_mode = alc883_3ST_6ch_modes,
9941 .need_dac_fix = 1,
9942 .const_channel_count = 6,
9943 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009944 ARRAY_SIZE(alc889_capture_sources),
9945 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009946 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009947 .setup = alc889_acer_aspire_8930g_setup,
9948 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009949#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009950 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009951#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009952 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009953 [ALC888_ACER_ASPIRE_7730G] = {
9954 .mixers = { alc883_3ST_6ch_mixer,
9955 alc883_chmode_mixer },
9956 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9957 alc888_acer_aspire_7730G_verbs },
9958 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9959 .dac_nids = alc883_dac_nids,
9960 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9961 .adc_nids = alc883_adc_nids_rev,
9962 .capsrc_nids = alc883_capsrc_nids_rev,
9963 .dig_out_nid = ALC883_DIGOUT_NID,
9964 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9965 .channel_mode = alc883_3ST_6ch_modes,
9966 .need_dac_fix = 1,
9967 .const_channel_count = 6,
9968 .input_mux = &alc883_capture_source,
9969 .unsol_event = alc_automute_amp_unsol_event,
9970 .setup = alc888_acer_aspire_6530g_setup,
9971 .init_hook = alc_automute_amp,
9972 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009973 [ALC883_MEDION] = {
9974 .mixers = { alc883_fivestack_mixer,
9975 alc883_chmode_mixer },
9976 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009977 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009978 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9979 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009980 .adc_nids = alc883_adc_nids_alt,
9981 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009982 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009983 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9984 .channel_mode = alc883_sixstack_modes,
9985 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009986 },
Kailang Yang272a5272007-05-14 11:00:38 +02009987 [ALC883_MEDION_MD2] = {
9988 .mixers = { alc883_medion_md2_mixer},
9989 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9990 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9991 .dac_nids = alc883_dac_nids,
9992 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009993 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9994 .channel_mode = alc883_3ST_2ch_modes,
9995 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009996 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009997 .setup = alc883_medion_md2_setup,
9998 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009999 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010000 [ALC883_MEDION_WIM2160] = {
10001 .mixers = { alc883_medion_wim2160_mixer },
10002 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10003 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10004 .dac_nids = alc883_dac_nids,
10005 .dig_out_nid = ALC883_DIGOUT_NID,
10006 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10007 .adc_nids = alc883_adc_nids,
10008 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10009 .channel_mode = alc883_3ST_2ch_modes,
10010 .input_mux = &alc883_capture_source,
10011 .unsol_event = alc_automute_amp_unsol_event,
10012 .setup = alc883_medion_wim2160_setup,
10013 .init_hook = alc_automute_amp,
10014 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010015 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010016 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010017 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10018 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10019 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010020 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10021 .channel_mode = alc883_3ST_2ch_modes,
10022 .input_mux = &alc883_capture_source,
10023 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010024 [ALC883_CLEVO_M540R] = {
10025 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10026 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10027 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10028 .dac_nids = alc883_dac_nids,
10029 .dig_out_nid = ALC883_DIGOUT_NID,
10030 .dig_in_nid = ALC883_DIGIN_NID,
10031 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10032 .channel_mode = alc883_3ST_6ch_clevo_modes,
10033 .need_dac_fix = 1,
10034 .input_mux = &alc883_capture_source,
10035 /* This machine has the hardware HP auto-muting, thus
10036 * we need no software mute via unsol event
10037 */
10038 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010039 [ALC883_CLEVO_M720] = {
10040 .mixers = { alc883_clevo_m720_mixer },
10041 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010042 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10043 .dac_nids = alc883_dac_nids,
10044 .dig_out_nid = ALC883_DIGOUT_NID,
10045 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10046 .channel_mode = alc883_3ST_2ch_modes,
10047 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010048 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010049 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010050 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010051 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010052 [ALC883_LENOVO_101E_2ch] = {
10053 .mixers = { alc883_lenovo_101e_2ch_mixer},
10054 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10055 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10056 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010057 .adc_nids = alc883_adc_nids_alt,
10058 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010059 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010060 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10061 .channel_mode = alc883_3ST_2ch_modes,
10062 .input_mux = &alc883_lenovo_101e_capture_source,
10063 .unsol_event = alc883_lenovo_101e_unsol_event,
10064 .init_hook = alc883_lenovo_101e_all_automute,
10065 },
Kailang Yang272a5272007-05-14 11:00:38 +020010066 [ALC883_LENOVO_NB0763] = {
10067 .mixers = { alc883_lenovo_nb0763_mixer },
10068 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10069 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10070 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010071 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10072 .channel_mode = alc883_3ST_2ch_modes,
10073 .need_dac_fix = 1,
10074 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010075 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010076 .setup = alc883_medion_md2_setup,
10077 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010078 },
10079 [ALC888_LENOVO_MS7195_DIG] = {
10080 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10081 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10082 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10083 .dac_nids = alc883_dac_nids,
10084 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010085 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10086 .channel_mode = alc883_3ST_6ch_modes,
10087 .need_dac_fix = 1,
10088 .input_mux = &alc883_capture_source,
10089 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10090 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010091 },
10092 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010093 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010094 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10095 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10096 .dac_nids = alc883_dac_nids,
10097 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010098 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10099 .channel_mode = alc883_3ST_2ch_modes,
10100 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010101 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010102 .setup = alc883_haier_w66_setup,
10103 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010104 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010105 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010106 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010107 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010108 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10109 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010110 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10111 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010112 .need_dac_fix = 1,
10113 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010114 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010115 .setup = alc888_3st_hp_setup,
10116 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010117 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010118 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010119 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010120 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10121 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10122 .dac_nids = alc883_dac_nids,
10123 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010124 .dig_in_nid = ALC883_DIGIN_NID,
10125 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10126 .channel_mode = alc883_sixstack_modes,
10127 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010128 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010129 .setup = alc888_6st_dell_setup,
10130 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010131 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010132 [ALC883_MITAC] = {
10133 .mixers = { alc883_mitac_mixer },
10134 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10135 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10136 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010137 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10138 .channel_mode = alc883_3ST_2ch_modes,
10139 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010140 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010141 .setup = alc883_mitac_setup,
10142 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010143 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010144 [ALC883_FUJITSU_PI2515] = {
10145 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10146 .init_verbs = { alc883_init_verbs,
10147 alc883_2ch_fujitsu_pi2515_verbs},
10148 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10149 .dac_nids = alc883_dac_nids,
10150 .dig_out_nid = ALC883_DIGOUT_NID,
10151 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10152 .channel_mode = alc883_3ST_2ch_modes,
10153 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010154 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010155 .setup = alc883_2ch_fujitsu_pi2515_setup,
10156 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010157 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010158 [ALC888_FUJITSU_XA3530] = {
10159 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10160 .init_verbs = { alc883_init_verbs,
10161 alc888_fujitsu_xa3530_verbs },
10162 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10163 .dac_nids = alc883_dac_nids,
10164 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10165 .adc_nids = alc883_adc_nids_rev,
10166 .capsrc_nids = alc883_capsrc_nids_rev,
10167 .dig_out_nid = ALC883_DIGOUT_NID,
10168 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10169 .channel_mode = alc888_4ST_8ch_intel_modes,
10170 .num_mux_defs =
10171 ARRAY_SIZE(alc888_2_capture_sources),
10172 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010173 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010174 .setup = alc888_fujitsu_xa3530_setup,
10175 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010176 },
Kailang Yange2757d52008-08-26 13:17:46 +020010177 [ALC888_LENOVO_SKY] = {
10178 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10179 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10180 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10181 .dac_nids = alc883_dac_nids,
10182 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010183 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10184 .channel_mode = alc883_sixstack_modes,
10185 .need_dac_fix = 1,
10186 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010187 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010188 .setup = alc888_lenovo_sky_setup,
10189 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010190 },
10191 [ALC888_ASUS_M90V] = {
10192 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10193 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10194 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10195 .dac_nids = alc883_dac_nids,
10196 .dig_out_nid = ALC883_DIGOUT_NID,
10197 .dig_in_nid = ALC883_DIGIN_NID,
10198 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10199 .channel_mode = alc883_3ST_6ch_modes,
10200 .need_dac_fix = 1,
10201 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010202 .unsol_event = alc_sku_unsol_event,
10203 .setup = alc883_mode2_setup,
10204 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010205 },
10206 [ALC888_ASUS_EEE1601] = {
10207 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010208 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010209 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10210 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10211 .dac_nids = alc883_dac_nids,
10212 .dig_out_nid = ALC883_DIGOUT_NID,
10213 .dig_in_nid = ALC883_DIGIN_NID,
10214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10215 .channel_mode = alc883_3ST_2ch_modes,
10216 .need_dac_fix = 1,
10217 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010218 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010219 .init_hook = alc883_eee1601_inithook,
10220 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010221 [ALC1200_ASUS_P5Q] = {
10222 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10223 .init_verbs = { alc883_init_verbs },
10224 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10225 .dac_nids = alc883_dac_nids,
10226 .dig_out_nid = ALC1200_DIGOUT_NID,
10227 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010228 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010229 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10230 .channel_mode = alc883_sixstack_modes,
10231 .input_mux = &alc883_capture_source,
10232 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010233 [ALC889A_MB31] = {
10234 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10235 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10236 alc880_gpio1_init_verbs },
10237 .adc_nids = alc883_adc_nids,
10238 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010239 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010240 .dac_nids = alc883_dac_nids,
10241 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10242 .channel_mode = alc889A_mb31_6ch_modes,
10243 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10244 .input_mux = &alc889A_mb31_capture_source,
10245 .dig_out_nid = ALC883_DIGOUT_NID,
10246 .unsol_event = alc889A_mb31_unsol_event,
10247 .init_hook = alc889A_mb31_automute,
10248 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010249 [ALC883_SONY_VAIO_TT] = {
10250 .mixers = { alc883_vaiott_mixer },
10251 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10252 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10253 .dac_nids = alc883_dac_nids,
10254 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10255 .channel_mode = alc883_3ST_2ch_modes,
10256 .input_mux = &alc883_capture_source,
10257 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010258 .setup = alc883_vaiott_setup,
10259 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010260 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010261};
10262
10263
10264/*
Takashi Iwai49535502009-06-30 15:28:30 +020010265 * Pin config fixes
10266 */
10267enum {
10268 PINFIX_ABIT_AW9D_MAX
10269};
10270
10271static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10272 { 0x15, 0x01080104 }, /* side */
10273 { 0x16, 0x01011012 }, /* rear */
10274 { 0x17, 0x01016011 }, /* clfe */
10275 { }
10276};
10277
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010278static const struct alc_fixup alc882_fixups[] = {
10279 [PINFIX_ABIT_AW9D_MAX] = {
10280 .pins = alc882_abit_aw9d_pinfix
10281 },
Takashi Iwai49535502009-06-30 15:28:30 +020010282};
10283
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010284static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai49535502009-06-30 15:28:30 +020010285 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10286 {}
10287};
10288
10289/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010290 * BIOS auto configuration
10291 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010292static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10293 const struct auto_pin_cfg *cfg)
10294{
10295 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10296}
10297
Takashi Iwai49535502009-06-30 15:28:30 +020010298static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010299 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010300 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010301{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010302 int idx;
10303
Takashi Iwai489008c2010-04-07 09:06:00 +020010304 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010305 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010306
Takashi Iwai489008c2010-04-07 09:06:00 +020010307 if (dac == 0x25)
10308 idx = 4;
10309 else if (dac >= 0x02 && dac <= 0x05)
10310 idx = dac - 2;
10311 else
10312 return;
10313 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010314}
10315
Takashi Iwai49535502009-06-30 15:28:30 +020010316static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010317{
10318 struct alc_spec *spec = codec->spec;
10319 int i;
10320
10321 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010322 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010323 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010324 if (nid)
Takashi Iwai49535502009-06-30 15:28:30 +020010325 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010326 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010327 }
10328}
10329
Takashi Iwai49535502009-06-30 15:28:30 +020010330static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010331{
10332 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010333 hda_nid_t pin, dac;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010334
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010335 pin = spec->autocfg.hp_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010336 if (pin) {
10337 dac = spec->multiout.hp_nid;
10338 if (!dac)
10339 dac = spec->multiout.dac_nids[0]; /* to front */
10340 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10341 }
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010342 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010343 if (pin) {
10344 dac = spec->multiout.extra_out_nid[0];
10345 if (!dac)
10346 dac = spec->multiout.dac_nids[0]; /* to front */
10347 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10348 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010349}
10350
Takashi Iwai49535502009-06-30 15:28:30 +020010351static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010352{
10353 struct alc_spec *spec = codec->spec;
10354 int i;
10355
10356 for (i = 0; i < AUTO_PIN_LAST; i++) {
10357 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai49535502009-06-30 15:28:30 +020010358 if (!nid)
10359 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010360 alc_set_input_pin(codec, nid, i);
Takashi Iwai49535502009-06-30 15:28:30 +020010361 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10362 snd_hda_codec_write(codec, nid, 0,
10363 AC_VERB_SET_AMP_GAIN_MUTE,
10364 AMP_OUT_MUTE);
10365 }
10366}
10367
10368static void alc882_auto_init_input_src(struct hda_codec *codec)
10369{
10370 struct alc_spec *spec = codec->spec;
10371 int c;
10372
10373 for (c = 0; c < spec->num_adc_nids; c++) {
10374 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10375 hda_nid_t nid = spec->capsrc_nids[c];
10376 unsigned int mux_idx;
10377 const struct hda_input_mux *imux;
10378 int conns, mute, idx, item;
10379
10380 conns = snd_hda_get_connections(codec, nid, conn_list,
10381 ARRAY_SIZE(conn_list));
10382 if (conns < 0)
10383 continue;
10384 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10385 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010386 if (!imux->num_items && mux_idx > 0)
10387 imux = &spec->input_mux[0];
Takashi Iwai49535502009-06-30 15:28:30 +020010388 for (idx = 0; idx < conns; idx++) {
10389 /* if the current connection is the selected one,
10390 * unmute it as default - otherwise mute it
10391 */
10392 mute = AMP_IN_MUTE(idx);
10393 for (item = 0; item < imux->num_items; item++) {
10394 if (imux->items[item].index == idx) {
10395 if (spec->cur_mux[c] == item)
10396 mute = AMP_IN_UNMUTE(idx);
10397 break;
10398 }
10399 }
10400 /* check if we have a selector or mixer
10401 * we could check for the widget type instead, but
10402 * just check for Amp-In presence (in case of mixer
10403 * without amp-in there is something wrong, this
10404 * function shouldn't be used or capsrc nid is wrong)
10405 */
10406 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010407 snd_hda_codec_write(codec, nid, 0,
10408 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai49535502009-06-30 15:28:30 +020010409 mute);
10410 else if (mute != AMP_IN_MUTE(idx))
10411 snd_hda_codec_write(codec, nid, 0,
10412 AC_VERB_SET_CONNECT_SEL,
10413 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010414 }
10415 }
10416}
10417
Takashi Iwai49535502009-06-30 15:28:30 +020010418/* add mic boosts if needed */
10419static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010420{
10421 struct alc_spec *spec = codec->spec;
Takashi Iwai49535502009-06-30 15:28:30 +020010422 int err;
10423 hda_nid_t nid;
10424
10425 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10426 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10427 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10428 "Mic Boost",
10429 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10430 if (err < 0)
10431 return err;
10432 }
10433 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10434 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10435 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10436 "Front Mic Boost",
10437 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10438 if (err < 0)
10439 return err;
10440 }
10441 return 0;
10442}
10443
10444/* almost identical with ALC880 parser... */
10445static int alc882_parse_auto_config(struct hda_codec *codec)
10446{
10447 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010448 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10449 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010450
Takashi Iwai05f5f472009-08-25 13:10:18 +020010451 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10452 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010453 if (err < 0)
10454 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010455 if (!spec->autocfg.line_outs)
10456 return 0; /* can't find valid BIOS pin config */
10457
10458 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10459 if (err < 0)
10460 return err;
10461 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10462 if (err < 0)
10463 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010464 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10465 "Headphone");
10466 if (err < 0)
10467 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010468 err = alc880_auto_create_extra_out(spec,
10469 spec->autocfg.speaker_pins[0],
10470 "Speaker");
10471 if (err < 0)
10472 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010473 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10474 if (err < 0)
10475 return err;
10476
10477 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10478
10479 /* check multiple SPDIF-out (for recent codecs) */
10480 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10481 hda_nid_t dig_nid;
10482 err = snd_hda_get_connections(codec,
10483 spec->autocfg.dig_out_pins[i],
10484 &dig_nid, 1);
10485 if (err < 0)
10486 continue;
10487 if (!i)
10488 spec->multiout.dig_out_nid = dig_nid;
10489 else {
10490 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010491 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010492 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010493 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010494 }
10495 }
10496 if (spec->autocfg.dig_in_pin)
10497 spec->dig_in_nid = ALC880_DIGIN_NID;
10498
10499 if (spec->kctls.list)
10500 add_mixer(spec, spec->kctls.list);
10501
10502 add_verb(spec, alc883_auto_init_verbs);
10503 /* if ADC 0x07 is available, initialize it, too */
10504 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10505 add_verb(spec, alc882_adc1_init_verbs);
10506
10507 spec->num_mux_defs = 1;
10508 spec->input_mux = &spec->private_imux[0];
10509
Kailang Yang6227cdc2010-02-25 08:36:52 +010010510 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010511
10512 err = alc_auto_add_mic_boost(codec);
10513 if (err < 0)
10514 return err;
10515
Takashi Iwai776e1842007-08-29 15:07:11 +020010516 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010517}
10518
10519/* additional initialization for auto-configuration model */
Takashi Iwai49535502009-06-30 15:28:30 +020010520static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010521{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010522 struct alc_spec *spec = codec->spec;
Takashi Iwai49535502009-06-30 15:28:30 +020010523 alc882_auto_init_multi_out(codec);
10524 alc882_auto_init_hp_out(codec);
10525 alc882_auto_init_analog_input(codec);
10526 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010527 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010528 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010529}
10530
Takashi Iwai49535502009-06-30 15:28:30 +020010531static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010532{
10533 struct alc_spec *spec;
10534 int err, board_config;
10535
10536 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10537 if (spec == NULL)
10538 return -ENOMEM;
10539
10540 codec->spec = spec;
10541
Kailang Yangda00c242010-03-19 11:23:45 +010010542 alc_auto_parse_customize_define(codec);
10543
Takashi Iwai49535502009-06-30 15:28:30 +020010544 switch (codec->vendor_id) {
10545 case 0x10ec0882:
10546 case 0x10ec0885:
10547 break;
10548 default:
10549 /* ALC883 and variants */
10550 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10551 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010552 }
10553
Takashi Iwai49535502009-06-30 15:28:30 +020010554 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10555 alc882_models,
10556 alc882_cfg_tbl);
10557
10558 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10559 board_config = snd_hda_check_board_codec_sid_config(codec,
10560 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10561
10562 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010563 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai49535502009-06-30 15:28:30 +020010564 codec->chip_name);
10565 board_config = ALC882_AUTO;
10566 }
10567
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010568 if (board_config == ALC882_AUTO)
10569 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai49535502009-06-30 15:28:30 +020010570
10571 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010572 /* automatic parse from the BIOS config */
Takashi Iwai49535502009-06-30 15:28:30 +020010573 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010574 if (err < 0) {
10575 alc_free(codec);
10576 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010577 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010578 printk(KERN_INFO
10579 "hda_codec: Cannot set up configuration "
10580 "from BIOS. Using base mode...\n");
Takashi Iwai49535502009-06-30 15:28:30 +020010581 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010582 }
10583 }
10584
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010585 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010586 err = snd_hda_attach_beep_device(codec, 0x1);
10587 if (err < 0) {
10588 alc_free(codec);
10589 return err;
10590 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010591 }
10592
Takashi Iwai49535502009-06-30 15:28:30 +020010593 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010594 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010595
Takashi Iwai49535502009-06-30 15:28:30 +020010596 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10597 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10598 /* FIXME: setup DAC5 */
10599 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10600 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10601
10602 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10603 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10604
Takashi Iwai49535502009-06-30 15:28:30 +020010605 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010606 int i, j;
Takashi Iwai49535502009-06-30 15:28:30 +020010607 spec->num_adc_nids = 0;
10608 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010609 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai49535502009-06-30 15:28:30 +020010610 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010611 hda_nid_t items[16];
Takashi Iwai49535502009-06-30 15:28:30 +020010612 hda_nid_t nid = alc882_adc_nids[i];
10613 unsigned int wcap = get_wcaps(codec, nid);
10614 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010615 wcap = get_wcaps_type(wcap);
Takashi Iwai49535502009-06-30 15:28:30 +020010616 if (wcap != AC_WID_AUD_IN)
10617 continue;
10618 spec->private_adc_nids[spec->num_adc_nids] = nid;
10619 err = snd_hda_get_connections(codec, nid, &cap, 1);
10620 if (err < 0)
10621 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010622 err = snd_hda_get_connections(codec, cap, items,
10623 ARRAY_SIZE(items));
10624 if (err < 0)
10625 continue;
10626 for (j = 0; j < imux->num_items; j++)
10627 if (imux->items[j].index >= err)
10628 break;
10629 if (j < imux->num_items)
10630 continue;
Takashi Iwai49535502009-06-30 15:28:30 +020010631 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10632 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010633 }
Takashi Iwai49535502009-06-30 15:28:30 +020010634 spec->adc_nids = spec->private_adc_nids;
10635 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010636 }
10637
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010638 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010639
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010640 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010641 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010642
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010643 if (board_config == ALC882_AUTO)
10644 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10645
Takashi Iwai2134ea42008-01-10 16:53:55 +010010646 spec->vmaster_nid = 0x0c;
10647
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010648 codec->patch_ops = alc_patch_ops;
Takashi Iwai49535502009-06-30 15:28:30 +020010649 if (board_config == ALC882_AUTO)
10650 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010651#ifdef CONFIG_SND_HDA_POWER_SAVE
10652 if (!spec->loopback.amplist)
Takashi Iwai49535502009-06-30 15:28:30 +020010653 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010654#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010655
10656 return 0;
10657}
10658
Takashi Iwai49535502009-06-30 15:28:30 +020010659
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010660/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010661 * ALC262 support
10662 */
10663
10664#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10665#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10666
10667#define alc262_dac_nids alc260_dac_nids
10668#define alc262_adc_nids alc882_adc_nids
10669#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010670#define alc262_capsrc_nids alc882_capsrc_nids
10671#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010672
10673#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010674#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010675
Kailang Yang4e555fe2008-08-26 13:05:55 +020010676static hda_nid_t alc262_dmic_adc_nids[1] = {
10677 /* ADC0 */
10678 0x09
10679};
10680
10681static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10682
Kailang Yangdf694da2005-12-05 19:42:22 +010010683static struct snd_kcontrol_new alc262_base_mixer[] = {
10684 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10685 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10686 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10687 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10688 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10689 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10690 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10691 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010692 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010693 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10694 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010695 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010696 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10698 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10699 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010700 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010701};
10702
Takashi Iwaice875f02008-01-28 18:17:43 +010010703/* update HP, line and mono-out pins according to the master switch */
10704static void alc262_hp_master_update(struct hda_codec *codec)
10705{
10706 struct alc_spec *spec = codec->spec;
10707 int val = spec->master_sw;
10708
10709 /* HP & line-out */
10710 snd_hda_codec_write_cache(codec, 0x1b, 0,
10711 AC_VERB_SET_PIN_WIDGET_CONTROL,
10712 val ? PIN_HP : 0);
10713 snd_hda_codec_write_cache(codec, 0x15, 0,
10714 AC_VERB_SET_PIN_WIDGET_CONTROL,
10715 val ? PIN_HP : 0);
10716 /* mono (speaker) depending on the HP jack sense */
10717 val = val && !spec->jack_present;
10718 snd_hda_codec_write_cache(codec, 0x16, 0,
10719 AC_VERB_SET_PIN_WIDGET_CONTROL,
10720 val ? PIN_OUT : 0);
10721}
10722
10723static void alc262_hp_bpc_automute(struct hda_codec *codec)
10724{
10725 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010726
10727 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010728 alc262_hp_master_update(codec);
10729}
10730
10731static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10732{
10733 if ((res >> 26) != ALC880_HP_EVENT)
10734 return;
10735 alc262_hp_bpc_automute(codec);
10736}
10737
10738static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10739{
10740 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010741
10742 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010743 alc262_hp_master_update(codec);
10744}
10745
10746static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10747 unsigned int res)
10748{
10749 if ((res >> 26) != ALC880_HP_EVENT)
10750 return;
10751 alc262_hp_wildwest_automute(codec);
10752}
10753
Takashi Iwaib72519b2009-05-08 14:31:55 +020010754#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010755
10756static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10757 struct snd_ctl_elem_value *ucontrol)
10758{
10759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10760 struct alc_spec *spec = codec->spec;
10761 int val = !!*ucontrol->value.integer.value;
10762
10763 if (val == spec->master_sw)
10764 return 0;
10765 spec->master_sw = val;
10766 alc262_hp_master_update(codec);
10767 return 1;
10768}
10769
Takashi Iwaib72519b2009-05-08 14:31:55 +020010770#define ALC262_HP_MASTER_SWITCH \
10771 { \
10772 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10773 .name = "Master Playback Switch", \
10774 .info = snd_ctl_boolean_mono_info, \
10775 .get = alc262_hp_master_sw_get, \
10776 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010777 }, \
10778 { \
10779 .iface = NID_MAPPING, \
10780 .name = "Master Playback Switch", \
10781 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010782 }
10783
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010784
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010785static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010786 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010787 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10788 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10789 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010790 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10791 HDA_OUTPUT),
10792 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10793 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010796 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010797 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10798 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010799 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10803 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010804 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10805 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10806 { } /* end */
10807};
10808
Kailang Yangcd7509a2007-01-26 18:33:17 +010010809static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010810 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010811 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10812 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10813 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10814 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010815 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10816 HDA_OUTPUT),
10817 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10818 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010819 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10820 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010821 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10824 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10825 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010826 { } /* end */
10827};
10828
10829static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10830 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10831 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010832 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010833 { } /* end */
10834};
10835
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010836/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010837static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010838{
10839 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010840
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010841 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010842 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010843}
10844
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010845static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010846 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10847 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010848 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10849 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10853 { } /* end */
10854};
10855
10856static struct hda_verb alc262_hp_t5735_verbs[] = {
10857 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10859
10860 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10861 { }
10862};
10863
Kailang Yang8c427222008-01-10 13:03:59 +010010864static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010865 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010867 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10868 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010869 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10870 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10871 { } /* end */
10872};
10873
10874static struct hda_verb alc262_hp_rp5700_verbs[] = {
10875 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10876 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10877 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10878 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10880 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10881 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10882 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10883 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10884 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10885 {}
10886};
10887
10888static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10889 .num_items = 1,
10890 .items = {
10891 { "Line", 0x1 },
10892 },
10893};
10894
Takashi Iwai42171c12009-05-08 14:11:43 +020010895/* bind hp and internal speaker mute (with plug check) as master switch */
10896static void alc262_hippo_master_update(struct hda_codec *codec)
10897{
10898 struct alc_spec *spec = codec->spec;
10899 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10900 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10901 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10902 unsigned int mute;
10903
10904 /* HP */
10905 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10906 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10907 HDA_AMP_MUTE, mute);
10908 /* mute internal speaker per jack sense */
10909 if (spec->jack_present)
10910 mute = HDA_AMP_MUTE;
10911 if (line_nid)
10912 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10913 HDA_AMP_MUTE, mute);
10914 if (speaker_nid && speaker_nid != line_nid)
10915 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10916 HDA_AMP_MUTE, mute);
10917}
10918
10919#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10920
10921static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10922 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010923{
10924 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010925 struct alc_spec *spec = codec->spec;
10926 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010927
Takashi Iwai42171c12009-05-08 14:11:43 +020010928 if (val == spec->master_sw)
10929 return 0;
10930 spec->master_sw = val;
10931 alc262_hippo_master_update(codec);
10932 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010933}
Takashi Iwai5b319542007-07-26 11:49:22 +020010934
Takashi Iwai42171c12009-05-08 14:11:43 +020010935#define ALC262_HIPPO_MASTER_SWITCH \
10936 { \
10937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10938 .name = "Master Playback Switch", \
10939 .info = snd_ctl_boolean_mono_info, \
10940 .get = alc262_hippo_master_sw_get, \
10941 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010942 }, \
10943 { \
10944 .iface = NID_MAPPING, \
10945 .name = "Master Playback Switch", \
10946 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10947 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010948 }
10949
10950static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10951 ALC262_HIPPO_MASTER_SWITCH,
10952 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10953 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10954 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10955 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10956 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10960 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10961 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10962 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10963 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10964 { } /* end */
10965};
10966
10967static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10968 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10969 ALC262_HIPPO_MASTER_SWITCH,
10970 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10971 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10972 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10973 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10977 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10979 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10980 { } /* end */
10981};
10982
10983/* mute/unmute internal speaker according to the hp jack and mute state */
10984static void alc262_hippo_automute(struct hda_codec *codec)
10985{
10986 struct alc_spec *spec = codec->spec;
10987 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010988
Wu Fengguang864f92b2009-11-18 12:38:02 +080010989 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010990 alc262_hippo_master_update(codec);
10991}
10992
10993static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10994{
10995 if ((res >> 26) != ALC880_HP_EVENT)
10996 return;
10997 alc262_hippo_automute(codec);
10998}
10999
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011000static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011001{
11002 struct alc_spec *spec = codec->spec;
11003
11004 spec->autocfg.hp_pins[0] = 0x15;
11005 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011006}
11007
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011008static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011009{
11010 struct alc_spec *spec = codec->spec;
11011
11012 spec->autocfg.hp_pins[0] = 0x1b;
11013 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011014}
11015
11016
Kailang Yang272a5272007-05-14 11:00:38 +020011017static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011018 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011019 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11022 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11023 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11024 { } /* end */
11025};
11026
Kailang Yang83c34212007-07-05 11:43:05 +020011027static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011028 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11029 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11032 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11033 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11034 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11035 { } /* end */
11036};
Kailang Yang272a5272007-05-14 11:00:38 +020011037
Tony Vroonba340e82009-02-02 19:01:30 +000011038static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11039 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11040 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11041 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11042 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11043 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11044 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11047 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11048 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11049 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11050 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11051 { } /* end */
11052};
11053
11054static struct hda_verb alc262_tyan_verbs[] = {
11055 /* Headphone automute */
11056 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11057 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11058 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11059
11060 /* P11 AUX_IN, white 4-pin connector */
11061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11062 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11063 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11064 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11065
11066 {}
11067};
11068
11069/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011070static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011071{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011072 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011073
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011074 spec->autocfg.hp_pins[0] = 0x1b;
11075 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011076}
11077
Tony Vroonba340e82009-02-02 19:01:30 +000011078
Kailang Yangdf694da2005-12-05 19:42:22 +010011079#define alc262_capture_mixer alc882_capture_mixer
11080#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11081
11082/*
11083 * generic initialization of ADC, input mixers and output mixers
11084 */
11085static struct hda_verb alc262_init_verbs[] = {
11086 /*
11087 * Unmute ADC0-2 and set the default input to mic-in
11088 */
11089 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11090 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11092 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11093 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11094 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11095
Takashi Iwaicb53c622007-08-10 17:21:45 +020011096 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011097 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011098 * Note: PASD motherboards uses the Line In 2 as the input for
11099 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011100 */
11101 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011107
11108 /*
11109 * Set up output mixers (0x0c - 0x0e)
11110 */
11111 /* set vol=0 to output mixers */
11112 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11113 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11114 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11115 /* set up input amps for analog loopback */
11116 /* Amp Indices: DAC = 0, mixer = 1 */
11117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11120 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11121 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11122 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11123
11124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11126 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11127 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11128 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11129 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11130
11131 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11133 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011136
Kailang Yangdf694da2005-12-05 19:42:22 +010011137 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11138 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011139
Kailang Yangdf694da2005-12-05 19:42:22 +010011140 /* FIXME: use matrix-type input source selection */
11141 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11142 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11143 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11144 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11146 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11147 /* Input mixer2 */
11148 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11149 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11150 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11151 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11152 /* Input mixer3 */
11153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011156 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011157
11158 { }
11159};
11160
Kailang Yang4e555fe2008-08-26 13:05:55 +020011161static struct hda_verb alc262_eapd_verbs[] = {
11162 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11163 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11164 { }
11165};
11166
Kailang Yangccc656c2006-10-17 12:32:26 +020011167static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11168 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11169 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11170 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11171
11172 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11173 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11174 {}
11175};
11176
Kailang Yang272a5272007-05-14 11:00:38 +020011177static struct hda_verb alc262_sony_unsol_verbs[] = {
11178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11179 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11180 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11181
11182 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011184 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011185};
11186
Kailang Yang4e555fe2008-08-26 13:05:55 +020011187static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11188 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11189 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11190 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11191 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011193 { } /* end */
11194};
11195
11196static struct hda_verb alc262_toshiba_s06_verbs[] = {
11197 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11200 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11201 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11202 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11203 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11204 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11205 {}
11206};
11207
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011208static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011209{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011210 struct alc_spec *spec = codec->spec;
11211
11212 spec->autocfg.hp_pins[0] = 0x15;
11213 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011214 spec->ext_mic.pin = 0x18;
11215 spec->ext_mic.mux_idx = 0;
11216 spec->int_mic.pin = 0x12;
11217 spec->int_mic.mux_idx = 9;
11218 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011219}
11220
Takashi Iwai834be882006-03-01 14:16:17 +010011221/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011222 * nec model
11223 * 0x15 = headphone
11224 * 0x16 = internal speaker
11225 * 0x18 = external mic
11226 */
11227
11228static struct snd_kcontrol_new alc262_nec_mixer[] = {
11229 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11230 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11231
11232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11234 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11235
11236 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11237 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11238 { } /* end */
11239};
11240
11241static struct hda_verb alc262_nec_verbs[] = {
11242 /* Unmute Speaker */
11243 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11244
11245 /* Headphone */
11246 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11248
11249 /* External mic to headphone */
11250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11251 /* External mic to speaker */
11252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11253 {}
11254};
11255
11256/*
Takashi Iwai834be882006-03-01 14:16:17 +010011257 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011258 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11259 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011260 */
11261
11262#define ALC_HP_EVENT 0x37
11263
11264static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11265 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011267 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11268 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011269 {}
11270};
11271
Jiang zhe0e31daf2008-03-20 12:12:39 +010011272static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11273 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11275 {}
11276};
11277
Daniel T Chene2595322009-12-19 18:19:02 -050011278static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11279 /* Front Mic pin: input vref at 50% */
11280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11281 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11282 {}
11283};
11284
Takashi Iwai834be882006-03-01 14:16:17 +010011285static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011286 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011287 .items = {
11288 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011289 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011290 { "CD", 0x4 },
11291 },
11292};
11293
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011294static struct hda_input_mux alc262_HP_capture_source = {
11295 .num_items = 5,
11296 .items = {
11297 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011298 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011299 { "Line", 0x2 },
11300 { "CD", 0x4 },
11301 { "AUX IN", 0x6 },
11302 },
11303};
11304
zhejiangaccbe492007-08-31 12:36:05 +020011305static struct hda_input_mux alc262_HP_D7000_capture_source = {
11306 .num_items = 4,
11307 .items = {
11308 { "Mic", 0x0 },
11309 { "Front Mic", 0x2 },
11310 { "Line", 0x1 },
11311 { "CD", 0x4 },
11312 },
11313};
11314
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011315/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011316static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11317{
11318 struct alc_spec *spec = codec->spec;
11319 unsigned int mute;
11320
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011321 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011322 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11323 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011324 spec->sense_updated = 1;
11325 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011326 /* unmute internal speaker only if both HPs are unplugged and
11327 * master switch is on
11328 */
11329 if (spec->jack_present)
11330 mute = HDA_AMP_MUTE;
11331 else
Takashi Iwai834be882006-03-01 14:16:17 +010011332 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011333 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11334 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011335}
11336
11337/* unsolicited event for HP jack sensing */
11338static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11339 unsigned int res)
11340{
11341 if ((res >> 26) != ALC_HP_EVENT)
11342 return;
11343 alc262_fujitsu_automute(codec, 1);
11344}
11345
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011346static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11347{
11348 alc262_fujitsu_automute(codec, 1);
11349}
11350
Takashi Iwai834be882006-03-01 14:16:17 +010011351/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011352static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11353 .ops = &snd_hda_bind_vol,
11354 .values = {
11355 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11356 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11357 0
11358 },
11359};
Takashi Iwai834be882006-03-01 14:16:17 +010011360
Jiang zhe0e31daf2008-03-20 12:12:39 +010011361/* mute/unmute internal speaker according to the hp jack and mute state */
11362static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11363{
11364 struct alc_spec *spec = codec->spec;
11365 unsigned int mute;
11366
11367 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011368 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011369 spec->sense_updated = 1;
11370 }
11371 if (spec->jack_present) {
11372 /* mute internal speaker */
11373 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11374 HDA_AMP_MUTE, HDA_AMP_MUTE);
11375 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11376 HDA_AMP_MUTE, HDA_AMP_MUTE);
11377 } else {
11378 /* unmute internal speaker if necessary */
11379 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11380 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11381 HDA_AMP_MUTE, mute);
11382 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11383 HDA_AMP_MUTE, mute);
11384 }
11385}
11386
11387/* unsolicited event for HP jack sensing */
11388static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11389 unsigned int res)
11390{
11391 if ((res >> 26) != ALC_HP_EVENT)
11392 return;
11393 alc262_lenovo_3000_automute(codec, 1);
11394}
11395
Takashi Iwai8de56b72009-07-24 16:51:47 +020011396static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11397 int dir, int idx, long *valp)
11398{
11399 int i, change = 0;
11400
11401 for (i = 0; i < 2; i++, valp++)
11402 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11403 HDA_AMP_MUTE,
11404 *valp ? 0 : HDA_AMP_MUTE);
11405 return change;
11406}
11407
Takashi Iwai834be882006-03-01 14:16:17 +010011408/* bind hp and internal speaker mute (with plug check) */
11409static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11410 struct snd_ctl_elem_value *ucontrol)
11411{
11412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11413 long *valp = ucontrol->value.integer.value;
11414 int change;
11415
Takashi Iwai8de56b72009-07-24 16:51:47 +020011416 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11417 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011418 if (change)
11419 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011420 return change;
11421}
11422
11423static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011424 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011425 {
11426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11427 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011428 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011429 .info = snd_hda_mixer_amp_switch_info,
11430 .get = snd_hda_mixer_amp_switch_get,
11431 .put = alc262_fujitsu_master_sw_put,
11432 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11433 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011434 {
11435 .iface = NID_MAPPING,
11436 .name = "Master Playback Switch",
11437 .private_value = 0x1b,
11438 },
Takashi Iwai834be882006-03-01 14:16:17 +010011439 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11440 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11441 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11443 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011444 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11445 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11446 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011447 { } /* end */
11448};
11449
Jiang zhe0e31daf2008-03-20 12:12:39 +010011450/* bind hp and internal speaker mute (with plug check) */
11451static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11452 struct snd_ctl_elem_value *ucontrol)
11453{
11454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11455 long *valp = ucontrol->value.integer.value;
11456 int change;
11457
Takashi Iwai8de56b72009-07-24 16:51:47 +020011458 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011459 if (change)
11460 alc262_lenovo_3000_automute(codec, 0);
11461 return change;
11462}
11463
11464static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11465 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11466 {
11467 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11468 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011469 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011470 .info = snd_hda_mixer_amp_switch_info,
11471 .get = snd_hda_mixer_amp_switch_get,
11472 .put = alc262_lenovo_3000_master_sw_put,
11473 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11474 },
11475 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11476 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11477 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11480 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11481 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11482 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11483 { } /* end */
11484};
11485
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011486static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11487 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011488 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011489 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11490 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11491 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11492 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11493 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11494 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11495 { } /* end */
11496};
11497
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011498/* additional init verbs for Benq laptops */
11499static struct hda_verb alc262_EAPD_verbs[] = {
11500 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11501 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11502 {}
11503};
11504
Kailang Yang83c34212007-07-05 11:43:05 +020011505static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11508
11509 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11510 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11511 {}
11512};
11513
Tobin Davisf651b502007-10-26 12:40:47 +020011514/* Samsung Q1 Ultra Vista model setup */
11515static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011516 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11517 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011518 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11519 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11520 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011521 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011522 { } /* end */
11523};
11524
11525static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011526 /* output mixer */
11527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11530 /* speaker */
11531 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11532 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11534 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11535 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011536 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011537 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11538 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11539 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11540 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11541 /* internal mic */
11542 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11544 /* ADC, choose mic */
11545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11546 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11548 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11549 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11550 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011555 {}
11556};
11557
Tobin Davisf651b502007-10-26 12:40:47 +020011558/* mute/unmute internal speaker according to the hp jack and mute state */
11559static void alc262_ultra_automute(struct hda_codec *codec)
11560{
11561 struct alc_spec *spec = codec->spec;
11562 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011563
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011564 mute = 0;
11565 /* auto-mute only when HP is used as HP */
11566 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011567 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011568 if (spec->jack_present)
11569 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011570 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011571 /* mute/unmute internal speaker */
11572 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11573 HDA_AMP_MUTE, mute);
11574 /* mute/unmute HP */
11575 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11576 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011577}
11578
11579/* unsolicited event for HP jack sensing */
11580static void alc262_ultra_unsol_event(struct hda_codec *codec,
11581 unsigned int res)
11582{
11583 if ((res >> 26) != ALC880_HP_EVENT)
11584 return;
11585 alc262_ultra_automute(codec);
11586}
11587
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011588static struct hda_input_mux alc262_ultra_capture_source = {
11589 .num_items = 2,
11590 .items = {
11591 { "Mic", 0x1 },
11592 { "Headphone", 0x7 },
11593 },
11594};
11595
11596static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11597 struct snd_ctl_elem_value *ucontrol)
11598{
11599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11600 struct alc_spec *spec = codec->spec;
11601 int ret;
11602
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011603 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011604 if (!ret)
11605 return 0;
11606 /* reprogram the HP pin as mic or HP according to the input source */
11607 snd_hda_codec_write_cache(codec, 0x15, 0,
11608 AC_VERB_SET_PIN_WIDGET_CONTROL,
11609 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11610 alc262_ultra_automute(codec); /* mute/unmute HP */
11611 return ret;
11612}
11613
11614static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11615 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11616 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11617 {
11618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11619 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011620 .info = alc_mux_enum_info,
11621 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011622 .put = alc262_ultra_mux_enum_put,
11623 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011624 {
11625 .iface = NID_MAPPING,
11626 .name = "Capture Source",
11627 .private_value = 0x15,
11628 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011629 { } /* end */
11630};
11631
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011632/* We use two mixers depending on the output pin; 0x16 is a mono output
11633 * and thus it's bound with a different mixer.
11634 * This function returns which mixer amp should be used.
11635 */
11636static int alc262_check_volbit(hda_nid_t nid)
11637{
11638 if (!nid)
11639 return 0;
11640 else if (nid == 0x16)
11641 return 2;
11642 else
11643 return 1;
11644}
11645
11646static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11647 const char *pfx, int *vbits)
11648{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011649 unsigned long val;
11650 int vbit;
11651
11652 vbit = alc262_check_volbit(nid);
11653 if (!vbit)
11654 return 0;
11655 if (*vbits & vbit) /* a volume control for this mixer already there */
11656 return 0;
11657 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011658 if (vbit == 2)
11659 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11660 else
11661 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011662 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011663}
11664
11665static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11666 const char *pfx)
11667{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011668 unsigned long val;
11669
11670 if (!nid)
11671 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011672 if (nid == 0x16)
11673 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11674 else
11675 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011676 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011677}
11678
Kailang Yangdf694da2005-12-05 19:42:22 +010011679/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011680static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11681 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011682{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011683 const char *pfx;
11684 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011685 int err;
11686
11687 spec->multiout.num_dacs = 1; /* only use one dac */
11688 spec->multiout.dac_nids = spec->private_dac_nids;
11689 spec->multiout.dac_nids[0] = 2;
11690
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011691 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11692 pfx = "Master";
11693 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11694 pfx = "Speaker";
11695 else
11696 pfx = "Front";
11697 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11698 if (err < 0)
11699 return err;
11700 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11701 if (err < 0)
11702 return err;
11703 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11704 if (err < 0)
11705 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011706
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011707 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11708 alc262_check_volbit(cfg->speaker_pins[0]) |
11709 alc262_check_volbit(cfg->hp_pins[0]);
11710 if (vbits == 1 || vbits == 2)
11711 pfx = "Master"; /* only one mixer is used */
11712 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11713 pfx = "Speaker";
11714 else
11715 pfx = "Front";
11716 vbits = 0;
11717 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11718 if (err < 0)
11719 return err;
11720 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11721 &vbits);
11722 if (err < 0)
11723 return err;
11724 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11725 &vbits);
11726 if (err < 0)
11727 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011728 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011729}
11730
Takashi Iwai05f5f472009-08-25 13:10:18 +020011731#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011732 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011733
11734/*
11735 * generic initialization of ADC, input mixers and output mixers
11736 */
11737static struct hda_verb alc262_volume_init_verbs[] = {
11738 /*
11739 * Unmute ADC0-2 and set the default input to mic-in
11740 */
11741 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11743 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11744 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11745 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11747
Takashi Iwaicb53c622007-08-10 17:21:45 +020011748 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011749 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011750 * Note: PASD motherboards uses the Line In 2 as the input for
11751 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011752 */
11753 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011759
11760 /*
11761 * Set up output mixers (0x0c - 0x0f)
11762 */
11763 /* set vol=0 to output mixers */
11764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11766 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011767
Kailang Yangdf694da2005-12-05 19:42:22 +010011768 /* set up input amps for analog loopback */
11769 /* Amp Indices: DAC = 0, mixer = 1 */
11770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11773 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11774 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11775 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11776
11777 /* FIXME: use matrix-type input source selection */
11778 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11779 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11780 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11781 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11782 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11783 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11784 /* Input mixer2 */
11785 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11786 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11787 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11788 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11789 /* Input mixer3 */
11790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11791 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11792 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11793 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11794
11795 { }
11796};
11797
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011798static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11799 /*
11800 * Unmute ADC0-2 and set the default input to mic-in
11801 */
11802 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11804 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11805 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11806 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11808
Takashi Iwaicb53c622007-08-10 17:21:45 +020011809 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011810 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011811 * Note: PASD motherboards uses the Line In 2 as the input for
11812 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011813 */
11814 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11817 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11818 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11819 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11820 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11821 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011822
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011823 /*
11824 * Set up output mixers (0x0c - 0x0e)
11825 */
11826 /* set vol=0 to output mixers */
11827 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11828 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11829 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11830
11831 /* set up input amps for analog loopback */
11832 /* Amp Indices: DAC = 0, mixer = 1 */
11833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11835 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11836 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11837 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11838 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11839
Takashi Iwaice875f02008-01-28 18:17:43 +010011840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11842 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11843
11844 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11846
11847 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11848 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11849
11850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11851 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11852 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11853 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11854 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11855
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011856 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011857 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011859 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011860 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11861 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11862
11863
11864 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011865 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11866 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011868 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11869 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11870 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11871 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11872 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11873 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11874 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11875 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011876 /* Input mixer2 */
11877 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011878 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11879 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11880 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11881 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11882 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11883 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11884 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11885 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011886 /* Input mixer3 */
11887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11890 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011896
Takashi Iwaice875f02008-01-28 18:17:43 +010011897 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11898
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011899 { }
11900};
11901
Kailang Yangcd7509a2007-01-26 18:33:17 +010011902static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11903 /*
11904 * Unmute ADC0-2 and set the default input to mic-in
11905 */
11906 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11908 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11910 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11911 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11912
Takashi Iwaicb53c622007-08-10 17:21:45 +020011913 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011914 * mixer widget
11915 * Note: PASD motherboards uses the Line In 2 as the input for front
11916 * panel mic (mic 2)
11917 */
11918 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11923 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011927 /*
11928 * Set up output mixers (0x0c - 0x0e)
11929 */
11930 /* set vol=0 to output mixers */
11931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11932 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11933 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11934
11935 /* set up input amps for analog loopback */
11936 /* Amp Indices: DAC = 0, mixer = 1 */
11937 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11938 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11939 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11940 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11941 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11942 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11943
11944
11945 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11946 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11947 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11948 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11949 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11950 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11951 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11952
11953 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11955
11956 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11957 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11958
11959 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11960 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11961 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11963 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11964 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11965
11966 /* FIXME: use matrix-type input source selection */
11967 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11968 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11971 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11972 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11974 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11975 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11976 /* Input mixer2 */
11977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11979 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11980 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11981 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11982 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11983 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11984 /* Input mixer3 */
11985 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11986 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11987 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11988 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11989 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11990 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11991 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11992
Takashi Iwaice875f02008-01-28 18:17:43 +010011993 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11994
Kailang Yangcd7509a2007-01-26 18:33:17 +010011995 { }
11996};
11997
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011998static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11999
12000 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12002 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12003
12004 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12005 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12006 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12007 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12008
12009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12010 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12011 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12012 {}
12013};
12014
12015
Takashi Iwaicb53c622007-08-10 17:21:45 +020012016#ifdef CONFIG_SND_HDA_POWER_SAVE
12017#define alc262_loopbacks alc880_loopbacks
12018#endif
12019
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012020/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012021#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12022#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12023#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12024#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12025
12026/*
12027 * BIOS auto configuration
12028 */
12029static int alc262_parse_auto_config(struct hda_codec *codec)
12030{
12031 struct alc_spec *spec = codec->spec;
12032 int err;
12033 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12034
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012035 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12036 alc262_ignore);
12037 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012038 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012039 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012040 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012041 spec->multiout.max_channels = 2;
12042 spec->no_analog = 1;
12043 goto dig_only;
12044 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012045 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012046 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012047 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12048 if (err < 0)
12049 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012050 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012051 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012052 return err;
12053
12054 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12055
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012056 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012057 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012058 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012059 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012060 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012061 if (spec->autocfg.dig_in_pin)
12062 spec->dig_in_nid = ALC262_DIGIN_NID;
12063
Takashi Iwai603c4012008-07-30 15:01:44 +020012064 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012065 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012066
Takashi Iwaid88897e2008-10-31 15:01:37 +010012067 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012068 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012069 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012070
Takashi Iwai776e1842007-08-29 15:07:11 +020012071 err = alc_auto_add_mic_boost(codec);
12072 if (err < 0)
12073 return err;
12074
Kailang Yang6227cdc2010-02-25 08:36:52 +010012075 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012076
Kailang Yangdf694da2005-12-05 19:42:22 +010012077 return 1;
12078}
12079
12080#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12081#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12082#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012083#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012084
12085
12086/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012087static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012088{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012089 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012090 alc262_auto_init_multi_out(codec);
12091 alc262_auto_init_hp_out(codec);
12092 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012093 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012094 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012095 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012096}
12097
12098/*
12099 * configuration and preset
12100 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012101static const char *alc262_models[ALC262_MODEL_LAST] = {
12102 [ALC262_BASIC] = "basic",
12103 [ALC262_HIPPO] = "hippo",
12104 [ALC262_HIPPO_1] = "hippo_1",
12105 [ALC262_FUJITSU] = "fujitsu",
12106 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012107 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012108 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012109 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012110 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012111 [ALC262_BENQ_T31] = "benq-t31",
12112 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012113 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012114 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012115 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012116 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012117 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012118 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012119 [ALC262_AUTO] = "auto",
12120};
12121
12122static struct snd_pci_quirk alc262_cfg_tbl[] = {
12123 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012124 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012125 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12126 ALC262_HP_BPC),
12127 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12128 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012129 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12130 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012131 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012132 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012133 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012134 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012135 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012136 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012137 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012138 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012139 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12140 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12141 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012142 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12143 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012144 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012145 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012146 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012147 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012148 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012149 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012150 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012151 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012152#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012153 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12154 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012155#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012156 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012157 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012158 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012159 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012160 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012161 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012162 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12163 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012164 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012165 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012166 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012167 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012168 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012169 {}
12170};
12171
12172static struct alc_config_preset alc262_presets[] = {
12173 [ALC262_BASIC] = {
12174 .mixers = { alc262_base_mixer },
12175 .init_verbs = { alc262_init_verbs },
12176 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12177 .dac_nids = alc262_dac_nids,
12178 .hp_nid = 0x03,
12179 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12180 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012181 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012182 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012183 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012184 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012185 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012186 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12187 .dac_nids = alc262_dac_nids,
12188 .hp_nid = 0x03,
12189 .dig_out_nid = ALC262_DIGOUT_NID,
12190 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12191 .channel_mode = alc262_modes,
12192 .input_mux = &alc262_capture_source,
12193 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012194 .setup = alc262_hippo_setup,
12195 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012196 },
12197 [ALC262_HIPPO_1] = {
12198 .mixers = { alc262_hippo1_mixer },
12199 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12200 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12201 .dac_nids = alc262_dac_nids,
12202 .hp_nid = 0x02,
12203 .dig_out_nid = ALC262_DIGOUT_NID,
12204 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12205 .channel_mode = alc262_modes,
12206 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012207 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012208 .setup = alc262_hippo1_setup,
12209 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012210 },
Takashi Iwai834be882006-03-01 14:16:17 +010012211 [ALC262_FUJITSU] = {
12212 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012213 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12214 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012215 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12216 .dac_nids = alc262_dac_nids,
12217 .hp_nid = 0x03,
12218 .dig_out_nid = ALC262_DIGOUT_NID,
12219 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12220 .channel_mode = alc262_modes,
12221 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012222 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012223 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012224 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012225 [ALC262_HP_BPC] = {
12226 .mixers = { alc262_HP_BPC_mixer },
12227 .init_verbs = { alc262_HP_BPC_init_verbs },
12228 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12229 .dac_nids = alc262_dac_nids,
12230 .hp_nid = 0x03,
12231 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12232 .channel_mode = alc262_modes,
12233 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012234 .unsol_event = alc262_hp_bpc_unsol_event,
12235 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012236 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012237 [ALC262_HP_BPC_D7000_WF] = {
12238 .mixers = { alc262_HP_BPC_WildWest_mixer },
12239 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12240 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12241 .dac_nids = alc262_dac_nids,
12242 .hp_nid = 0x03,
12243 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12244 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012245 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012246 .unsol_event = alc262_hp_wildwest_unsol_event,
12247 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012248 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012249 [ALC262_HP_BPC_D7000_WL] = {
12250 .mixers = { alc262_HP_BPC_WildWest_mixer,
12251 alc262_HP_BPC_WildWest_option_mixer },
12252 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12253 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12254 .dac_nids = alc262_dac_nids,
12255 .hp_nid = 0x03,
12256 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12257 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012258 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012259 .unsol_event = alc262_hp_wildwest_unsol_event,
12260 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012261 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012262 [ALC262_HP_TC_T5735] = {
12263 .mixers = { alc262_hp_t5735_mixer },
12264 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12265 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12266 .dac_nids = alc262_dac_nids,
12267 .hp_nid = 0x03,
12268 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12269 .channel_mode = alc262_modes,
12270 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012271 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012272 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012273 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012274 },
12275 [ALC262_HP_RP5700] = {
12276 .mixers = { alc262_hp_rp5700_mixer },
12277 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12278 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12279 .dac_nids = alc262_dac_nids,
12280 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12281 .channel_mode = alc262_modes,
12282 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012283 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012284 [ALC262_BENQ_ED8] = {
12285 .mixers = { alc262_base_mixer },
12286 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12287 .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,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012293 },
Kailang Yang272a5272007-05-14 11:00:38 +020012294 [ALC262_SONY_ASSAMD] = {
12295 .mixers = { alc262_sony_mixer },
12296 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12297 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12298 .dac_nids = alc262_dac_nids,
12299 .hp_nid = 0x02,
12300 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12301 .channel_mode = alc262_modes,
12302 .input_mux = &alc262_capture_source,
12303 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012304 .setup = alc262_hippo_setup,
12305 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012306 },
12307 [ALC262_BENQ_T31] = {
12308 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012309 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12310 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012311 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12312 .dac_nids = alc262_dac_nids,
12313 .hp_nid = 0x03,
12314 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12315 .channel_mode = alc262_modes,
12316 .input_mux = &alc262_capture_source,
12317 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012318 .setup = alc262_hippo_setup,
12319 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012320 },
Tobin Davisf651b502007-10-26 12:40:47 +020012321 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012322 .mixers = { alc262_ultra_mixer },
12323 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012324 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012325 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12326 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012327 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12328 .channel_mode = alc262_modes,
12329 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012330 .adc_nids = alc262_adc_nids, /* ADC0 */
12331 .capsrc_nids = alc262_capsrc_nids,
12332 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012333 .unsol_event = alc262_ultra_unsol_event,
12334 .init_hook = alc262_ultra_automute,
12335 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012336 [ALC262_LENOVO_3000] = {
12337 .mixers = { alc262_lenovo_3000_mixer },
12338 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012339 alc262_lenovo_3000_unsol_verbs,
12340 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012341 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12342 .dac_nids = alc262_dac_nids,
12343 .hp_nid = 0x03,
12344 .dig_out_nid = ALC262_DIGOUT_NID,
12345 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12346 .channel_mode = alc262_modes,
12347 .input_mux = &alc262_fujitsu_capture_source,
12348 .unsol_event = alc262_lenovo_3000_unsol_event,
12349 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012350 [ALC262_NEC] = {
12351 .mixers = { alc262_nec_mixer },
12352 .init_verbs = { alc262_nec_verbs },
12353 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12354 .dac_nids = alc262_dac_nids,
12355 .hp_nid = 0x03,
12356 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12357 .channel_mode = alc262_modes,
12358 .input_mux = &alc262_capture_source,
12359 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012360 [ALC262_TOSHIBA_S06] = {
12361 .mixers = { alc262_toshiba_s06_mixer },
12362 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12363 alc262_eapd_verbs },
12364 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12365 .capsrc_nids = alc262_dmic_capsrc_nids,
12366 .dac_nids = alc262_dac_nids,
12367 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012368 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012369 .dig_out_nid = ALC262_DIGOUT_NID,
12370 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12371 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012372 .unsol_event = alc_sku_unsol_event,
12373 .setup = alc262_toshiba_s06_setup,
12374 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012375 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012376 [ALC262_TOSHIBA_RX1] = {
12377 .mixers = { alc262_toshiba_rx1_mixer },
12378 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12379 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12380 .dac_nids = alc262_dac_nids,
12381 .hp_nid = 0x03,
12382 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12383 .channel_mode = alc262_modes,
12384 .input_mux = &alc262_capture_source,
12385 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012386 .setup = alc262_hippo_setup,
12387 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012388 },
Tony Vroonba340e82009-02-02 19:01:30 +000012389 [ALC262_TYAN] = {
12390 .mixers = { alc262_tyan_mixer },
12391 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12392 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12393 .dac_nids = alc262_dac_nids,
12394 .hp_nid = 0x02,
12395 .dig_out_nid = ALC262_DIGOUT_NID,
12396 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12397 .channel_mode = alc262_modes,
12398 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012399 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012400 .setup = alc262_tyan_setup,
12401 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012402 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012403};
12404
12405static int patch_alc262(struct hda_codec *codec)
12406{
12407 struct alc_spec *spec;
12408 int board_config;
12409 int err;
12410
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012411 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012412 if (spec == NULL)
12413 return -ENOMEM;
12414
12415 codec->spec = spec;
12416#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012417 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12418 * under-run
12419 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012420 {
12421 int tmp;
12422 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12423 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12424 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12425 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12426 }
12427#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012428 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012429
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012430 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12431
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012432 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12433 alc262_models,
12434 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012435
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012436 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012437 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12438 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012439 board_config = ALC262_AUTO;
12440 }
12441
12442 if (board_config == ALC262_AUTO) {
12443 /* automatic parse from the BIOS config */
12444 err = alc262_parse_auto_config(codec);
12445 if (err < 0) {
12446 alc_free(codec);
12447 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012448 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012449 printk(KERN_INFO
12450 "hda_codec: Cannot set up configuration "
12451 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012452 board_config = ALC262_BASIC;
12453 }
12454 }
12455
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012456 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012457 err = snd_hda_attach_beep_device(codec, 0x1);
12458 if (err < 0) {
12459 alc_free(codec);
12460 return err;
12461 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012462 }
12463
Kailang Yangdf694da2005-12-05 19:42:22 +010012464 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012465 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012466
Kailang Yangdf694da2005-12-05 19:42:22 +010012467 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12468 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012469
Kailang Yangdf694da2005-12-05 19:42:22 +010012470 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12471 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12472
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012473 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012474 int i;
12475 /* check whether the digital-mic has to be supported */
12476 for (i = 0; i < spec->input_mux->num_items; i++) {
12477 if (spec->input_mux->items[i].index >= 9)
12478 break;
12479 }
12480 if (i < spec->input_mux->num_items) {
12481 /* use only ADC0 */
12482 spec->adc_nids = alc262_dmic_adc_nids;
12483 spec->num_adc_nids = 1;
12484 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012485 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012486 /* all analog inputs */
12487 /* check whether NID 0x07 is valid */
12488 unsigned int wcap = get_wcaps(codec, 0x07);
12489
12490 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012491 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012492 if (wcap != AC_WID_AUD_IN) {
12493 spec->adc_nids = alc262_adc_nids_alt;
12494 spec->num_adc_nids =
12495 ARRAY_SIZE(alc262_adc_nids_alt);
12496 spec->capsrc_nids = alc262_capsrc_nids_alt;
12497 } else {
12498 spec->adc_nids = alc262_adc_nids;
12499 spec->num_adc_nids =
12500 ARRAY_SIZE(alc262_adc_nids);
12501 spec->capsrc_nids = alc262_capsrc_nids;
12502 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012503 }
12504 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012505 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012506 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012507 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012508 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012509
Takashi Iwai2134ea42008-01-10 16:53:55 +010012510 spec->vmaster_nid = 0x0c;
12511
Kailang Yangdf694da2005-12-05 19:42:22 +010012512 codec->patch_ops = alc_patch_ops;
12513 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012514 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012515#ifdef CONFIG_SND_HDA_POWER_SAVE
12516 if (!spec->loopback.amplist)
12517 spec->loopback.amplist = alc262_loopbacks;
12518#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012519
Kailang Yangdf694da2005-12-05 19:42:22 +010012520 return 0;
12521}
12522
Kailang Yangdf694da2005-12-05 19:42:22 +010012523/*
Kailang Yanga361d842007-06-05 12:30:55 +020012524 * ALC268 channel source setting (2 channel)
12525 */
12526#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12527#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012528
Kailang Yanga361d842007-06-05 12:30:55 +020012529static hda_nid_t alc268_dac_nids[2] = {
12530 /* front, hp */
12531 0x02, 0x03
12532};
12533
12534static hda_nid_t alc268_adc_nids[2] = {
12535 /* ADC0-1 */
12536 0x08, 0x07
12537};
12538
12539static hda_nid_t alc268_adc_nids_alt[1] = {
12540 /* ADC0 */
12541 0x08
12542};
12543
Takashi Iwaie1406342008-02-11 18:32:32 +010012544static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12545
Kailang Yanga361d842007-06-05 12:30:55 +020012546static struct snd_kcontrol_new alc268_base_mixer[] = {
12547 /* output mixer control */
12548 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12549 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12550 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012552 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12553 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12554 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012555 { }
12556};
12557
Takashi Iwai42171c12009-05-08 14:11:43 +020012558static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12559 /* output mixer control */
12560 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12561 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12562 ALC262_HIPPO_MASTER_SWITCH,
12563 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12564 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12565 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12566 { }
12567};
12568
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012569/* bind Beep switches of both NID 0x0f and 0x10 */
12570static struct hda_bind_ctls alc268_bind_beep_sw = {
12571 .ops = &snd_hda_bind_sw,
12572 .values = {
12573 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12574 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12575 0
12576 },
12577};
12578
12579static struct snd_kcontrol_new alc268_beep_mixer[] = {
12580 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12581 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12582 { }
12583};
12584
Kailang Yangd1a991a2007-08-15 16:21:59 +020012585static struct hda_verb alc268_eapd_verbs[] = {
12586 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12587 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12588 { }
12589};
12590
Takashi Iwaid2738092007-08-16 14:59:45 +020012591/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012592static struct hda_verb alc268_toshiba_verbs[] = {
12593 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12594 { } /* end */
12595};
12596
12597/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012598/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012599static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12600 .ops = &snd_hda_bind_vol,
12601 .values = {
12602 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12603 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12604 0
12605 },
12606};
12607
Takashi Iwai889c4392007-08-23 18:56:52 +020012608/* mute/unmute internal speaker according to the hp jack and mute state */
12609static void alc268_acer_automute(struct hda_codec *codec, int force)
12610{
12611 struct alc_spec *spec = codec->spec;
12612 unsigned int mute;
12613
12614 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012615 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012616 spec->sense_updated = 1;
12617 }
12618 if (spec->jack_present)
12619 mute = HDA_AMP_MUTE; /* mute internal speaker */
12620 else /* unmute internal speaker if necessary */
12621 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12622 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12623 HDA_AMP_MUTE, mute);
12624}
12625
12626
12627/* bind hp and internal speaker mute (with plug check) */
12628static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12629 struct snd_ctl_elem_value *ucontrol)
12630{
12631 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12632 long *valp = ucontrol->value.integer.value;
12633 int change;
12634
Takashi Iwai8de56b72009-07-24 16:51:47 +020012635 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012636 if (change)
12637 alc268_acer_automute(codec, 0);
12638 return change;
12639}
Takashi Iwaid2738092007-08-16 14:59:45 +020012640
Kailang Yang8ef355d2008-08-26 13:10:22 +020012641static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12642 /* output mixer control */
12643 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12644 {
12645 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12646 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012647 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012648 .info = snd_hda_mixer_amp_switch_info,
12649 .get = snd_hda_mixer_amp_switch_get,
12650 .put = alc268_acer_master_sw_put,
12651 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12652 },
12653 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12654 { }
12655};
12656
Takashi Iwaid2738092007-08-16 14:59:45 +020012657static struct snd_kcontrol_new alc268_acer_mixer[] = {
12658 /* output mixer control */
12659 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12660 {
12661 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12662 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012663 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012664 .info = snd_hda_mixer_amp_switch_info,
12665 .get = snd_hda_mixer_amp_switch_get,
12666 .put = alc268_acer_master_sw_put,
12667 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12668 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012669 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12670 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12671 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012672 { }
12673};
12674
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012675static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12676 /* output mixer control */
12677 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12678 {
12679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12680 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012681 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012682 .info = snd_hda_mixer_amp_switch_info,
12683 .get = snd_hda_mixer_amp_switch_get,
12684 .put = alc268_acer_master_sw_put,
12685 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12686 },
12687 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12688 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12689 { }
12690};
12691
Kailang Yang8ef355d2008-08-26 13:10:22 +020012692static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12693 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12695 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12696 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12697 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12699 { }
12700};
12701
Takashi Iwaid2738092007-08-16 14:59:45 +020012702static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012703 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12704 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12708 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012709 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12710 { }
12711};
12712
12713/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012714#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012715#define alc268_toshiba_setup alc262_hippo_setup
12716#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012717
12718static void alc268_acer_unsol_event(struct hda_codec *codec,
12719 unsigned int res)
12720{
Takashi Iwai889c4392007-08-23 18:56:52 +020012721 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012722 return;
12723 alc268_acer_automute(codec, 1);
12724}
12725
Takashi Iwai889c4392007-08-23 18:56:52 +020012726static void alc268_acer_init_hook(struct hda_codec *codec)
12727{
12728 alc268_acer_automute(codec, 1);
12729}
12730
Kailang Yang8ef355d2008-08-26 13:10:22 +020012731/* toggle speaker-output according to the hp-jack state */
12732static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12733{
12734 unsigned int present;
12735 unsigned char bits;
12736
Wu Fengguang864f92b2009-11-18 12:38:02 +080012737 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012738 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012739 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012740 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012741 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012742 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012743}
12744
Kailang Yang8ef355d2008-08-26 13:10:22 +020012745static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12746 unsigned int res)
12747{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012748 switch (res >> 26) {
12749 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012750 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012751 break;
12752 case ALC880_MIC_EVENT:
12753 alc_mic_automute(codec);
12754 break;
12755 }
12756}
12757
12758static void alc268_acer_lc_setup(struct hda_codec *codec)
12759{
12760 struct alc_spec *spec = codec->spec;
12761 spec->ext_mic.pin = 0x18;
12762 spec->ext_mic.mux_idx = 0;
12763 spec->int_mic.pin = 0x12;
12764 spec->int_mic.mux_idx = 6;
12765 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012766}
12767
12768static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12769{
12770 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012771 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012772}
12773
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012774static struct snd_kcontrol_new alc268_dell_mixer[] = {
12775 /* output mixer control */
12776 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12777 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12778 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12780 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12781 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12782 { }
12783};
12784
12785static struct hda_verb alc268_dell_verbs[] = {
12786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12788 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012789 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012790 { }
12791};
12792
12793/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012794static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012795{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012796 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012797
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012798 spec->autocfg.hp_pins[0] = 0x15;
12799 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012800 spec->ext_mic.pin = 0x18;
12801 spec->ext_mic.mux_idx = 0;
12802 spec->int_mic.pin = 0x19;
12803 spec->int_mic.mux_idx = 1;
12804 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012805}
12806
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012807static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12808 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12809 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12810 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12812 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12813 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12814 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12815 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12816 { }
12817};
12818
12819static struct hda_verb alc267_quanta_il1_verbs[] = {
12820 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12821 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12822 { }
12823};
12824
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012825static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012826{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012827 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012828 spec->autocfg.hp_pins[0] = 0x15;
12829 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012830 spec->ext_mic.pin = 0x18;
12831 spec->ext_mic.mux_idx = 0;
12832 spec->int_mic.pin = 0x19;
12833 spec->int_mic.mux_idx = 1;
12834 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012835}
12836
Kailang Yanga361d842007-06-05 12:30:55 +020012837/*
12838 * generic initialization of ADC, input mixers and output mixers
12839 */
12840static struct hda_verb alc268_base_init_verbs[] = {
12841 /* Unmute DAC0-1 and set vol = 0 */
12842 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012843 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012844
12845 /*
12846 * Set up output mixers (0x0c - 0x0e)
12847 */
12848 /* set vol=0 to output mixers */
12849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012850 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12851
12852 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12853 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12854
12855 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12856 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12857 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12859 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12860 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12861 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12862 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12863
12864 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12867 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012868 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012869
12870 /* set PCBEEP vol = 0, mute connections */
12871 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12872 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12873 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012874
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012875 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012876
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012877 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12878 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12879 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12880 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012881
Kailang Yanga361d842007-06-05 12:30:55 +020012882 { }
12883};
12884
12885/*
12886 * generic initialization of ADC, input mixers and output mixers
12887 */
12888static struct hda_verb alc268_volume_init_verbs[] = {
12889 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012890 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12891 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012892
12893 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12894 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12895 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12896 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12897 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12898
Kailang Yanga361d842007-06-05 12:30:55 +020012899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12901 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12902
12903 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012904 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012905
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012906 /* set PCBEEP vol = 0, mute connections */
12907 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12909 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012910
12911 { }
12912};
12913
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012914static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12915 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12916 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12917 { } /* end */
12918};
12919
Kailang Yanga361d842007-06-05 12:30:55 +020012920static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12921 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12922 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012923 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012924 { } /* end */
12925};
12926
12927static struct snd_kcontrol_new alc268_capture_mixer[] = {
12928 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12929 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12930 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12931 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020012932 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012933 { } /* end */
12934};
12935
12936static struct hda_input_mux alc268_capture_source = {
12937 .num_items = 4,
12938 .items = {
12939 { "Mic", 0x0 },
12940 { "Front Mic", 0x1 },
12941 { "Line", 0x2 },
12942 { "CD", 0x3 },
12943 },
12944};
12945
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012946static struct hda_input_mux alc268_acer_capture_source = {
12947 .num_items = 3,
12948 .items = {
12949 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012950 { "Internal Mic", 0x1 },
12951 { "Line", 0x2 },
12952 },
12953};
12954
12955static struct hda_input_mux alc268_acer_dmic_capture_source = {
12956 .num_items = 3,
12957 .items = {
12958 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012959 { "Internal Mic", 0x6 },
12960 { "Line", 0x2 },
12961 },
12962};
12963
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012964#ifdef CONFIG_SND_DEBUG
12965static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012966 /* Volume widgets */
12967 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12968 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12969 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12970 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12971 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12972 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12973 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12974 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12975 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12976 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12977 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12978 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12979 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012980 /* The below appears problematic on some hardwares */
12981 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012982 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12983 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12984 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12985 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12986
12987 /* Modes for retasking pin widgets */
12988 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12989 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12990 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12991 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12992
12993 /* Controls for GPIO pins, assuming they are configured as outputs */
12994 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12995 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12996 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12997 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12998
12999 /* Switches to allow the digital SPDIF output pin to be enabled.
13000 * The ALC268 does not have an SPDIF input.
13001 */
13002 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13003
13004 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13005 * this output to turn on an external amplifier.
13006 */
13007 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13008 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13009
13010 { } /* end */
13011};
13012#endif
13013
Kailang Yanga361d842007-06-05 12:30:55 +020013014/* create input playback/capture controls for the given pin */
13015static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13016 const char *ctlname, int idx)
13017{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013018 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013019 int err;
13020
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013021 switch (nid) {
13022 case 0x14:
13023 case 0x16:
13024 dac = 0x02;
13025 break;
13026 case 0x15:
Kailang Yang531d8792010-04-09 10:57:33 +020013027 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013028 dac = 0x03;
13029 break;
13030 default:
13031 return 0;
13032 }
13033 if (spec->multiout.dac_nids[0] != dac &&
13034 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013035 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013036 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013037 HDA_OUTPUT));
13038 if (err < 0)
13039 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013040 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13041 }
13042
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013043 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013044 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013045 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013046 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013047 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013048 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013049 if (err < 0)
13050 return err;
13051 return 0;
13052}
13053
13054/* add playback controls from the parsed DAC table */
13055static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13056 const struct auto_pin_cfg *cfg)
13057{
13058 hda_nid_t nid;
13059 int err;
13060
Kailang Yanga361d842007-06-05 12:30:55 +020013061 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013062
13063 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013064 if (nid) {
13065 const char *name;
13066 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13067 name = "Speaker";
13068 else
13069 name = "Front";
13070 err = alc268_new_analog_output(spec, nid, name, 0);
13071 if (err < 0)
13072 return err;
13073 }
Kailang Yanga361d842007-06-05 12:30:55 +020013074
13075 nid = cfg->speaker_pins[0];
13076 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013077 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013078 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13079 if (err < 0)
13080 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013081 } else {
13082 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13083 if (err < 0)
13084 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013085 }
13086 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013087 if (nid) {
13088 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13089 if (err < 0)
13090 return err;
13091 }
Kailang Yanga361d842007-06-05 12:30:55 +020013092
13093 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13094 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013095 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013096 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013097 if (err < 0)
13098 return err;
13099 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013100 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013101}
13102
13103/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013104static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013105 const struct auto_pin_cfg *cfg)
13106{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013107 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013108}
13109
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013110static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13111 hda_nid_t nid, int pin_type)
13112{
13113 int idx;
13114
13115 alc_set_pin_output(codec, nid, pin_type);
13116 if (nid == 0x14 || nid == 0x16)
13117 idx = 0;
13118 else
13119 idx = 1;
13120 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13121}
13122
13123static void alc268_auto_init_multi_out(struct hda_codec *codec)
13124{
13125 struct alc_spec *spec = codec->spec;
13126 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13127 if (nid) {
13128 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13129 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13130 }
13131}
13132
13133static void alc268_auto_init_hp_out(struct hda_codec *codec)
13134{
13135 struct alc_spec *spec = codec->spec;
13136 hda_nid_t pin;
13137
13138 pin = spec->autocfg.hp_pins[0];
13139 if (pin)
13140 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13141 pin = spec->autocfg.speaker_pins[0];
13142 if (pin)
13143 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13144}
13145
Kailang Yanga361d842007-06-05 12:30:55 +020013146static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13147{
13148 struct alc_spec *spec = codec->spec;
13149 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13150 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13151 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13152 unsigned int dac_vol1, dac_vol2;
13153
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013154 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013155 snd_hda_codec_write(codec, speaker_nid, 0,
13156 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013157 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013158 snd_hda_codec_write(codec, 0x0f, 0,
13159 AC_VERB_SET_AMP_GAIN_MUTE,
13160 AMP_IN_UNMUTE(1));
13161 snd_hda_codec_write(codec, 0x10, 0,
13162 AC_VERB_SET_AMP_GAIN_MUTE,
13163 AMP_IN_UNMUTE(1));
13164 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013165 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013166 snd_hda_codec_write(codec, 0x0f, 0,
13167 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13168 snd_hda_codec_write(codec, 0x10, 0,
13169 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13170 }
13171
13172 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013173 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013174 dac_vol2 = AMP_OUT_ZERO;
13175 else if (line_nid == 0x15)
13176 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013177 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013178 dac_vol2 = AMP_OUT_ZERO;
13179 else if (hp_nid == 0x15)
13180 dac_vol1 = AMP_OUT_ZERO;
13181 if (line_nid != 0x16 || hp_nid != 0x16 ||
13182 spec->autocfg.line_out_pins[1] != 0x16 ||
13183 spec->autocfg.line_out_pins[2] != 0x16)
13184 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13185
13186 snd_hda_codec_write(codec, 0x02, 0,
13187 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13188 snd_hda_codec_write(codec, 0x03, 0,
13189 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13190}
13191
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013192/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013193#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13194#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013195#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013196#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13197
13198/*
13199 * BIOS auto configuration
13200 */
13201static int alc268_parse_auto_config(struct hda_codec *codec)
13202{
13203 struct alc_spec *spec = codec->spec;
13204 int err;
13205 static hda_nid_t alc268_ignore[] = { 0 };
13206
13207 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13208 alc268_ignore);
13209 if (err < 0)
13210 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013211 if (!spec->autocfg.line_outs) {
13212 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13213 spec->multiout.max_channels = 2;
13214 spec->no_analog = 1;
13215 goto dig_only;
13216 }
Kailang Yanga361d842007-06-05 12:30:55 +020013217 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013218 }
Kailang Yanga361d842007-06-05 12:30:55 +020013219 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13220 if (err < 0)
13221 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013222 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013223 if (err < 0)
13224 return err;
13225
13226 spec->multiout.max_channels = 2;
13227
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013228 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013229 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013230 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020013231 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013232 spec->dig_out_type = spec->autocfg.dig_out_type[0];
13233 }
Takashi Iwai603c4012008-07-30 15:01:44 +020013234 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013235 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013236
Takashi Iwai892981f2009-03-02 08:04:35 +010013237 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013238 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013239
Takashi Iwaid88897e2008-10-31 15:01:37 +010013240 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013241 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013242 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013243
Takashi Iwai776e1842007-08-29 15:07:11 +020013244 err = alc_auto_add_mic_boost(codec);
13245 if (err < 0)
13246 return err;
13247
Kailang Yang6227cdc2010-02-25 08:36:52 +010013248 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013249
Kailang Yanga361d842007-06-05 12:30:55 +020013250 return 1;
13251}
13252
Kailang Yanga361d842007-06-05 12:30:55 +020013253#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13254
13255/* init callback for auto-configuration model -- overriding the default init */
13256static void alc268_auto_init(struct hda_codec *codec)
13257{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013258 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013259 alc268_auto_init_multi_out(codec);
13260 alc268_auto_init_hp_out(codec);
13261 alc268_auto_init_mono_speaker_out(codec);
13262 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013263 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013264 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013265}
13266
13267/*
13268 * configuration and preset
13269 */
13270static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013271 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013272 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013273 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013274 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013275 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013276 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013277 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013278 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013279#ifdef CONFIG_SND_DEBUG
13280 [ALC268_TEST] = "test",
13281#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013282 [ALC268_AUTO] = "auto",
13283};
13284
13285static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013286 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013287 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013288 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013289 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013290 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013291 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13292 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013293 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013294 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13295 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013296 /* almost compatible with toshiba but with optional digital outs;
13297 * auto-probing seems working fine
13298 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013299 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013300 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013301 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013302 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013303 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013304 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013305 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013306 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013307 {}
13308};
13309
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013310/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13311static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13312 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13313 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13314 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13315 ALC268_TOSHIBA),
13316 {}
13317};
13318
Kailang Yanga361d842007-06-05 12:30:55 +020013319static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013320 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013321 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13322 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013323 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13324 alc267_quanta_il1_verbs },
13325 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13326 .dac_nids = alc268_dac_nids,
13327 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13328 .adc_nids = alc268_adc_nids_alt,
13329 .hp_nid = 0x03,
13330 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13331 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013332 .unsol_event = alc_sku_unsol_event,
13333 .setup = alc267_quanta_il1_setup,
13334 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013335 },
Kailang Yanga361d842007-06-05 12:30:55 +020013336 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013337 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13338 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013339 .init_verbs = { alc268_base_init_verbs },
13340 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13341 .dac_nids = alc268_dac_nids,
13342 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13343 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013344 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013345 .hp_nid = 0x03,
13346 .dig_out_nid = ALC268_DIGOUT_NID,
13347 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13348 .channel_mode = alc268_modes,
13349 .input_mux = &alc268_capture_source,
13350 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013351 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013352 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013353 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013354 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13355 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013356 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13357 .dac_nids = alc268_dac_nids,
13358 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13359 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013360 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013361 .hp_nid = 0x03,
13362 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13363 .channel_mode = alc268_modes,
13364 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013365 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013366 .setup = alc268_toshiba_setup,
13367 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013368 },
13369 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013370 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013371 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013372 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13373 alc268_acer_verbs },
13374 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13375 .dac_nids = alc268_dac_nids,
13376 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13377 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013378 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013379 .hp_nid = 0x02,
13380 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13381 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013382 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013383 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013384 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013385 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013386 [ALC268_ACER_DMIC] = {
13387 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13388 alc268_beep_mixer },
13389 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13390 alc268_acer_verbs },
13391 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13392 .dac_nids = alc268_dac_nids,
13393 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13394 .adc_nids = alc268_adc_nids_alt,
13395 .capsrc_nids = alc268_capsrc_nids,
13396 .hp_nid = 0x02,
13397 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13398 .channel_mode = alc268_modes,
13399 .input_mux = &alc268_acer_dmic_capture_source,
13400 .unsol_event = alc268_acer_unsol_event,
13401 .init_hook = alc268_acer_init_hook,
13402 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013403 [ALC268_ACER_ASPIRE_ONE] = {
13404 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013405 alc268_beep_mixer,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013406 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013407 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13408 alc268_acer_aspire_one_verbs },
13409 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13410 .dac_nids = alc268_dac_nids,
13411 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13412 .adc_nids = alc268_adc_nids_alt,
13413 .capsrc_nids = alc268_capsrc_nids,
13414 .hp_nid = 0x03,
13415 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13416 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013417 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013418 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013419 .init_hook = alc268_acer_lc_init_hook,
13420 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013421 [ALC268_DELL] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013422 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13423 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013424 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13425 alc268_dell_verbs },
13426 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13427 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013428 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13429 .adc_nids = alc268_adc_nids_alt,
13430 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013431 .hp_nid = 0x02,
13432 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13433 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013434 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013435 .setup = alc268_dell_setup,
13436 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013437 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013438 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013439 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13440 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013441 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13442 alc268_toshiba_verbs },
13443 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13444 .dac_nids = alc268_dac_nids,
13445 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13446 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013447 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013448 .hp_nid = 0x03,
13449 .dig_out_nid = ALC268_DIGOUT_NID,
13450 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13451 .channel_mode = alc268_modes,
13452 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013453 .setup = alc268_toshiba_setup,
13454 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013455 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013456#ifdef CONFIG_SND_DEBUG
13457 [ALC268_TEST] = {
13458 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13459 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13460 alc268_volume_init_verbs },
13461 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13462 .dac_nids = alc268_dac_nids,
13463 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13464 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013465 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013466 .hp_nid = 0x03,
13467 .dig_out_nid = ALC268_DIGOUT_NID,
13468 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13469 .channel_mode = alc268_modes,
13470 .input_mux = &alc268_capture_source,
13471 },
13472#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013473};
13474
13475static int patch_alc268(struct hda_codec *codec)
13476{
13477 struct alc_spec *spec;
13478 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013479 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013480
Julia Lawallef86f582009-12-19 08:18:03 +010013481 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013482 if (spec == NULL)
13483 return -ENOMEM;
13484
13485 codec->spec = spec;
13486
13487 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13488 alc268_models,
13489 alc268_cfg_tbl);
13490
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013491 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13492 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013493 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013494
Kailang Yanga361d842007-06-05 12:30:55 +020013495 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013496 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13497 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013498 board_config = ALC268_AUTO;
13499 }
13500
13501 if (board_config == ALC268_AUTO) {
13502 /* automatic parse from the BIOS config */
13503 err = alc268_parse_auto_config(codec);
13504 if (err < 0) {
13505 alc_free(codec);
13506 return err;
13507 } else if (!err) {
13508 printk(KERN_INFO
13509 "hda_codec: Cannot set up configuration "
13510 "from BIOS. Using base mode...\n");
13511 board_config = ALC268_3ST;
13512 }
13513 }
13514
13515 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013516 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013517
Kailang Yanga361d842007-06-05 12:30:55 +020013518 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13519 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013520 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013521
Kailang Yanga361d842007-06-05 12:30:55 +020013522 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13523
Takashi Iwai22971e32009-02-10 11:56:44 +010013524 has_beep = 0;
13525 for (i = 0; i < spec->num_mixers; i++) {
13526 if (spec->mixers[i] == alc268_beep_mixer) {
13527 has_beep = 1;
13528 break;
13529 }
13530 }
13531
13532 if (has_beep) {
13533 err = snd_hda_attach_beep_device(codec, 0x1);
13534 if (err < 0) {
13535 alc_free(codec);
13536 return err;
13537 }
13538 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13539 /* override the amp caps for beep generator */
13540 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013541 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13542 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13543 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13544 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013545 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013546
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013547 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013548 /* check whether NID 0x07 is valid */
13549 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013550 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013551
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013552 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013553 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013554 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013555 if (spec->auto_mic ||
13556 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013557 spec->adc_nids = alc268_adc_nids_alt;
13558 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013559 if (spec->auto_mic)
13560 fixup_automic_adc(codec);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013561 if (spec->auto_mic || spec->input_mux->num_items == 1)
13562 add_mixer(spec, alc268_capture_nosrc_mixer);
13563 else
13564 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013565 } else {
13566 spec->adc_nids = alc268_adc_nids;
13567 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013568 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013569 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013570 /* set default input source */
13571 for (i = 0; i < spec->num_adc_nids; i++)
13572 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13573 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013574 i < spec->num_mux_defs ?
13575 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013576 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013577 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013578
13579 spec->vmaster_nid = 0x02;
13580
Kailang Yanga361d842007-06-05 12:30:55 +020013581 codec->patch_ops = alc_patch_ops;
13582 if (board_config == ALC268_AUTO)
13583 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013584
Kailang Yanga361d842007-06-05 12:30:55 +020013585 return 0;
13586}
13587
13588/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013589 * ALC269 channel source setting (2 channel)
13590 */
13591#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13592
13593#define alc269_dac_nids alc260_dac_nids
13594
13595static hda_nid_t alc269_adc_nids[1] = {
13596 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013597 0x08,
13598};
13599
Takashi Iwaie01bf502008-08-21 16:25:07 +020013600static hda_nid_t alc269_capsrc_nids[1] = {
13601 0x23,
13602};
13603
Kailang Yang84898e82010-02-04 14:16:14 +010013604static hda_nid_t alc269vb_adc_nids[1] = {
13605 /* ADC1 */
13606 0x09,
13607};
13608
13609static hda_nid_t alc269vb_capsrc_nids[1] = {
13610 0x22,
13611};
13612
Takashi Iwai66946352010-03-29 17:21:45 +020013613static hda_nid_t alc269_adc_candidates[] = {
13614 0x08, 0x09, 0x07,
13615};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013616
Kailang Yangf6a92242007-12-13 16:52:54 +010013617#define alc269_modes alc260_modes
13618#define alc269_capture_source alc880_lg_lw_capture_source
13619
13620static struct snd_kcontrol_new alc269_base_mixer[] = {
13621 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13622 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13623 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13624 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13626 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13627 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13628 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13629 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13630 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13631 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13632 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13633 { } /* end */
13634};
13635
Kailang Yang60db6b52008-08-26 13:13:00 +020013636static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13637 /* output mixer control */
13638 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13639 {
13640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13641 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013642 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013643 .info = snd_hda_mixer_amp_switch_info,
13644 .get = snd_hda_mixer_amp_switch_get,
13645 .put = alc268_acer_master_sw_put,
13646 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13647 },
13648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13650 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13651 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13652 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13653 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013654 { }
13655};
13656
Tony Vroon64154832008-11-06 15:08:49 +000013657static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13658 /* output mixer control */
13659 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13660 {
13661 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13662 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013663 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013664 .info = snd_hda_mixer_amp_switch_info,
13665 .get = snd_hda_mixer_amp_switch_get,
13666 .put = alc268_acer_master_sw_put,
13667 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13668 },
13669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13671 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13672 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13673 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13674 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13675 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13676 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13677 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013678 { }
13679};
13680
Kailang Yang84898e82010-02-04 14:16:14 +010013681static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013682 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013683 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013685 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013686 { } /* end */
13687};
13688
Kailang Yang84898e82010-02-04 14:16:14 +010013689static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13690 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13691 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13692 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13693 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13694 { } /* end */
13695};
13696
Kailang Yangf6a92242007-12-13 16:52:54 +010013697/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013698static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13699 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13700 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13701 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13702 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13703 { } /* end */
13704};
13705
13706static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013707 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13708 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013709 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13710 { } /* end */
13711};
13712
Kailang Yang84898e82010-02-04 14:16:14 +010013713static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13714 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13715 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13716 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13717 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13718 { } /* end */
13719};
13720
13721static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13722 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13723 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13724 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13725 { } /* end */
13726};
13727
Takashi Iwai26f5df22008-11-03 17:39:46 +010013728/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013729#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013730
Kailang Yang60db6b52008-08-26 13:13:00 +020013731static struct hda_verb alc269_quanta_fl1_verbs[] = {
13732 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13733 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13734 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13735 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13736 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13737 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13738 { }
13739};
13740
Tony Vroon64154832008-11-06 15:08:49 +000013741static struct hda_verb alc269_lifebook_verbs[] = {
13742 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13743 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13744 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13745 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13746 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13747 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13748 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13749 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13750 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13751 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13752 { }
13753};
13754
Kailang Yang60db6b52008-08-26 13:13:00 +020013755/* toggle speaker-output according to the hp-jack state */
13756static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13757{
13758 unsigned int present;
13759 unsigned char bits;
13760
Wu Fengguang864f92b2009-11-18 12:38:02 +080013761 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013762 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013763 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013764 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013765 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013766 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013767
13768 snd_hda_codec_write(codec, 0x20, 0,
13769 AC_VERB_SET_COEF_INDEX, 0x0c);
13770 snd_hda_codec_write(codec, 0x20, 0,
13771 AC_VERB_SET_PROC_COEF, 0x680);
13772
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, 0x480);
13777}
13778
Tony Vroon64154832008-11-06 15:08:49 +000013779/* toggle speaker-output according to the hp-jacks state */
13780static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13781{
13782 unsigned int present;
13783 unsigned char bits;
13784
13785 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013786 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013787
13788 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013789 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013790
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013791 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013792 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013793 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013794 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013795 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013796
13797 snd_hda_codec_write(codec, 0x20, 0,
13798 AC_VERB_SET_COEF_INDEX, 0x0c);
13799 snd_hda_codec_write(codec, 0x20, 0,
13800 AC_VERB_SET_PROC_COEF, 0x680);
13801
13802 snd_hda_codec_write(codec, 0x20, 0,
13803 AC_VERB_SET_COEF_INDEX, 0x0c);
13804 snd_hda_codec_write(codec, 0x20, 0,
13805 AC_VERB_SET_PROC_COEF, 0x480);
13806}
13807
Tony Vroon64154832008-11-06 15:08:49 +000013808static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13809{
13810 unsigned int present_laptop;
13811 unsigned int present_dock;
13812
Wu Fengguang864f92b2009-11-18 12:38:02 +080013813 present_laptop = snd_hda_jack_detect(codec, 0x18);
13814 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013815
13816 /* Laptop mic port overrides dock mic port, design decision */
13817 if (present_dock)
13818 snd_hda_codec_write(codec, 0x23, 0,
13819 AC_VERB_SET_CONNECT_SEL, 0x3);
13820 if (present_laptop)
13821 snd_hda_codec_write(codec, 0x23, 0,
13822 AC_VERB_SET_CONNECT_SEL, 0x0);
13823 if (!present_dock && !present_laptop)
13824 snd_hda_codec_write(codec, 0x23, 0,
13825 AC_VERB_SET_CONNECT_SEL, 0x1);
13826}
13827
Kailang Yang60db6b52008-08-26 13:13:00 +020013828static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13829 unsigned int res)
13830{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013831 switch (res >> 26) {
13832 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013833 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013834 break;
13835 case ALC880_MIC_EVENT:
13836 alc_mic_automute(codec);
13837 break;
13838 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013839}
13840
Tony Vroon64154832008-11-06 15:08:49 +000013841static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13842 unsigned int res)
13843{
13844 if ((res >> 26) == ALC880_HP_EVENT)
13845 alc269_lifebook_speaker_automute(codec);
13846 if ((res >> 26) == ALC880_MIC_EVENT)
13847 alc269_lifebook_mic_autoswitch(codec);
13848}
13849
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013850static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13851{
13852 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013853 spec->autocfg.hp_pins[0] = 0x15;
13854 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013855 spec->ext_mic.pin = 0x18;
13856 spec->ext_mic.mux_idx = 0;
13857 spec->int_mic.pin = 0x19;
13858 spec->int_mic.mux_idx = 1;
13859 spec->auto_mic = 1;
13860}
13861
Kailang Yang60db6b52008-08-26 13:13:00 +020013862static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13863{
13864 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013865 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013866}
13867
Tony Vroon64154832008-11-06 15:08:49 +000013868static void alc269_lifebook_init_hook(struct hda_codec *codec)
13869{
13870 alc269_lifebook_speaker_automute(codec);
13871 alc269_lifebook_mic_autoswitch(codec);
13872}
13873
Kailang Yang84898e82010-02-04 14:16:14 +010013874static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013875 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13876 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13877 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13878 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13879 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13880 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13881 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13882 {}
13883};
13884
Kailang Yang84898e82010-02-04 14:16:14 +010013885static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013886 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13887 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13888 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13890 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13891 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13892 {}
13893};
13894
Kailang Yang84898e82010-02-04 14:16:14 +010013895static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13896 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13897 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13898 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13899 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13900 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13901 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13902 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13903 {}
13904};
13905
13906static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13907 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13908 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13909 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13910 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13911 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13912 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13913 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13914 {}
13915};
13916
Kailang Yang60db6b52008-08-26 13:13:00 +020013917/* toggle speaker-output according to the hp-jack state */
13918static void alc269_speaker_automute(struct hda_codec *codec)
13919{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013920 struct alc_spec *spec = codec->spec;
13921 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013922 unsigned int present;
13923 unsigned char bits;
13924
Kailang Yangebb83ee2009-12-17 12:23:00 +010013925 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013926 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013927 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013928 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013929 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013930 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013931}
13932
Kailang Yang60db6b52008-08-26 13:13:00 +020013933/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013934static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013935 unsigned int res)
13936{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013937 switch (res >> 26) {
13938 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013939 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013940 break;
13941 case ALC880_MIC_EVENT:
13942 alc_mic_automute(codec);
13943 break;
13944 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013945}
13946
Kailang Yang226b1ec2010-04-09 11:01:20 +020013947static void alc269_laptop_amic_setup(struct hda_codec *codec)
13948{
13949 struct alc_spec *spec = codec->spec;
13950 spec->autocfg.hp_pins[0] = 0x15;
13951 spec->autocfg.speaker_pins[0] = 0x14;
13952 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 Yang84898e82010-02-04 14:16:14 +010013959static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013960{
13961 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013962 spec->autocfg.hp_pins[0] = 0x15;
13963 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013964 spec->ext_mic.pin = 0x18;
13965 spec->ext_mic.mux_idx = 0;
13966 spec->int_mic.pin = 0x12;
13967 spec->int_mic.mux_idx = 5;
13968 spec->auto_mic = 1;
13969}
13970
Kailang Yang226b1ec2010-04-09 11:01:20 +020013971static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010013972{
13973 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020013974 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010013975 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013976 spec->ext_mic.pin = 0x18;
13977 spec->ext_mic.mux_idx = 0;
13978 spec->int_mic.pin = 0x19;
13979 spec->int_mic.mux_idx = 1;
13980 spec->auto_mic = 1;
13981}
13982
Kailang Yang226b1ec2010-04-09 11:01:20 +020013983static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13984{
13985 struct alc_spec *spec = codec->spec;
13986 spec->autocfg.hp_pins[0] = 0x21;
13987 spec->autocfg.speaker_pins[0] = 0x14;
13988 spec->ext_mic.pin = 0x18;
13989 spec->ext_mic.mux_idx = 0;
13990 spec->int_mic.pin = 0x12;
13991 spec->int_mic.mux_idx = 6;
13992 spec->auto_mic = 1;
13993}
13994
Kailang Yang84898e82010-02-04 14:16:14 +010013995static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013996{
13997 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013998 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013999}
14000
Kailang Yangf6a92242007-12-13 16:52:54 +010014001/*
14002 * generic initialization of ADC, input mixers and output mixers
14003 */
14004static struct hda_verb alc269_init_verbs[] = {
14005 /*
14006 * Unmute ADC0 and set the default input to mic-in
14007 */
Kailang Yang84898e82010-02-04 14:16:14 +010014008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014009
14010 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014011 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014012 */
14013 /* set vol=0 to output mixers */
14014 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14015 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14016
14017 /* set up input amps for analog loopback */
14018 /* Amp Indices: DAC = 0, mixer = 1 */
14019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14022 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14023 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14025
14026 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14028 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14029 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14030 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14031 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14033
14034 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014036
Kailang Yang84898e82010-02-04 14:16:14 +010014037 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014038 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14039 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014040 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014041
14042 /* set EAPD */
14043 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014044 { }
14045};
14046
14047static struct hda_verb alc269vb_init_verbs[] = {
14048 /*
14049 * Unmute ADC0 and set the default input to mic-in
14050 */
14051 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14052
14053 /*
14054 * Set up output mixers (0x02 - 0x03)
14055 */
14056 /* set vol=0 to output mixers */
14057 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14058 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14059
14060 /* set up input amps for analog loopback */
14061 /* Amp Indices: DAC = 0, mixer = 1 */
14062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14063 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14065 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14066 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14067 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14068
14069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14070 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14071 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14072 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14073 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14074 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14075 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14076
14077 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14078 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14079
14080 /* FIXME: use Mux-type input source selection */
14081 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14082 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14083 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14084
14085 /* set EAPD */
14086 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014087 { }
14088};
14089
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014090#define alc269_auto_create_multi_out_ctls \
14091 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014092#define alc269_auto_create_input_ctls \
14093 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014094
14095#ifdef CONFIG_SND_HDA_POWER_SAVE
14096#define alc269_loopbacks alc880_loopbacks
14097#endif
14098
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014099/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014100#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14101#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14102#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14103#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14104
Takashi Iwaif03d3112009-03-05 14:18:16 +010014105static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14106 .substreams = 1,
14107 .channels_min = 2,
14108 .channels_max = 8,
14109 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14110 /* NID is set in alc_build_pcms */
14111 .ops = {
14112 .open = alc880_playback_pcm_open,
14113 .prepare = alc880_playback_pcm_prepare,
14114 .cleanup = alc880_playback_pcm_cleanup
14115 },
14116};
14117
14118static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14119 .substreams = 1,
14120 .channels_min = 2,
14121 .channels_max = 2,
14122 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14123 /* NID is set in alc_build_pcms */
14124};
14125
Takashi Iwaiad358792010-03-30 18:00:59 +020014126#ifdef CONFIG_SND_HDA_POWER_SAVE
14127static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14128{
14129 switch (codec->subsystem_id) {
14130 case 0x103c1586:
14131 return 1;
14132 }
14133 return 0;
14134}
14135
14136static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14137{
14138 /* update mute-LED according to the speaker mute state */
14139 if (nid == 0x01 || nid == 0x14) {
14140 int pinval;
14141 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14142 HDA_AMP_MUTE)
14143 pinval = 0x24;
14144 else
14145 pinval = 0x20;
14146 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014147 snd_hda_codec_update_cache(codec, 0x19, 0,
14148 AC_VERB_SET_PIN_WIDGET_CONTROL,
14149 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014150 }
14151 return alc_check_power_status(codec, nid);
14152}
14153#endif /* CONFIG_SND_HDA_POWER_SAVE */
14154
Kailang Yangf6a92242007-12-13 16:52:54 +010014155/*
14156 * BIOS auto configuration
14157 */
14158static int alc269_parse_auto_config(struct hda_codec *codec)
14159{
14160 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014161 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014162 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14163
14164 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14165 alc269_ignore);
14166 if (err < 0)
14167 return err;
14168
14169 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14170 if (err < 0)
14171 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014172 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014173 if (err < 0)
14174 return err;
14175
14176 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14177
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014178 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010014179 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
14180
Takashi Iwai603c4012008-07-30 15:01:44 +020014181 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014182 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014183
Kailang Yang84898e82010-02-04 14:16:14 +010014184 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14185 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014186 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014187 } else {
14188 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014189 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014190 }
14191
Kailang Yangf6a92242007-12-13 16:52:54 +010014192 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014193 spec->input_mux = &spec->private_imux[0];
Takashi Iwai66946352010-03-29 17:21:45 +020014194 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14195 sizeof(alc269_adc_candidates));
14196
Takashi Iwaie01bf502008-08-21 16:25:07 +020014197 /* set default input source */
Takashi Iwai66946352010-03-29 17:21:45 +020014198 snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
Takashi Iwaie01bf502008-08-21 16:25:07 +020014199 0, AC_VERB_SET_CONNECT_SEL,
14200 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014201
14202 err = alc_auto_add_mic_boost(codec);
14203 if (err < 0)
14204 return err;
14205
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014206 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014207 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014208
Kailang Yangf6a92242007-12-13 16:52:54 +010014209 return 1;
14210}
14211
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014212#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14213#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014214#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14215
14216
14217/* init callback for auto-configuration model -- overriding the default init */
14218static void alc269_auto_init(struct hda_codec *codec)
14219{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014220 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014221 alc269_auto_init_multi_out(codec);
14222 alc269_auto_init_hp_out(codec);
14223 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014224 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014225 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014226}
14227
Takashi Iwaiff818c22010-04-12 08:59:25 +020014228enum {
14229 ALC269_FIXUP_SONY_VAIO,
14230};
14231
Tobias Klauserfbc25662010-05-20 10:40:55 +020014232static const struct hda_verb alc269_sony_vaio_fixup_verbs[] = {
Takashi Iwaiff818c22010-04-12 08:59:25 +020014233 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14234 {}
14235};
14236
14237static const struct alc_fixup alc269_fixups[] = {
14238 [ALC269_FIXUP_SONY_VAIO] = {
14239 .verbs = alc269_sony_vaio_fixup_verbs
14240 },
14241};
14242
14243static struct snd_pci_quirk alc269_fixup_tbl[] = {
14244 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
14245 {}
14246};
14247
14248
Kailang Yangf6a92242007-12-13 16:52:54 +010014249/*
14250 * configuration and preset
14251 */
14252static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014253 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014254 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014255 [ALC269_AMIC] = "laptop-amic",
14256 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014257 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014258 [ALC269_LIFEBOOK] = "lifebook",
14259 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014260};
14261
14262static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014263 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020014264 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014265 ALC269_AMIC),
14266 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14267 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14268 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14269 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14270 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14271 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14272 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14273 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14274 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14275 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14276 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14277 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14278 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14279 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14280 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14281 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14282 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14283 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14284 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14285 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14286 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14287 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14288 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14289 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14290 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14291 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14292 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14293 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14294 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14295 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14296 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14297 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14298 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14299 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14300 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14301 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014302 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014303 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014304 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014305 ALC269_DMIC),
14306 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14307 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014308 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014309 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014310 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14311 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14312 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14313 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14314 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14315 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014316 {}
14317};
14318
14319static struct alc_config_preset alc269_presets[] = {
14320 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014321 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014322 .init_verbs = { alc269_init_verbs },
14323 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14324 .dac_nids = alc269_dac_nids,
14325 .hp_nid = 0x03,
14326 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14327 .channel_mode = alc269_modes,
14328 .input_mux = &alc269_capture_source,
14329 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014330 [ALC269_QUANTA_FL1] = {
14331 .mixers = { alc269_quanta_fl1_mixer },
14332 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14333 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14334 .dac_nids = alc269_dac_nids,
14335 .hp_nid = 0x03,
14336 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14337 .channel_mode = alc269_modes,
14338 .input_mux = &alc269_capture_source,
14339 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014340 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014341 .init_hook = alc269_quanta_fl1_init_hook,
14342 },
Kailang Yang84898e82010-02-04 14:16:14 +010014343 [ALC269_AMIC] = {
14344 .mixers = { alc269_laptop_mixer },
14345 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014346 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014347 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014348 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14349 .dac_nids = alc269_dac_nids,
14350 .hp_nid = 0x03,
14351 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14352 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014353 .unsol_event = alc269_laptop_unsol_event,
14354 .setup = alc269_laptop_amic_setup,
14355 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014356 },
Kailang Yang84898e82010-02-04 14:16:14 +010014357 [ALC269_DMIC] = {
14358 .mixers = { alc269_laptop_mixer },
14359 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014360 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014361 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014362 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14363 .dac_nids = alc269_dac_nids,
14364 .hp_nid = 0x03,
14365 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14366 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014367 .unsol_event = alc269_laptop_unsol_event,
14368 .setup = alc269_laptop_dmic_setup,
14369 .init_hook = alc269_laptop_inithook,
14370 },
14371 [ALC269VB_AMIC] = {
14372 .mixers = { alc269vb_laptop_mixer },
14373 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14374 .init_verbs = { alc269vb_init_verbs,
14375 alc269vb_laptop_amic_init_verbs },
14376 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14377 .dac_nids = alc269_dac_nids,
14378 .hp_nid = 0x03,
14379 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14380 .channel_mode = alc269_modes,
14381 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014382 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014383 .init_hook = alc269_laptop_inithook,
14384 },
14385 [ALC269VB_DMIC] = {
14386 .mixers = { alc269vb_laptop_mixer },
14387 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14388 .init_verbs = { alc269vb_init_verbs,
14389 alc269vb_laptop_dmic_init_verbs },
14390 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14391 .dac_nids = alc269_dac_nids,
14392 .hp_nid = 0x03,
14393 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14394 .channel_mode = alc269_modes,
14395 .unsol_event = alc269_laptop_unsol_event,
14396 .setup = alc269vb_laptop_dmic_setup,
14397 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014398 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014399 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014400 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014401 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014402 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014403 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014404 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14405 .dac_nids = alc269_dac_nids,
14406 .hp_nid = 0x03,
14407 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14408 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014409 .unsol_event = alc269_laptop_unsol_event,
14410 .setup = alc269_laptop_dmic_setup,
14411 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014412 },
Tony Vroon64154832008-11-06 15:08:49 +000014413 [ALC269_LIFEBOOK] = {
14414 .mixers = { alc269_lifebook_mixer },
14415 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14416 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14417 .dac_nids = alc269_dac_nids,
14418 .hp_nid = 0x03,
14419 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14420 .channel_mode = alc269_modes,
14421 .input_mux = &alc269_capture_source,
14422 .unsol_event = alc269_lifebook_unsol_event,
14423 .init_hook = alc269_lifebook_init_hook,
14424 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014425};
14426
14427static int patch_alc269(struct hda_codec *codec)
14428{
14429 struct alc_spec *spec;
14430 int board_config;
14431 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014432 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014433
14434 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14435 if (spec == NULL)
14436 return -ENOMEM;
14437
14438 codec->spec = spec;
14439
Kailang Yangda00c242010-03-19 11:23:45 +010014440 alc_auto_parse_customize_define(codec);
14441
Kailang Yang274693f2009-12-03 10:07:50 +010014442 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014443 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14444 spec->cdefine.platform_type == 1)
14445 alc_codec_rename(codec, "ALC271X");
14446 else
14447 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014448 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014449 } else
14450 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014451
Kailang Yangf6a92242007-12-13 16:52:54 +010014452 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14453 alc269_models,
14454 alc269_cfg_tbl);
14455
14456 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014457 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14458 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014459 board_config = ALC269_AUTO;
14460 }
14461
Takashi Iwaiff818c22010-04-12 08:59:25 +020014462 if (board_config == ALC269_AUTO)
14463 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14464
Kailang Yangf6a92242007-12-13 16:52:54 +010014465 if (board_config == ALC269_AUTO) {
14466 /* automatic parse from the BIOS config */
14467 err = alc269_parse_auto_config(codec);
14468 if (err < 0) {
14469 alc_free(codec);
14470 return err;
14471 } else if (!err) {
14472 printk(KERN_INFO
14473 "hda_codec: Cannot set up configuration "
14474 "from BIOS. Using base mode...\n");
14475 board_config = ALC269_BASIC;
14476 }
14477 }
14478
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014479 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020014480 err = snd_hda_attach_beep_device(codec, 0x1);
14481 if (err < 0) {
14482 alc_free(codec);
14483 return err;
14484 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014485 }
14486
Kailang Yangf6a92242007-12-13 16:52:54 +010014487 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014488 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014489
Kailang Yang84898e82010-02-04 14:16:14 +010014490 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014491 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14492 * fix the sample rate of analog I/O to 44.1kHz
14493 */
14494 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14495 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14496 } else {
14497 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14498 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14499 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014500 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14501 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14502
Takashi Iwai66946352010-03-29 17:21:45 +020014503 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14504 if (!is_alc269vb) {
14505 spec->adc_nids = alc269_adc_nids;
14506 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14507 spec->capsrc_nids = alc269_capsrc_nids;
14508 } else {
14509 spec->adc_nids = alc269vb_adc_nids;
14510 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14511 spec->capsrc_nids = alc269vb_capsrc_nids;
14512 }
Kailang Yang84898e82010-02-04 14:16:14 +010014513 }
14514
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014515 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014516 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014517 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010014518 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014519
Takashi Iwaiff818c22010-04-12 08:59:25 +020014520 if (board_config == ALC269_AUTO)
14521 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14522
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014523 spec->vmaster_nid = 0x02;
14524
Kailang Yangf6a92242007-12-13 16:52:54 +010014525 codec->patch_ops = alc_patch_ops;
14526 if (board_config == ALC269_AUTO)
14527 spec->init_hook = alc269_auto_init;
14528#ifdef CONFIG_SND_HDA_POWER_SAVE
14529 if (!spec->loopback.amplist)
14530 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014531 if (alc269_mic2_for_mute_led(codec))
14532 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014533#endif
14534
14535 return 0;
14536}
14537
14538/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014539 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14540 */
14541
14542/*
14543 * set the path ways for 2 channel output
14544 * need to set the codec line out and mic 1 pin widgets to inputs
14545 */
14546static struct hda_verb alc861_threestack_ch2_init[] = {
14547 /* set pin widget 1Ah (line in) for input */
14548 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014549 /* set pin widget 18h (mic1/2) for input, for mic also enable
14550 * the vref
14551 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014552 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14553
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014554 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14555#if 0
14556 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14557 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14558#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014559 { } /* end */
14560};
14561/*
14562 * 6ch mode
14563 * need to set the codec line out and mic 1 pin widgets to outputs
14564 */
14565static struct hda_verb alc861_threestack_ch6_init[] = {
14566 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14567 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14568 /* set pin widget 18h (mic1) for output (CLFE)*/
14569 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14570
14571 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014572 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014573
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014574 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14575#if 0
14576 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14577 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14578#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014579 { } /* end */
14580};
14581
14582static struct hda_channel_mode alc861_threestack_modes[2] = {
14583 { 2, alc861_threestack_ch2_init },
14584 { 6, alc861_threestack_ch6_init },
14585};
Takashi Iwai22309c32006-08-09 16:57:28 +020014586/* Set mic1 as input and unmute the mixer */
14587static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14588 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14589 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14590 { } /* end */
14591};
14592/* Set mic1 as output and mute mixer */
14593static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14594 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14595 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14596 { } /* end */
14597};
14598
14599static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14600 { 2, alc861_uniwill_m31_ch2_init },
14601 { 4, alc861_uniwill_m31_ch4_init },
14602};
Kailang Yangdf694da2005-12-05 19:42:22 +010014603
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014604/* Set mic1 and line-in as input and unmute the mixer */
14605static struct hda_verb alc861_asus_ch2_init[] = {
14606 /* set pin widget 1Ah (line in) for input */
14607 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014608 /* set pin widget 18h (mic1/2) for input, for mic also enable
14609 * the vref
14610 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014611 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14612
14613 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14614#if 0
14615 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14616 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14617#endif
14618 { } /* end */
14619};
14620/* Set mic1 nad line-in as output and mute mixer */
14621static struct hda_verb alc861_asus_ch6_init[] = {
14622 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14623 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14624 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14625 /* set pin widget 18h (mic1) for output (CLFE)*/
14626 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14627 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14628 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14629 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14630
14631 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14632#if 0
14633 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14634 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14635#endif
14636 { } /* end */
14637};
14638
14639static struct hda_channel_mode alc861_asus_modes[2] = {
14640 { 2, alc861_asus_ch2_init },
14641 { 6, alc861_asus_ch6_init },
14642};
14643
Kailang Yangdf694da2005-12-05 19:42:22 +010014644/* patch-ALC861 */
14645
14646static struct snd_kcontrol_new alc861_base_mixer[] = {
14647 /* output mixer control */
14648 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14649 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14650 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14651 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14652 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14653
14654 /*Input mixer control */
14655 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14656 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14657 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14658 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14659 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14660 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14661 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14662 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14663 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014665
Kailang Yangdf694da2005-12-05 19:42:22 +010014666 { } /* end */
14667};
14668
14669static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14670 /* output mixer control */
14671 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14672 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14673 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14674 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14675 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14676
14677 /* Input mixer control */
14678 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14679 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14680 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14681 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14682 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14683 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14685 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14686 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14687 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014688
Kailang Yangdf694da2005-12-05 19:42:22 +010014689 {
14690 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14691 .name = "Channel Mode",
14692 .info = alc_ch_mode_info,
14693 .get = alc_ch_mode_get,
14694 .put = alc_ch_mode_put,
14695 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14696 },
14697 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014698};
14699
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014700static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014701 /* output mixer control */
14702 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14704 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014705
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014706 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014707};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014708
Takashi Iwai22309c32006-08-09 16:57:28 +020014709static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14710 /* output mixer control */
14711 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14712 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14713 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14714 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14715 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14716
14717 /* Input mixer control */
14718 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14719 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14720 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14721 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14722 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14723 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14725 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14726 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14727 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014728
Takashi Iwai22309c32006-08-09 16:57:28 +020014729 {
14730 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14731 .name = "Channel Mode",
14732 .info = alc_ch_mode_info,
14733 .get = alc_ch_mode_get,
14734 .put = alc_ch_mode_put,
14735 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14736 },
14737 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014738};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014739
14740static struct snd_kcontrol_new alc861_asus_mixer[] = {
14741 /* output mixer control */
14742 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14743 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14744 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14745 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14746 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14747
14748 /* Input mixer control */
14749 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14750 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14751 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14752 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14753 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14754 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14756 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14757 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14759
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014760 {
14761 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14762 .name = "Channel Mode",
14763 .info = alc_ch_mode_info,
14764 .get = alc_ch_mode_get,
14765 .put = alc_ch_mode_put,
14766 .private_value = ARRAY_SIZE(alc861_asus_modes),
14767 },
14768 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014769};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014770
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014771/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014772static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014773 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14774 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014775 { }
14776};
14777
Kailang Yangdf694da2005-12-05 19:42:22 +010014778/*
14779 * generic initialization of ADC, input mixers and output mixers
14780 */
14781static struct hda_verb alc861_base_init_verbs[] = {
14782 /*
14783 * Unmute ADC0 and set the default input to mic-in
14784 */
14785 /* port-A for surround (rear panel) */
14786 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14787 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14788 /* port-B for mic-in (rear panel) with vref */
14789 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14790 /* port-C for line-in (rear panel) */
14791 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14792 /* port-D for Front */
14793 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14794 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14795 /* port-E for HP out (front panel) */
14796 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14797 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014798 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014799 /* port-F for mic-in (front panel) with vref */
14800 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14801 /* port-G for CLFE (rear panel) */
14802 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14803 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14804 /* port-H for side (rear panel) */
14805 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14806 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14807 /* CD-in */
14808 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14809 /* route front mic to ADC1*/
14810 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14811 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014812
Kailang Yangdf694da2005-12-05 19:42:22 +010014813 /* Unmute DAC0~3 & spdif out*/
14814 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14815 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14816 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14817 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014819
Kailang Yangdf694da2005-12-05 19:42:22 +010014820 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14821 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14822 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14823 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14824 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014825
Kailang Yangdf694da2005-12-05 19:42:22 +010014826 /* Unmute Stereo Mixer 15 */
14827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014831
14832 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14833 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14834 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14835 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14836 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14839 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014840 /* hp used DAC 3 (Front) */
14841 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14843
14844 { }
14845};
14846
14847static struct hda_verb alc861_threestack_init_verbs[] = {
14848 /*
14849 * Unmute ADC0 and set the default input to mic-in
14850 */
14851 /* port-A for surround (rear panel) */
14852 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14853 /* port-B for mic-in (rear panel) with vref */
14854 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14855 /* port-C for line-in (rear panel) */
14856 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14857 /* port-D for Front */
14858 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14859 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14860 /* port-E for HP out (front panel) */
14861 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14862 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014863 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014864 /* port-F for mic-in (front panel) with vref */
14865 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14866 /* port-G for CLFE (rear panel) */
14867 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14868 /* port-H for side (rear panel) */
14869 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14870 /* CD-in */
14871 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14872 /* route front mic to ADC1*/
14873 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14874 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14875 /* Unmute DAC0~3 & spdif out*/
14876 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14877 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14878 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14879 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14880 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014881
Kailang Yangdf694da2005-12-05 19:42:22 +010014882 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14883 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14884 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14885 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14886 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014887
Kailang Yangdf694da2005-12-05 19:42:22 +010014888 /* Unmute Stereo Mixer 15 */
14889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14890 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14891 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014893
14894 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14895 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14896 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14897 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14898 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14899 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14900 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14901 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014902 /* hp used DAC 3 (Front) */
14903 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014904 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14905 { }
14906};
Takashi Iwai22309c32006-08-09 16:57:28 +020014907
14908static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14909 /*
14910 * Unmute ADC0 and set the default input to mic-in
14911 */
14912 /* port-A for surround (rear panel) */
14913 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14914 /* port-B for mic-in (rear panel) with vref */
14915 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14916 /* port-C for line-in (rear panel) */
14917 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14918 /* port-D for Front */
14919 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14920 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14921 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014922 /* this has to be set to VREF80 */
14923 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014924 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014925 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014926 /* port-F for mic-in (front panel) with vref */
14927 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14928 /* port-G for CLFE (rear panel) */
14929 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14930 /* port-H for side (rear panel) */
14931 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14932 /* CD-in */
14933 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14934 /* route front mic to ADC1*/
14935 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14936 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14937 /* Unmute DAC0~3 & spdif out*/
14938 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14939 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14940 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14941 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014943
Takashi Iwai22309c32006-08-09 16:57:28 +020014944 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14945 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14946 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14947 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14948 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014949
Takashi Iwai22309c32006-08-09 16:57:28 +020014950 /* Unmute Stereo Mixer 15 */
14951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14952 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14953 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014955
14956 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14957 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14958 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14959 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14960 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14961 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14962 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14963 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014964 /* hp used DAC 3 (Front) */
14965 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014966 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14967 { }
14968};
14969
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014970static struct hda_verb alc861_asus_init_verbs[] = {
14971 /*
14972 * Unmute ADC0 and set the default input to mic-in
14973 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014974 /* port-A for surround (rear panel)
14975 * according to codec#0 this is the HP jack
14976 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014977 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14978 /* route front PCM to HP */
14979 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14980 /* port-B for mic-in (rear panel) with vref */
14981 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14982 /* port-C for line-in (rear panel) */
14983 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14984 /* port-D for Front */
14985 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14986 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14987 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014988 /* this has to be set to VREF80 */
14989 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014990 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014991 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014992 /* port-F for mic-in (front panel) with vref */
14993 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14994 /* port-G for CLFE (rear panel) */
14995 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14996 /* port-H for side (rear panel) */
14997 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14998 /* CD-in */
14999 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15000 /* route front mic to ADC1*/
15001 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15002 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15003 /* Unmute DAC0~3 & spdif out*/
15004 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15005 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15006 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15007 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15008 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15009 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15010 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15011 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15012 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15013 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015014
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015015 /* Unmute Stereo Mixer 15 */
15016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15017 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15018 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015020
15021 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15022 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15023 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15024 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15025 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15026 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15027 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015029 /* hp used DAC 3 (Front) */
15030 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015031 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15032 { }
15033};
15034
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015035/* additional init verbs for ASUS laptops */
15036static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15037 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15038 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15039 { }
15040};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015041
Kailang Yangdf694da2005-12-05 19:42:22 +010015042/*
15043 * generic initialization of ADC, input mixers and output mixers
15044 */
15045static struct hda_verb alc861_auto_init_verbs[] = {
15046 /*
15047 * Unmute ADC0 and set the default input to mic-in
15048 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015049 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015050 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015051
Kailang Yangdf694da2005-12-05 19:42:22 +010015052 /* Unmute DAC0~3 & spdif out*/
15053 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15054 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15055 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15056 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015058
Kailang Yangdf694da2005-12-05 19:42:22 +010015059 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15060 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15061 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15062 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15063 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015064
Kailang Yangdf694da2005-12-05 19:42:22 +010015065 /* Unmute Stereo Mixer 15 */
15066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15070
Takashi Iwai1c209302009-07-22 15:17:45 +020015071 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15072 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15073 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15074 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15076 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15077 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15078 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015079
15080 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15081 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015082 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15083 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015084 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15085 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015086 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15087 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015088
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015089 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015090
15091 { }
15092};
15093
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015094static struct hda_verb alc861_toshiba_init_verbs[] = {
15095 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015096
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015097 { }
15098};
15099
15100/* toggle speaker-output according to the hp-jack state */
15101static void alc861_toshiba_automute(struct hda_codec *codec)
15102{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015103 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015104
Takashi Iwai47fd8302007-08-10 17:11:07 +020015105 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15106 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15107 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15108 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015109}
15110
15111static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15112 unsigned int res)
15113{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015114 if ((res >> 26) == ALC880_HP_EVENT)
15115 alc861_toshiba_automute(codec);
15116}
15117
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015118/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015119#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15120#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15121#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15122#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15123
15124
15125#define ALC861_DIGOUT_NID 0x07
15126
15127static struct hda_channel_mode alc861_8ch_modes[1] = {
15128 { 8, NULL }
15129};
15130
15131static hda_nid_t alc861_dac_nids[4] = {
15132 /* front, surround, clfe, side */
15133 0x03, 0x06, 0x05, 0x04
15134};
15135
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015136static hda_nid_t alc660_dac_nids[3] = {
15137 /* front, clfe, surround */
15138 0x03, 0x05, 0x06
15139};
15140
Kailang Yangdf694da2005-12-05 19:42:22 +010015141static hda_nid_t alc861_adc_nids[1] = {
15142 /* ADC0-2 */
15143 0x08,
15144};
15145
15146static struct hda_input_mux alc861_capture_source = {
15147 .num_items = 5,
15148 .items = {
15149 { "Mic", 0x0 },
15150 { "Front Mic", 0x3 },
15151 { "Line", 0x1 },
15152 { "CD", 0x4 },
15153 { "Mixer", 0x5 },
15154 },
15155};
15156
Takashi Iwai1c209302009-07-22 15:17:45 +020015157static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15158{
15159 struct alc_spec *spec = codec->spec;
15160 hda_nid_t mix, srcs[5];
15161 int i, j, num;
15162
15163 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15164 return 0;
15165 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15166 if (num < 0)
15167 return 0;
15168 for (i = 0; i < num; i++) {
15169 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015170 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015171 if (type != AC_WID_AUD_OUT)
15172 continue;
15173 for (j = 0; j < spec->multiout.num_dacs; j++)
15174 if (spec->multiout.dac_nids[j] == srcs[i])
15175 break;
15176 if (j >= spec->multiout.num_dacs)
15177 return srcs[i];
15178 }
15179 return 0;
15180}
15181
Kailang Yangdf694da2005-12-05 19:42:22 +010015182/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015183static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015184 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015185{
Takashi Iwai1c209302009-07-22 15:17:45 +020015186 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015187 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015188 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015189
15190 spec->multiout.dac_nids = spec->private_dac_nids;
15191 for (i = 0; i < cfg->line_outs; i++) {
15192 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015193 dac = alc861_look_for_dac(codec, nid);
15194 if (!dac)
15195 continue;
15196 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015197 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015198 return 0;
15199}
15200
Takashi Iwai1c209302009-07-22 15:17:45 +020015201static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15202 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015203{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015204 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015205 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15206}
15207
15208/* add playback controls from the parsed DAC table */
15209static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15210 const struct auto_pin_cfg *cfg)
15211{
15212 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015213 static const char *chname[4] = {
15214 "Front", "Surround", NULL /*CLFE*/, "Side"
15215 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015216 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015217 int i, err;
15218
15219 if (cfg->line_outs == 1) {
15220 const char *pfx = NULL;
15221 if (!cfg->hp_outs)
15222 pfx = "Master";
15223 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15224 pfx = "Speaker";
15225 if (pfx) {
15226 nid = spec->multiout.dac_nids[0];
15227 return alc861_create_out_sw(codec, pfx, nid, 3);
15228 }
15229 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015230
15231 for (i = 0; i < cfg->line_outs; i++) {
15232 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015233 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015234 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015235 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015236 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015237 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015238 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015239 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015240 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015241 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015242 return err;
15243 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015244 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015245 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015246 return err;
15247 }
15248 }
15249 return 0;
15250}
15251
Takashi Iwai1c209302009-07-22 15:17:45 +020015252static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015253{
Takashi Iwai1c209302009-07-22 15:17:45 +020015254 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015255 int err;
15256 hda_nid_t nid;
15257
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015258 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015259 return 0;
15260
15261 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015262 nid = alc861_look_for_dac(codec, pin);
15263 if (nid) {
15264 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15265 if (err < 0)
15266 return err;
15267 spec->multiout.hp_nid = nid;
15268 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015269 }
15270 return 0;
15271}
15272
15273/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015274static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015275 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015276{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015277 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015278}
15279
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015280static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15281 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015282 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015283{
Takashi Iwai1c209302009-07-22 15:17:45 +020015284 hda_nid_t mix, srcs[5];
15285 int i, num;
15286
Jacek Luczak564c5be2008-05-03 18:41:23 +020015287 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15288 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015289 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015290 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015291 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15292 return;
15293 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15294 if (num < 0)
15295 return;
15296 for (i = 0; i < num; i++) {
15297 unsigned int mute;
15298 if (srcs[i] == dac || srcs[i] == 0x15)
15299 mute = AMP_IN_UNMUTE(i);
15300 else
15301 mute = AMP_IN_MUTE(i);
15302 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15303 mute);
15304 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015305}
15306
15307static void alc861_auto_init_multi_out(struct hda_codec *codec)
15308{
15309 struct alc_spec *spec = codec->spec;
15310 int i;
15311
15312 for (i = 0; i < spec->autocfg.line_outs; i++) {
15313 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015314 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015315 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015316 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015317 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015318 }
15319}
15320
15321static void alc861_auto_init_hp_out(struct hda_codec *codec)
15322{
15323 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015324
Takashi Iwai15870f02009-10-05 08:25:13 +020015325 if (spec->autocfg.hp_outs)
15326 alc861_auto_set_output_and_unmute(codec,
15327 spec->autocfg.hp_pins[0],
15328 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015329 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015330 if (spec->autocfg.speaker_outs)
15331 alc861_auto_set_output_and_unmute(codec,
15332 spec->autocfg.speaker_pins[0],
15333 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015334 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015335}
15336
15337static void alc861_auto_init_analog_input(struct hda_codec *codec)
15338{
15339 struct alc_spec *spec = codec->spec;
15340 int i;
15341
15342 for (i = 0; i < AUTO_PIN_LAST; i++) {
15343 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015344 if (nid >= 0x0c && nid <= 0x11)
15345 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015346 }
15347}
15348
15349/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015350/* return 1 if successful, 0 if the proper config is not found,
15351 * or a negative error code
15352 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015353static int alc861_parse_auto_config(struct hda_codec *codec)
15354{
15355 struct alc_spec *spec = codec->spec;
15356 int err;
15357 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15358
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015359 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15360 alc861_ignore);
15361 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015362 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015363 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015364 return 0; /* can't find valid BIOS pin config */
15365
Takashi Iwai1c209302009-07-22 15:17:45 +020015366 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015367 if (err < 0)
15368 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015369 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015370 if (err < 0)
15371 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015372 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015373 if (err < 0)
15374 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015375 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015376 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015377 return err;
15378
15379 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15380
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015381 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015382 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15383
Takashi Iwai603c4012008-07-30 15:01:44 +020015384 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015385 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015386
Takashi Iwaid88897e2008-10-31 15:01:37 +010015387 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015388
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015389 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015390 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015391
15392 spec->adc_nids = alc861_adc_nids;
15393 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015394 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015395
Kailang Yang6227cdc2010-02-25 08:36:52 +010015396 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015397
Kailang Yangdf694da2005-12-05 19:42:22 +010015398 return 1;
15399}
15400
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015401/* additional initialization for auto-configuration model */
15402static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015403{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015404 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015405 alc861_auto_init_multi_out(codec);
15406 alc861_auto_init_hp_out(codec);
15407 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015408 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015409 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015410}
15411
Takashi Iwaicb53c622007-08-10 17:21:45 +020015412#ifdef CONFIG_SND_HDA_POWER_SAVE
15413static struct hda_amp_list alc861_loopbacks[] = {
15414 { 0x15, HDA_INPUT, 0 },
15415 { 0x15, HDA_INPUT, 1 },
15416 { 0x15, HDA_INPUT, 2 },
15417 { 0x15, HDA_INPUT, 3 },
15418 { } /* end */
15419};
15420#endif
15421
Kailang Yangdf694da2005-12-05 19:42:22 +010015422
15423/*
15424 * configuration and preset
15425 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015426static const char *alc861_models[ALC861_MODEL_LAST] = {
15427 [ALC861_3ST] = "3stack",
15428 [ALC660_3ST] = "3stack-660",
15429 [ALC861_3ST_DIG] = "3stack-dig",
15430 [ALC861_6ST_DIG] = "6stack-dig",
15431 [ALC861_UNIWILL_M31] = "uniwill-m31",
15432 [ALC861_TOSHIBA] = "toshiba",
15433 [ALC861_ASUS] = "asus",
15434 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15435 [ALC861_AUTO] = "auto",
15436};
15437
15438static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015439 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015440 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15441 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15442 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015443 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015444 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015445 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015446 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15447 * Any other models that need this preset?
15448 */
15449 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015450 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15451 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015452 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15453 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15454 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15455 /* FIXME: the below seems conflict */
15456 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15457 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15458 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015459 {}
15460};
15461
15462static struct alc_config_preset alc861_presets[] = {
15463 [ALC861_3ST] = {
15464 .mixers = { alc861_3ST_mixer },
15465 .init_verbs = { alc861_threestack_init_verbs },
15466 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15467 .dac_nids = alc861_dac_nids,
15468 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15469 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015470 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015471 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15472 .adc_nids = alc861_adc_nids,
15473 .input_mux = &alc861_capture_source,
15474 },
15475 [ALC861_3ST_DIG] = {
15476 .mixers = { alc861_base_mixer },
15477 .init_verbs = { alc861_threestack_init_verbs },
15478 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15479 .dac_nids = alc861_dac_nids,
15480 .dig_out_nid = ALC861_DIGOUT_NID,
15481 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15482 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015483 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015484 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15485 .adc_nids = alc861_adc_nids,
15486 .input_mux = &alc861_capture_source,
15487 },
15488 [ALC861_6ST_DIG] = {
15489 .mixers = { alc861_base_mixer },
15490 .init_verbs = { alc861_base_init_verbs },
15491 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15492 .dac_nids = alc861_dac_nids,
15493 .dig_out_nid = ALC861_DIGOUT_NID,
15494 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15495 .channel_mode = alc861_8ch_modes,
15496 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15497 .adc_nids = alc861_adc_nids,
15498 .input_mux = &alc861_capture_source,
15499 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015500 [ALC660_3ST] = {
15501 .mixers = { alc861_3ST_mixer },
15502 .init_verbs = { alc861_threestack_init_verbs },
15503 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15504 .dac_nids = alc660_dac_nids,
15505 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15506 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015507 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015508 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15509 .adc_nids = alc861_adc_nids,
15510 .input_mux = &alc861_capture_source,
15511 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015512 [ALC861_UNIWILL_M31] = {
15513 .mixers = { alc861_uniwill_m31_mixer },
15514 .init_verbs = { alc861_uniwill_m31_init_verbs },
15515 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15516 .dac_nids = alc861_dac_nids,
15517 .dig_out_nid = ALC861_DIGOUT_NID,
15518 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15519 .channel_mode = alc861_uniwill_m31_modes,
15520 .need_dac_fix = 1,
15521 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15522 .adc_nids = alc861_adc_nids,
15523 .input_mux = &alc861_capture_source,
15524 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015525 [ALC861_TOSHIBA] = {
15526 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015527 .init_verbs = { alc861_base_init_verbs,
15528 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015529 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15530 .dac_nids = alc861_dac_nids,
15531 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15532 .channel_mode = alc883_3ST_2ch_modes,
15533 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15534 .adc_nids = alc861_adc_nids,
15535 .input_mux = &alc861_capture_source,
15536 .unsol_event = alc861_toshiba_unsol_event,
15537 .init_hook = alc861_toshiba_automute,
15538 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015539 [ALC861_ASUS] = {
15540 .mixers = { alc861_asus_mixer },
15541 .init_verbs = { alc861_asus_init_verbs },
15542 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15543 .dac_nids = alc861_dac_nids,
15544 .dig_out_nid = ALC861_DIGOUT_NID,
15545 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15546 .channel_mode = alc861_asus_modes,
15547 .need_dac_fix = 1,
15548 .hp_nid = 0x06,
15549 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15550 .adc_nids = alc861_adc_nids,
15551 .input_mux = &alc861_capture_source,
15552 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015553 [ALC861_ASUS_LAPTOP] = {
15554 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15555 .init_verbs = { alc861_asus_init_verbs,
15556 alc861_asus_laptop_init_verbs },
15557 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15558 .dac_nids = alc861_dac_nids,
15559 .dig_out_nid = ALC861_DIGOUT_NID,
15560 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15561 .channel_mode = alc883_3ST_2ch_modes,
15562 .need_dac_fix = 1,
15563 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15564 .adc_nids = alc861_adc_nids,
15565 .input_mux = &alc861_capture_source,
15566 },
15567};
Kailang Yangdf694da2005-12-05 19:42:22 +010015568
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015569/* Pin config fixes */
15570enum {
15571 PINFIX_FSC_AMILO_PI1505,
15572};
15573
15574static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15575 { 0x0b, 0x0221101f }, /* HP */
15576 { 0x0f, 0x90170310 }, /* speaker */
15577 { }
15578};
15579
15580static const struct alc_fixup alc861_fixups[] = {
15581 [PINFIX_FSC_AMILO_PI1505] = {
15582 .pins = alc861_fsc_amilo_pi1505_pinfix
15583 },
15584};
15585
15586static struct snd_pci_quirk alc861_fixup_tbl[] = {
15587 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15588 {}
15589};
Kailang Yangdf694da2005-12-05 19:42:22 +010015590
15591static int patch_alc861(struct hda_codec *codec)
15592{
15593 struct alc_spec *spec;
15594 int board_config;
15595 int err;
15596
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015597 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015598 if (spec == NULL)
15599 return -ENOMEM;
15600
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015601 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015602
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015603 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15604 alc861_models,
15605 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015606
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015607 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015608 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15609 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015610 board_config = ALC861_AUTO;
15611 }
15612
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015613 if (board_config == ALC861_AUTO)
15614 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015615
Kailang Yangdf694da2005-12-05 19:42:22 +010015616 if (board_config == ALC861_AUTO) {
15617 /* automatic parse from the BIOS config */
15618 err = alc861_parse_auto_config(codec);
15619 if (err < 0) {
15620 alc_free(codec);
15621 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015622 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015623 printk(KERN_INFO
15624 "hda_codec: Cannot set up configuration "
15625 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015626 board_config = ALC861_3ST_DIG;
15627 }
15628 }
15629
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015630 err = snd_hda_attach_beep_device(codec, 0x23);
15631 if (err < 0) {
15632 alc_free(codec);
15633 return err;
15634 }
15635
Kailang Yangdf694da2005-12-05 19:42:22 +010015636 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015637 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015638
Kailang Yangdf694da2005-12-05 19:42:22 +010015639 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15640 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15641
Kailang Yangdf694da2005-12-05 19:42:22 +010015642 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15643 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15644
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015645 if (!spec->cap_mixer)
15646 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015647 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15648
Takashi Iwai2134ea42008-01-10 16:53:55 +010015649 spec->vmaster_nid = 0x03;
15650
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015651 if (board_config == ALC861_AUTO)
15652 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15653
Kailang Yangdf694da2005-12-05 19:42:22 +010015654 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015655 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015656 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015657#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015658 spec->power_hook = alc_power_eapd;
15659#endif
15660 }
15661#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015662 if (!spec->loopback.amplist)
15663 spec->loopback.amplist = alc861_loopbacks;
15664#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015665
Kailang Yangdf694da2005-12-05 19:42:22 +010015666 return 0;
15667}
15668
15669/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015670 * ALC861-VD support
15671 *
15672 * Based on ALC882
15673 *
15674 * In addition, an independent DAC
15675 */
15676#define ALC861VD_DIGOUT_NID 0x06
15677
15678static hda_nid_t alc861vd_dac_nids[4] = {
15679 /* front, surr, clfe, side surr */
15680 0x02, 0x03, 0x04, 0x05
15681};
15682
15683/* dac_nids for ALC660vd are in a different order - according to
15684 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015685 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015686 * of ALC660vd codecs, but for now there is only 3stack mixer
15687 * - and it is the same as in 861vd.
15688 * adc_nids in ALC660vd are (is) the same as in 861vd
15689 */
15690static hda_nid_t alc660vd_dac_nids[3] = {
15691 /* front, rear, clfe, rear_surr */
15692 0x02, 0x04, 0x03
15693};
15694
15695static hda_nid_t alc861vd_adc_nids[1] = {
15696 /* ADC0 */
15697 0x09,
15698};
15699
Takashi Iwaie1406342008-02-11 18:32:32 +010015700static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15701
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015702/* input MUX */
15703/* FIXME: should be a matrix-type input source selection */
15704static struct hda_input_mux alc861vd_capture_source = {
15705 .num_items = 4,
15706 .items = {
15707 { "Mic", 0x0 },
15708 { "Front Mic", 0x1 },
15709 { "Line", 0x2 },
15710 { "CD", 0x4 },
15711 },
15712};
15713
Kailang Yang272a5272007-05-14 11:00:38 +020015714static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015715 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015716 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015717 { "Ext Mic", 0x0 },
15718 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015719 },
15720};
15721
Kailang Yangd1a991a2007-08-15 16:21:59 +020015722static struct hda_input_mux alc861vd_hp_capture_source = {
15723 .num_items = 2,
15724 .items = {
15725 { "Front Mic", 0x0 },
15726 { "ATAPI Mic", 0x1 },
15727 },
15728};
15729
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015730/*
15731 * 2ch mode
15732 */
15733static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15734 { 2, NULL }
15735};
15736
15737/*
15738 * 6ch mode
15739 */
15740static struct hda_verb alc861vd_6stack_ch6_init[] = {
15741 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15742 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15743 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15744 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15745 { } /* end */
15746};
15747
15748/*
15749 * 8ch mode
15750 */
15751static struct hda_verb alc861vd_6stack_ch8_init[] = {
15752 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15753 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15754 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15755 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15756 { } /* end */
15757};
15758
15759static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15760 { 6, alc861vd_6stack_ch6_init },
15761 { 8, alc861vd_6stack_ch8_init },
15762};
15763
15764static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15765 {
15766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15767 .name = "Channel Mode",
15768 .info = alc_ch_mode_info,
15769 .get = alc_ch_mode_get,
15770 .put = alc_ch_mode_put,
15771 },
15772 { } /* end */
15773};
15774
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015775/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15776 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15777 */
15778static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15779 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15780 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15781
15782 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15783 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15784
15785 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15786 HDA_OUTPUT),
15787 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15788 HDA_OUTPUT),
15789 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15790 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15791
15792 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15793 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15794
15795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15796
15797 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15800
15801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15802 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15803 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15804
15805 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15806 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15807
15808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15810
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015811 { } /* end */
15812};
15813
15814static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15815 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15816 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15817
15818 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15819
15820 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15823
15824 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15825 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15826 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15827
15828 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15829 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15830
15831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15833
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015834 { } /* end */
15835};
15836
Kailang Yangbdd148a2007-05-08 15:19:08 +020015837static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15838 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15839 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15840 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15841
15842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15843
15844 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15847
15848 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15849 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15850 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15851
15852 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15853 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15854
15855 { } /* end */
15856};
15857
Tobin Davisb419f342008-03-07 11:57:51 +010015858/* Pin assignment: Speaker=0x14, HP = 0x15,
15859 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015860 */
15861static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015862 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15863 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015864 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15865 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015866 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15867 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15868 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15869 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15870 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15871 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015872 { } /* end */
15873};
15874
Kailang Yangd1a991a2007-08-15 16:21:59 +020015875/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15876 * Front Mic=0x18, ATAPI Mic = 0x19,
15877 */
15878static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15879 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15881 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15882 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15883 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15884 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15885 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15886 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015887
Kailang Yangd1a991a2007-08-15 16:21:59 +020015888 { } /* end */
15889};
15890
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015891/*
15892 * generic initialization of ADC, input mixers and output mixers
15893 */
15894static struct hda_verb alc861vd_volume_init_verbs[] = {
15895 /*
15896 * Unmute ADC0 and set the default input to mic-in
15897 */
15898 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15899 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15900
15901 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15902 * the analog-loopback mixer widget
15903 */
15904 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015910
15911 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015916
15917 /*
15918 * Set up output mixers (0x02 - 0x05)
15919 */
15920 /* set vol=0 to output mixers */
15921 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15922 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15923 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15924 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15925
15926 /* set up input amps for analog loopback */
15927 /* Amp Indices: DAC = 0, mixer = 1 */
15928 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15930 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15931 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15932 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15933 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15934 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15935 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15936
15937 { }
15938};
15939
15940/*
15941 * 3-stack pin configuration:
15942 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15943 */
15944static struct hda_verb alc861vd_3stack_init_verbs[] = {
15945 /*
15946 * Set pin mode and muting
15947 */
15948 /* set front pin widgets 0x14 for output */
15949 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15950 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15951 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15952
15953 /* Mic (rear) pin: input vref at 80% */
15954 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15955 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15956 /* Front Mic pin: input vref at 80% */
15957 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15958 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15959 /* Line In pin: input */
15960 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15961 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15962 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15965 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15966 /* CD pin widget for input */
15967 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15968
15969 { }
15970};
15971
15972/*
15973 * 6-stack pin configuration:
15974 */
15975static struct hda_verb alc861vd_6stack_init_verbs[] = {
15976 /*
15977 * Set pin mode and muting
15978 */
15979 /* set front pin widgets 0x14 for output */
15980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15982 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15983
15984 /* Rear Pin: output 1 (0x0d) */
15985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15986 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15987 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15988 /* CLFE Pin: output 2 (0x0e) */
15989 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15990 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15991 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15992 /* Side Pin: output 3 (0x0f) */
15993 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15994 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15995 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15996
15997 /* Mic (rear) pin: input vref at 80% */
15998 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15999 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16000 /* Front Mic pin: input vref at 80% */
16001 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16002 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16003 /* Line In pin: input */
16004 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16005 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16006 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16007 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16008 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16009 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16010 /* CD pin widget for input */
16011 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16012
16013 { }
16014};
16015
Kailang Yangbdd148a2007-05-08 15:19:08 +020016016static struct hda_verb alc861vd_eapd_verbs[] = {
16017 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16018 { }
16019};
16020
Kailang Yangf9423e72008-05-27 12:32:25 +020016021static struct hda_verb alc660vd_eapd_verbs[] = {
16022 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16023 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16024 { }
16025};
16026
Kailang Yangbdd148a2007-05-08 15:19:08 +020016027static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16028 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16030 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16031 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016032 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016033 {}
16034};
16035
Kailang Yangbdd148a2007-05-08 15:19:08 +020016036static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16037{
16038 unsigned int present;
16039 unsigned char bits;
16040
Wu Fengguang864f92b2009-11-18 12:38:02 +080016041 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016042 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016043
Takashi Iwai47fd8302007-08-10 17:11:07 +020016044 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16045 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016046}
16047
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016048static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016049{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016050 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016051 spec->autocfg.hp_pins[0] = 0x1b;
16052 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016053}
16054
16055static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16056{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016057 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016058 alc861vd_lenovo_mic_automute(codec);
16059}
16060
16061static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16062 unsigned int res)
16063{
16064 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016065 case ALC880_MIC_EVENT:
16066 alc861vd_lenovo_mic_automute(codec);
16067 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016068 default:
16069 alc_automute_amp_unsol_event(codec, res);
16070 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016071 }
16072}
16073
Kailang Yang272a5272007-05-14 11:00:38 +020016074static struct hda_verb alc861vd_dallas_verbs[] = {
16075 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16076 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16077 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16078 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16079
16080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16082 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16083 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16084 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16085 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16086 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16087 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016088
Kailang Yang272a5272007-05-14 11:00:38 +020016089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16091 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16092 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16093 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16094 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16095 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16096 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16097
16098 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16099 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16100 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16101 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16102 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16103 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16104 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16105 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16106
16107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16111
16112 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016113 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016114 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16115
16116 { } /* end */
16117};
16118
16119/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016120static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016121{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016122 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016123
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016124 spec->autocfg.hp_pins[0] = 0x15;
16125 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016126}
16127
Takashi Iwaicb53c622007-08-10 17:21:45 +020016128#ifdef CONFIG_SND_HDA_POWER_SAVE
16129#define alc861vd_loopbacks alc880_loopbacks
16130#endif
16131
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016132/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016133#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16134#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16135#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16136#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16137
16138/*
16139 * configuration and preset
16140 */
16141static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16142 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016143 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016144 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016145 [ALC861VD_3ST] = "3stack",
16146 [ALC861VD_3ST_DIG] = "3stack-digout",
16147 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016148 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016149 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016150 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016151 [ALC861VD_AUTO] = "auto",
16152};
16153
16154static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016155 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16156 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016157 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016158 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016159 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016160 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016161 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016162 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016163 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016164 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016165 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016166 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016167 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016168 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016169 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016170 {}
16171};
16172
16173static struct alc_config_preset alc861vd_presets[] = {
16174 [ALC660VD_3ST] = {
16175 .mixers = { alc861vd_3st_mixer },
16176 .init_verbs = { alc861vd_volume_init_verbs,
16177 alc861vd_3stack_init_verbs },
16178 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16179 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016180 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16181 .channel_mode = alc861vd_3stack_2ch_modes,
16182 .input_mux = &alc861vd_capture_source,
16183 },
Mike Crash6963f842007-06-25 12:12:51 +020016184 [ALC660VD_3ST_DIG] = {
16185 .mixers = { alc861vd_3st_mixer },
16186 .init_verbs = { alc861vd_volume_init_verbs,
16187 alc861vd_3stack_init_verbs },
16188 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16189 .dac_nids = alc660vd_dac_nids,
16190 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016191 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16192 .channel_mode = alc861vd_3stack_2ch_modes,
16193 .input_mux = &alc861vd_capture_source,
16194 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016195 [ALC861VD_3ST] = {
16196 .mixers = { alc861vd_3st_mixer },
16197 .init_verbs = { alc861vd_volume_init_verbs,
16198 alc861vd_3stack_init_verbs },
16199 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16200 .dac_nids = alc861vd_dac_nids,
16201 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16202 .channel_mode = alc861vd_3stack_2ch_modes,
16203 .input_mux = &alc861vd_capture_source,
16204 },
16205 [ALC861VD_3ST_DIG] = {
16206 .mixers = { alc861vd_3st_mixer },
16207 .init_verbs = { alc861vd_volume_init_verbs,
16208 alc861vd_3stack_init_verbs },
16209 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16210 .dac_nids = alc861vd_dac_nids,
16211 .dig_out_nid = ALC861VD_DIGOUT_NID,
16212 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16213 .channel_mode = alc861vd_3stack_2ch_modes,
16214 .input_mux = &alc861vd_capture_source,
16215 },
16216 [ALC861VD_6ST_DIG] = {
16217 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16218 .init_verbs = { alc861vd_volume_init_verbs,
16219 alc861vd_6stack_init_verbs },
16220 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16221 .dac_nids = alc861vd_dac_nids,
16222 .dig_out_nid = ALC861VD_DIGOUT_NID,
16223 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16224 .channel_mode = alc861vd_6stack_modes,
16225 .input_mux = &alc861vd_capture_source,
16226 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016227 [ALC861VD_LENOVO] = {
16228 .mixers = { alc861vd_lenovo_mixer },
16229 .init_verbs = { alc861vd_volume_init_verbs,
16230 alc861vd_3stack_init_verbs,
16231 alc861vd_eapd_verbs,
16232 alc861vd_lenovo_unsol_verbs },
16233 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16234 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016235 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16236 .channel_mode = alc861vd_3stack_2ch_modes,
16237 .input_mux = &alc861vd_capture_source,
16238 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016239 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016240 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016241 },
Kailang Yang272a5272007-05-14 11:00:38 +020016242 [ALC861VD_DALLAS] = {
16243 .mixers = { alc861vd_dallas_mixer },
16244 .init_verbs = { alc861vd_dallas_verbs },
16245 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16246 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016247 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16248 .channel_mode = alc861vd_3stack_2ch_modes,
16249 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016250 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016251 .setup = alc861vd_dallas_setup,
16252 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016253 },
16254 [ALC861VD_HP] = {
16255 .mixers = { alc861vd_hp_mixer },
16256 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16257 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16258 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016259 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016260 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16261 .channel_mode = alc861vd_3stack_2ch_modes,
16262 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016263 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016264 .setup = alc861vd_dallas_setup,
16265 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016266 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016267 [ALC660VD_ASUS_V1S] = {
16268 .mixers = { alc861vd_lenovo_mixer },
16269 .init_verbs = { alc861vd_volume_init_verbs,
16270 alc861vd_3stack_init_verbs,
16271 alc861vd_eapd_verbs,
16272 alc861vd_lenovo_unsol_verbs },
16273 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16274 .dac_nids = alc660vd_dac_nids,
16275 .dig_out_nid = ALC861VD_DIGOUT_NID,
16276 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16277 .channel_mode = alc861vd_3stack_2ch_modes,
16278 .input_mux = &alc861vd_capture_source,
16279 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016280 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016281 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016282 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016283};
16284
16285/*
16286 * BIOS auto configuration
16287 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016288static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16289 const struct auto_pin_cfg *cfg)
16290{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016291 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016292}
16293
16294
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016295static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16296 hda_nid_t nid, int pin_type, int dac_idx)
16297{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016298 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016299}
16300
16301static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16302{
16303 struct alc_spec *spec = codec->spec;
16304 int i;
16305
16306 for (i = 0; i <= HDA_SIDE; i++) {
16307 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016308 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016309 if (nid)
16310 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016311 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016312 }
16313}
16314
16315
16316static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16317{
16318 struct alc_spec *spec = codec->spec;
16319 hda_nid_t pin;
16320
16321 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016322 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016323 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016324 pin = spec->autocfg.speaker_pins[0];
16325 if (pin)
16326 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016327}
16328
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016329#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16330
16331static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16332{
16333 struct alc_spec *spec = codec->spec;
16334 int i;
16335
16336 for (i = 0; i < AUTO_PIN_LAST; i++) {
16337 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016338 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016339 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016340 if (nid != ALC861VD_PIN_CD_NID &&
16341 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016342 snd_hda_codec_write(codec, nid, 0,
16343 AC_VERB_SET_AMP_GAIN_MUTE,
16344 AMP_OUT_MUTE);
16345 }
16346 }
16347}
16348
Takashi Iwaif511b012008-08-15 16:46:42 +020016349#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16350
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016351#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16352#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16353
16354/* add playback controls from the parsed DAC table */
16355/* Based on ALC880 version. But ALC861VD has separate,
16356 * different NIDs for mute/unmute switch and volume control */
16357static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16358 const struct auto_pin_cfg *cfg)
16359{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016360 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16361 hda_nid_t nid_v, nid_s;
16362 int i, err;
16363
16364 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016365 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016366 continue;
16367 nid_v = alc861vd_idx_to_mixer_vol(
16368 alc880_dac_to_idx(
16369 spec->multiout.dac_nids[i]));
16370 nid_s = alc861vd_idx_to_mixer_switch(
16371 alc880_dac_to_idx(
16372 spec->multiout.dac_nids[i]));
16373
16374 if (i == 2) {
16375 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016376 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16377 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016378 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16379 HDA_OUTPUT));
16380 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016381 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016382 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16383 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016384 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16385 HDA_OUTPUT));
16386 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016387 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016388 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16389 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016390 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16391 HDA_INPUT));
16392 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016393 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016394 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16395 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016396 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16397 HDA_INPUT));
16398 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016399 return err;
16400 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016401 const char *pfx;
16402 if (cfg->line_outs == 1 &&
16403 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16404 if (!cfg->hp_pins)
16405 pfx = "Speaker";
16406 else
16407 pfx = "PCM";
16408 } else
16409 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016410 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016411 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16412 HDA_OUTPUT));
16413 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016414 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016415 if (cfg->line_outs == 1 &&
16416 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16417 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016418 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016419 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016420 HDA_INPUT));
16421 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016422 return err;
16423 }
16424 }
16425 return 0;
16426}
16427
16428/* add playback controls for speaker and HP outputs */
16429/* Based on ALC880 version. But ALC861VD has separate,
16430 * different NIDs for mute/unmute switch and volume control */
16431static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16432 hda_nid_t pin, const char *pfx)
16433{
16434 hda_nid_t nid_v, nid_s;
16435 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016436
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016437 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016438 return 0;
16439
16440 if (alc880_is_fixed_pin(pin)) {
16441 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16442 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016443 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016444 spec->multiout.hp_nid = nid_v;
16445 else
16446 spec->multiout.extra_out_nid[0] = nid_v;
16447 /* control HP volume/switch on the output mixer amp */
16448 nid_v = alc861vd_idx_to_mixer_vol(
16449 alc880_fixed_pin_idx(pin));
16450 nid_s = alc861vd_idx_to_mixer_switch(
16451 alc880_fixed_pin_idx(pin));
16452
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016453 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016454 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16455 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016456 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016457 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016458 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16459 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016460 return err;
16461 } else if (alc880_is_multi_pin(pin)) {
16462 /* set manual connection */
16463 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016464 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016465 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16466 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016467 return err;
16468 }
16469 return 0;
16470}
16471
16472/* parse the BIOS configuration and set up the alc_spec
16473 * return 1 if successful, 0 if the proper config is not found,
16474 * or a negative error code
16475 * Based on ALC880 version - had to change it to override
16476 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16477static int alc861vd_parse_auto_config(struct hda_codec *codec)
16478{
16479 struct alc_spec *spec = codec->spec;
16480 int err;
16481 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16482
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016483 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16484 alc861vd_ignore);
16485 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016486 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016487 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016488 return 0; /* can't find valid BIOS pin config */
16489
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016490 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16491 if (err < 0)
16492 return err;
16493 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16494 if (err < 0)
16495 return err;
16496 err = alc861vd_auto_create_extra_out(spec,
16497 spec->autocfg.speaker_pins[0],
16498 "Speaker");
16499 if (err < 0)
16500 return err;
16501 err = alc861vd_auto_create_extra_out(spec,
16502 spec->autocfg.hp_pins[0],
16503 "Headphone");
16504 if (err < 0)
16505 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016506 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016507 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016508 return err;
16509
16510 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16511
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016512 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016513 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16514
Takashi Iwai603c4012008-07-30 15:01:44 +020016515 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016516 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016517
Takashi Iwaid88897e2008-10-31 15:01:37 +010016518 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016519
16520 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016521 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016522
Takashi Iwai776e1842007-08-29 15:07:11 +020016523 err = alc_auto_add_mic_boost(codec);
16524 if (err < 0)
16525 return err;
16526
Kailang Yang6227cdc2010-02-25 08:36:52 +010016527 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016528
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016529 return 1;
16530}
16531
16532/* additional initialization for auto-configuration model */
16533static void alc861vd_auto_init(struct hda_codec *codec)
16534{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016535 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016536 alc861vd_auto_init_multi_out(codec);
16537 alc861vd_auto_init_hp_out(codec);
16538 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016539 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016540 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016541 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016542}
16543
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016544enum {
16545 ALC660VD_FIX_ASUS_GPIO1
16546};
16547
16548/* reset GPIO1 */
16549static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16550 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16551 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16552 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16553 { }
16554};
16555
16556static const struct alc_fixup alc861vd_fixups[] = {
16557 [ALC660VD_FIX_ASUS_GPIO1] = {
16558 .verbs = alc660vd_fix_asus_gpio1_verbs,
16559 },
16560};
16561
16562static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16563 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16564 {}
16565};
16566
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016567static int patch_alc861vd(struct hda_codec *codec)
16568{
16569 struct alc_spec *spec;
16570 int err, board_config;
16571
16572 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16573 if (spec == NULL)
16574 return -ENOMEM;
16575
16576 codec->spec = spec;
16577
16578 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16579 alc861vd_models,
16580 alc861vd_cfg_tbl);
16581
16582 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016583 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16584 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016585 board_config = ALC861VD_AUTO;
16586 }
16587
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016588 if (board_config == ALC861VD_AUTO)
16589 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016590
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016591 if (board_config == ALC861VD_AUTO) {
16592 /* automatic parse from the BIOS config */
16593 err = alc861vd_parse_auto_config(codec);
16594 if (err < 0) {
16595 alc_free(codec);
16596 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016597 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016598 printk(KERN_INFO
16599 "hda_codec: Cannot set up configuration "
16600 "from BIOS. Using base mode...\n");
16601 board_config = ALC861VD_3ST;
16602 }
16603 }
16604
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016605 err = snd_hda_attach_beep_device(codec, 0x23);
16606 if (err < 0) {
16607 alc_free(codec);
16608 return err;
16609 }
16610
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016611 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016612 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016613
Kailang Yang2f893282008-05-27 12:14:47 +020016614 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016615 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016616 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016617 }
16618
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016619 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16620 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16621
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016622 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16623 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16624
Takashi Iwaidd704692009-08-11 08:45:11 +020016625 if (!spec->adc_nids) {
16626 spec->adc_nids = alc861vd_adc_nids;
16627 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16628 }
16629 if (!spec->capsrc_nids)
16630 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016631
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016632 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016633 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016634
Takashi Iwai2134ea42008-01-10 16:53:55 +010016635 spec->vmaster_nid = 0x02;
16636
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016637 if (board_config == ALC861VD_AUTO)
16638 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16639
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016640 codec->patch_ops = alc_patch_ops;
16641
16642 if (board_config == ALC861VD_AUTO)
16643 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016644#ifdef CONFIG_SND_HDA_POWER_SAVE
16645 if (!spec->loopback.amplist)
16646 spec->loopback.amplist = alc861vd_loopbacks;
16647#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016648
16649 return 0;
16650}
16651
16652/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016653 * ALC662 support
16654 *
16655 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16656 * configuration. Each pin widget can choose any input DACs and a mixer.
16657 * Each ADC is connected from a mixer of all inputs. This makes possible
16658 * 6-channel independent captures.
16659 *
16660 * In addition, an independent DAC for the multi-playback (not used in this
16661 * driver yet).
16662 */
16663#define ALC662_DIGOUT_NID 0x06
16664#define ALC662_DIGIN_NID 0x0a
16665
16666static hda_nid_t alc662_dac_nids[4] = {
16667 /* front, rear, clfe, rear_surr */
16668 0x02, 0x03, 0x04
16669};
16670
Kailang Yang622e84c2009-04-21 07:39:04 +020016671static hda_nid_t alc272_dac_nids[2] = {
16672 0x02, 0x03
16673};
16674
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016675static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016676 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016677 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016678};
Takashi Iwaie1406342008-02-11 18:32:32 +010016679
Kailang Yang622e84c2009-04-21 07:39:04 +020016680static hda_nid_t alc272_adc_nids[1] = {
16681 /* ADC1-2 */
16682 0x08,
16683};
16684
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016685static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016686static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16687
Takashi Iwaie1406342008-02-11 18:32:32 +010016688
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016689/* input MUX */
16690/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016691static struct hda_input_mux alc662_capture_source = {
16692 .num_items = 4,
16693 .items = {
16694 { "Mic", 0x0 },
16695 { "Front Mic", 0x1 },
16696 { "Line", 0x2 },
16697 { "CD", 0x4 },
16698 },
16699};
16700
16701static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16702 .num_items = 2,
16703 .items = {
16704 { "Mic", 0x1 },
16705 { "Line", 0x2 },
16706 },
16707};
Kailang Yang291702f2007-10-16 14:28:03 +020016708
Kailang Yang6dda9f42008-05-27 12:05:31 +020016709static struct hda_input_mux alc663_capture_source = {
16710 .num_items = 3,
16711 .items = {
16712 { "Mic", 0x0 },
16713 { "Front Mic", 0x1 },
16714 { "Line", 0x2 },
16715 },
16716};
16717
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016718#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016719static struct hda_input_mux alc272_nc10_capture_source = {
16720 .num_items = 16,
16721 .items = {
16722 { "Autoselect Mic", 0x0 },
16723 { "Internal Mic", 0x1 },
16724 { "In-0x02", 0x2 },
16725 { "In-0x03", 0x3 },
16726 { "In-0x04", 0x4 },
16727 { "In-0x05", 0x5 },
16728 { "In-0x06", 0x6 },
16729 { "In-0x07", 0x7 },
16730 { "In-0x08", 0x8 },
16731 { "In-0x09", 0x9 },
16732 { "In-0x0a", 0x0a },
16733 { "In-0x0b", 0x0b },
16734 { "In-0x0c", 0x0c },
16735 { "In-0x0d", 0x0d },
16736 { "In-0x0e", 0x0e },
16737 { "In-0x0f", 0x0f },
16738 },
16739};
16740#endif
16741
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016742/*
16743 * 2ch mode
16744 */
16745static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16746 { 2, NULL }
16747};
16748
16749/*
16750 * 2ch mode
16751 */
16752static struct hda_verb alc662_3ST_ch2_init[] = {
16753 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16754 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16755 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16756 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16757 { } /* end */
16758};
16759
16760/*
16761 * 6ch mode
16762 */
16763static struct hda_verb alc662_3ST_ch6_init[] = {
16764 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16765 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16766 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16769 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16770 { } /* end */
16771};
16772
16773static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16774 { 2, alc662_3ST_ch2_init },
16775 { 6, alc662_3ST_ch6_init },
16776};
16777
16778/*
16779 * 2ch mode
16780 */
16781static struct hda_verb alc662_sixstack_ch6_init[] = {
16782 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16783 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16784 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16785 { } /* end */
16786};
16787
16788/*
16789 * 6ch mode
16790 */
16791static struct hda_verb alc662_sixstack_ch8_init[] = {
16792 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16793 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16794 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16795 { } /* end */
16796};
16797
16798static struct hda_channel_mode alc662_5stack_modes[2] = {
16799 { 2, alc662_sixstack_ch6_init },
16800 { 6, alc662_sixstack_ch8_init },
16801};
16802
16803/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16804 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16805 */
16806
16807static struct snd_kcontrol_new alc662_base_mixer[] = {
16808 /* output mixer control */
16809 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016810 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016811 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016812 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016813 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16814 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016815 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16816 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16818
16819 /*Input mixer control */
16820 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16821 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16822 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16823 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16824 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16825 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016828 { } /* end */
16829};
16830
16831static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16832 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016833 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016834 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016843 { } /* end */
16844};
16845
16846static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16847 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016848 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016849 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016850 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016851 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16852 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016853 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16854 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16856 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16857 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16858 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16859 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16862 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16863 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016864 { } /* end */
16865};
16866
16867static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16868 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16869 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016870 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16871 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016872 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16873 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16874 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016877 { } /* end */
16878};
16879
Kailang Yang291702f2007-10-16 14:28:03 +020016880static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016881 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16882 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016883
16884 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16885 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16886 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16887
16888 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16889 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16890 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16891 { } /* end */
16892};
16893
Kailang Yang8c427222008-01-10 13:03:59 +010016894static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016895 ALC262_HIPPO_MASTER_SWITCH,
16896 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016897 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016898 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16899 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016900 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16901 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16902 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
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
Kailang Yangf1d4e282008-08-26 14:03:29 +020016908static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16909 .ops = &snd_hda_bind_vol,
16910 .values = {
16911 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16912 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16913 0
16914 },
16915};
16916
16917static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16918 .ops = &snd_hda_bind_sw,
16919 .values = {
16920 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16921 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16922 0
16923 },
16924};
16925
Kailang Yang6dda9f42008-05-27 12:05:31 +020016926static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016927 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16928 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16931 { } /* end */
16932};
16933
16934static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16935 .ops = &snd_hda_bind_sw,
16936 .values = {
16937 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16938 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16939 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16940 0
16941 },
16942};
16943
16944static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16945 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16946 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16948 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16949 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16950 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16951
16952 { } /* end */
16953};
16954
16955static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16956 .ops = &snd_hda_bind_sw,
16957 .values = {
16958 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16959 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16960 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16961 0
16962 },
16963};
16964
16965static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16966 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16967 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16968 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16969 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16970 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16971 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16972 { } /* end */
16973};
16974
16975static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016976 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16977 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16981 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16982 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16983 { } /* end */
16984};
16985
16986static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16987 .ops = &snd_hda_bind_vol,
16988 .values = {
16989 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16990 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16991 0
16992 },
16993};
16994
16995static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16996 .ops = &snd_hda_bind_sw,
16997 .values = {
16998 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16999 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17000 0
17001 },
17002};
17003
17004static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17005 HDA_BIND_VOL("Master Playback Volume",
17006 &alc663_asus_two_bind_master_vol),
17007 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17008 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17011 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017012 { } /* end */
17013};
17014
17015static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17016 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17017 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17018 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017022 { } /* end */
17023};
17024
17025static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17026 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17027 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17028 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17029 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17031
17032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17034 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17035 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17036 { } /* end */
17037};
17038
17039static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17040 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17041 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17043
17044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17046 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17047 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17050 { } /* end */
17051};
17052
Kailang Yangebb83ee2009-12-17 12:23:00 +010017053static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17054 .ops = &snd_hda_bind_sw,
17055 .values = {
17056 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17057 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17058 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17059 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17060 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17061 0
17062 },
17063};
17064
17065static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17066 .ops = &snd_hda_bind_sw,
17067 .values = {
17068 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17069 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17070 0
17071 },
17072};
17073
17074static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17075 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17076 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17077 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17078 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17079 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17080 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17081 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17082 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17083 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17084 { } /* end */
17085};
17086
17087static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17088 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17089 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17090 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17091 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17092 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17094 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17095 { } /* end */
17096};
17097
17098
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017099static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17100 {
17101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17102 .name = "Channel Mode",
17103 .info = alc_ch_mode_info,
17104 .get = alc_ch_mode_get,
17105 .put = alc_ch_mode_put,
17106 },
17107 { } /* end */
17108};
17109
17110static struct hda_verb alc662_init_verbs[] = {
17111 /* ADC: mute amp left and right */
17112 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17113 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017114
Kailang Yangb60dd392007-09-20 12:50:29 +020017115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017121
17122 /* Front Pin: output 0 (0x0c) */
17123 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17124 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17125
17126 /* Rear Pin: output 1 (0x0d) */
17127 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17129
17130 /* CLFE Pin: output 2 (0x0e) */
17131 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17133
17134 /* Mic (rear) pin: input vref at 80% */
17135 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17137 /* Front Mic pin: input vref at 80% */
17138 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17139 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17140 /* Line In pin: input */
17141 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17142 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17143 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17144 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17145 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17146 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17147 /* CD pin widget for input */
17148 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17149
17150 /* FIXME: use matrix-type input source selection */
17151 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17152 /* Input mixer */
17153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017154 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017155
17156 /* always trun on EAPD */
17157 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17158 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17159
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017160 { }
17161};
17162
Kailang Yangcec27c82010-02-04 14:18:18 +010017163static struct hda_verb alc663_init_verbs[] = {
17164 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17165 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17166 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17167 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17168 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17169 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17170 { }
17171};
17172
17173static struct hda_verb alc272_init_verbs[] = {
17174 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17175 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17176 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17177 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17178 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17179 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17180 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17181 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17182 { }
17183};
17184
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017185static struct hda_verb alc662_sue_init_verbs[] = {
17186 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17187 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017188 {}
17189};
17190
17191static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17192 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17193 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17194 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017195};
17196
Kailang Yang8c427222008-01-10 13:03:59 +010017197/* Set Unsolicited Event*/
17198static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17199 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17200 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17201 {}
17202};
17203
Kailang Yang6dda9f42008-05-27 12:05:31 +020017204static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017205 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17206 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017207 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17208 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017209 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017212 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17213 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17214 {}
17215};
17216
Kailang Yangf1d4e282008-08-26 14:03:29 +020017217static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17218 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17219 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17220 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17223 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17224 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17225 {}
17226};
17227
17228static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17229 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17230 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17231 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17232 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* 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 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17237 {}
17238};
17239
17240static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17241 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17243 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17244 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17245 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17246 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17247 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17248 {}
17249};
17250
17251static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17252 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17253 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17254 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17255 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17261 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17262 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17264 {}
17265};
17266
17267static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17268 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17270 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17271 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17274 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17275 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17277 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17278 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17279 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17280 {}
17281};
17282
Kailang Yang6dda9f42008-05-27 12:05:31 +020017283static struct hda_verb alc663_g71v_init_verbs[] = {
17284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17285 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17286 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17287
17288 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17289 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17290 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17291
17292 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17293 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17294 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17295 {}
17296};
17297
17298static struct hda_verb alc663_g50v_init_verbs[] = {
17299 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17300 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17301 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17302
17303 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17304 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17305 {}
17306};
17307
Kailang Yangf1d4e282008-08-26 14:03:29 +020017308static struct hda_verb alc662_ecs_init_verbs[] = {
17309 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17311 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17312 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17313 {}
17314};
17315
Kailang Yang622e84c2009-04-21 07:39:04 +020017316static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17317 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17318 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17319 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17320 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17321 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17322 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17323 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17326 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17327 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17328 {}
17329};
17330
17331static struct hda_verb alc272_dell_init_verbs[] = {
17332 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17333 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17335 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17336 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17337 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17338 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17341 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17342 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17343 {}
17344};
17345
Kailang Yangebb83ee2009-12-17 12:23:00 +010017346static struct hda_verb alc663_mode7_init_verbs[] = {
17347 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17348 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17349 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17350 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17351 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17352 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17353 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17354 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17355 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17356 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17359 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17360 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17361 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17362 {}
17363};
17364
17365static struct hda_verb alc663_mode8_init_verbs[] = {
17366 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17369 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17370 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17371 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17372 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17373 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17374 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17375 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17376 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17379 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17380 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17381 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17382 {}
17383};
17384
Kailang Yangf1d4e282008-08-26 14:03:29 +020017385static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17386 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17387 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17388 { } /* end */
17389};
17390
Kailang Yang622e84c2009-04-21 07:39:04 +020017391static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17392 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17393 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17394 { } /* end */
17395};
17396
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017397static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17398{
17399 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017400 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017401
Wu Fengguang864f92b2009-11-18 12:38:02 +080017402 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017403 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017404
Takashi Iwai47fd8302007-08-10 17:11:07 +020017405 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17406 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017407}
17408
17409static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17410{
17411 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017412 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017413
Wu Fengguang864f92b2009-11-18 12:38:02 +080017414 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017415 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017416
Takashi Iwai47fd8302007-08-10 17:11:07 +020017417 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17418 HDA_AMP_MUTE, bits);
17419 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17420 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017421}
17422
17423static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17424 unsigned int res)
17425{
17426 if ((res >> 26) == ALC880_HP_EVENT)
17427 alc662_lenovo_101e_all_automute(codec);
17428 if ((res >> 26) == ALC880_FRONT_EVENT)
17429 alc662_lenovo_101e_ispeaker_automute(codec);
17430}
17431
Kailang Yang291702f2007-10-16 14:28:03 +020017432/* unsolicited event for HP jack sensing */
17433static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17434 unsigned int res)
17435{
Kailang Yang291702f2007-10-16 14:28:03 +020017436 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017437 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017438 else
17439 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017440}
17441
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017442static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017443{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017444 struct alc_spec *spec = codec->spec;
17445
17446 alc262_hippo1_setup(codec);
17447 spec->ext_mic.pin = 0x18;
17448 spec->ext_mic.mux_idx = 0;
17449 spec->int_mic.pin = 0x19;
17450 spec->int_mic.mux_idx = 1;
17451 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017452}
17453
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017454static void alc662_eeepc_inithook(struct hda_codec *codec)
17455{
17456 alc262_hippo_automute(codec);
17457 alc_mic_automute(codec);
17458}
17459
17460static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017461{
Takashi Iwai42171c12009-05-08 14:11:43 +020017462 struct alc_spec *spec = codec->spec;
17463
17464 spec->autocfg.hp_pins[0] = 0x14;
17465 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017466}
17467
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017468#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17469
Kailang Yang6dda9f42008-05-27 12:05:31 +020017470static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17471{
17472 unsigned int present;
17473 unsigned char bits;
17474
Wu Fengguang864f92b2009-11-18 12:38:02 +080017475 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017476 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017477 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017478 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017479 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017480 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017481}
17482
17483static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17484{
17485 unsigned int present;
17486 unsigned char bits;
17487
Wu Fengguang864f92b2009-11-18 12:38:02 +080017488 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017489 bits = present ? HDA_AMP_MUTE : 0;
17490 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017491 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017492 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017493 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017494 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017495 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017496 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017497 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017498}
17499
17500static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17501{
17502 unsigned int present;
17503 unsigned char bits;
17504
Wu Fengguang864f92b2009-11-18 12:38:02 +080017505 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017506 bits = present ? HDA_AMP_MUTE : 0;
17507 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017508 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017509 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017510 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017511 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017512 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017513 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017514 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017515}
17516
17517static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17518{
17519 unsigned int present;
17520 unsigned char bits;
17521
Wu Fengguang864f92b2009-11-18 12:38:02 +080017522 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017523 bits = present ? 0 : PIN_OUT;
17524 snd_hda_codec_write(codec, 0x14, 0,
17525 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17526}
17527
17528static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17529{
17530 unsigned int present1, present2;
17531
Wu Fengguang864f92b2009-11-18 12:38:02 +080017532 present1 = snd_hda_jack_detect(codec, 0x21);
17533 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017534
17535 if (present1 || present2) {
17536 snd_hda_codec_write_cache(codec, 0x14, 0,
17537 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17538 } else {
17539 snd_hda_codec_write_cache(codec, 0x14, 0,
17540 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17541 }
17542}
17543
17544static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17545{
17546 unsigned int present1, present2;
17547
Wu Fengguang864f92b2009-11-18 12:38:02 +080017548 present1 = snd_hda_jack_detect(codec, 0x1b);
17549 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017550
17551 if (present1 || present2) {
17552 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017553 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017554 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017555 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017556 } else {
17557 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017558 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017559 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017560 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017561 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017562}
17563
Kailang Yangebb83ee2009-12-17 12:23:00 +010017564static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17565{
17566 unsigned int present1, present2;
17567
17568 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17569 AC_VERB_GET_PIN_SENSE, 0)
17570 & AC_PINSENSE_PRESENCE;
17571 present2 = snd_hda_codec_read(codec, 0x21, 0,
17572 AC_VERB_GET_PIN_SENSE, 0)
17573 & AC_PINSENSE_PRESENCE;
17574
17575 if (present1 || present2) {
17576 snd_hda_codec_write_cache(codec, 0x14, 0,
17577 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17578 snd_hda_codec_write_cache(codec, 0x17, 0,
17579 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17580 } else {
17581 snd_hda_codec_write_cache(codec, 0x14, 0,
17582 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17583 snd_hda_codec_write_cache(codec, 0x17, 0,
17584 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17585 }
17586}
17587
17588static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17589{
17590 unsigned int present1, present2;
17591
17592 present1 = snd_hda_codec_read(codec, 0x21, 0,
17593 AC_VERB_GET_PIN_SENSE, 0)
17594 & AC_PINSENSE_PRESENCE;
17595 present2 = snd_hda_codec_read(codec, 0x15, 0,
17596 AC_VERB_GET_PIN_SENSE, 0)
17597 & AC_PINSENSE_PRESENCE;
17598
17599 if (present1 || present2) {
17600 snd_hda_codec_write_cache(codec, 0x14, 0,
17601 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17602 snd_hda_codec_write_cache(codec, 0x17, 0,
17603 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17604 } else {
17605 snd_hda_codec_write_cache(codec, 0x14, 0,
17606 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17607 snd_hda_codec_write_cache(codec, 0x17, 0,
17608 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17609 }
17610}
17611
Kailang Yang6dda9f42008-05-27 12:05:31 +020017612static void alc663_m51va_unsol_event(struct hda_codec *codec,
17613 unsigned int res)
17614{
17615 switch (res >> 26) {
17616 case ALC880_HP_EVENT:
17617 alc663_m51va_speaker_automute(codec);
17618 break;
17619 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017620 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017621 break;
17622 }
17623}
17624
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017625static void alc663_m51va_setup(struct hda_codec *codec)
17626{
17627 struct alc_spec *spec = codec->spec;
17628 spec->ext_mic.pin = 0x18;
17629 spec->ext_mic.mux_idx = 0;
17630 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017631 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017632 spec->auto_mic = 1;
17633}
17634
Kailang Yang6dda9f42008-05-27 12:05:31 +020017635static void alc663_m51va_inithook(struct hda_codec *codec)
17636{
17637 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017638 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017639}
17640
Kailang Yangf1d4e282008-08-26 14:03:29 +020017641/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017642#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017643
17644static void alc663_mode1_setup(struct hda_codec *codec)
17645{
17646 struct alc_spec *spec = codec->spec;
17647 spec->ext_mic.pin = 0x18;
17648 spec->ext_mic.mux_idx = 0;
17649 spec->int_mic.pin = 0x19;
17650 spec->int_mic.mux_idx = 1;
17651 spec->auto_mic = 1;
17652}
17653
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017654#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017655
Kailang Yangf1d4e282008-08-26 14:03:29 +020017656/* ***************** Mode2 ******************************/
17657static void alc662_mode2_unsol_event(struct hda_codec *codec,
17658 unsigned int res)
17659{
17660 switch (res >> 26) {
17661 case ALC880_HP_EVENT:
17662 alc662_f5z_speaker_automute(codec);
17663 break;
17664 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017665 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017666 break;
17667 }
17668}
17669
Kailang Yangebb83ee2009-12-17 12:23:00 +010017670#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017671
Kailang Yangf1d4e282008-08-26 14:03:29 +020017672static void alc662_mode2_inithook(struct hda_codec *codec)
17673{
17674 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017675 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017676}
17677/* ***************** Mode3 ******************************/
17678static void alc663_mode3_unsol_event(struct hda_codec *codec,
17679 unsigned int res)
17680{
17681 switch (res >> 26) {
17682 case ALC880_HP_EVENT:
17683 alc663_two_hp_m1_speaker_automute(codec);
17684 break;
17685 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017686 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017687 break;
17688 }
17689}
17690
Kailang Yangebb83ee2009-12-17 12:23:00 +010017691#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017692
Kailang Yangf1d4e282008-08-26 14:03:29 +020017693static void alc663_mode3_inithook(struct hda_codec *codec)
17694{
17695 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017696 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017697}
17698/* ***************** Mode4 ******************************/
17699static void alc663_mode4_unsol_event(struct hda_codec *codec,
17700 unsigned int res)
17701{
17702 switch (res >> 26) {
17703 case ALC880_HP_EVENT:
17704 alc663_21jd_two_speaker_automute(codec);
17705 break;
17706 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017707 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017708 break;
17709 }
17710}
17711
Kailang Yangebb83ee2009-12-17 12:23:00 +010017712#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017713
Kailang Yangf1d4e282008-08-26 14:03:29 +020017714static void alc663_mode4_inithook(struct hda_codec *codec)
17715{
17716 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017717 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017718}
17719/* ***************** Mode5 ******************************/
17720static void alc663_mode5_unsol_event(struct hda_codec *codec,
17721 unsigned int res)
17722{
17723 switch (res >> 26) {
17724 case ALC880_HP_EVENT:
17725 alc663_15jd_two_speaker_automute(codec);
17726 break;
17727 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017728 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017729 break;
17730 }
17731}
17732
Kailang Yangebb83ee2009-12-17 12:23:00 +010017733#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017734
Kailang Yangf1d4e282008-08-26 14:03:29 +020017735static void alc663_mode5_inithook(struct hda_codec *codec)
17736{
17737 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017738 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017739}
17740/* ***************** Mode6 ******************************/
17741static void alc663_mode6_unsol_event(struct hda_codec *codec,
17742 unsigned int res)
17743{
17744 switch (res >> 26) {
17745 case ALC880_HP_EVENT:
17746 alc663_two_hp_m2_speaker_automute(codec);
17747 break;
17748 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017749 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017750 break;
17751 }
17752}
17753
Kailang Yangebb83ee2009-12-17 12:23:00 +010017754#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017755
Kailang Yangf1d4e282008-08-26 14:03:29 +020017756static void alc663_mode6_inithook(struct hda_codec *codec)
17757{
17758 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017759 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017760}
17761
Kailang Yangebb83ee2009-12-17 12:23:00 +010017762/* ***************** Mode7 ******************************/
17763static void alc663_mode7_unsol_event(struct hda_codec *codec,
17764 unsigned int res)
17765{
17766 switch (res >> 26) {
17767 case ALC880_HP_EVENT:
17768 alc663_two_hp_m7_speaker_automute(codec);
17769 break;
17770 case ALC880_MIC_EVENT:
17771 alc_mic_automute(codec);
17772 break;
17773 }
17774}
17775
17776#define alc663_mode7_setup alc663_mode1_setup
17777
17778static void alc663_mode7_inithook(struct hda_codec *codec)
17779{
17780 alc663_two_hp_m7_speaker_automute(codec);
17781 alc_mic_automute(codec);
17782}
17783
17784/* ***************** Mode8 ******************************/
17785static void alc663_mode8_unsol_event(struct hda_codec *codec,
17786 unsigned int res)
17787{
17788 switch (res >> 26) {
17789 case ALC880_HP_EVENT:
17790 alc663_two_hp_m8_speaker_automute(codec);
17791 break;
17792 case ALC880_MIC_EVENT:
17793 alc_mic_automute(codec);
17794 break;
17795 }
17796}
17797
17798#define alc663_mode8_setup alc663_m51va_setup
17799
17800static void alc663_mode8_inithook(struct hda_codec *codec)
17801{
17802 alc663_two_hp_m8_speaker_automute(codec);
17803 alc_mic_automute(codec);
17804}
17805
Kailang Yang6dda9f42008-05-27 12:05:31 +020017806static void alc663_g71v_hp_automute(struct hda_codec *codec)
17807{
17808 unsigned int present;
17809 unsigned char bits;
17810
Wu Fengguang864f92b2009-11-18 12:38:02 +080017811 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017812 bits = present ? HDA_AMP_MUTE : 0;
17813 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17814 HDA_AMP_MUTE, bits);
17815 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17816 HDA_AMP_MUTE, bits);
17817}
17818
17819static void alc663_g71v_front_automute(struct hda_codec *codec)
17820{
17821 unsigned int present;
17822 unsigned char bits;
17823
Wu Fengguang864f92b2009-11-18 12:38:02 +080017824 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017825 bits = present ? HDA_AMP_MUTE : 0;
17826 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17827 HDA_AMP_MUTE, bits);
17828}
17829
17830static void alc663_g71v_unsol_event(struct hda_codec *codec,
17831 unsigned int res)
17832{
17833 switch (res >> 26) {
17834 case ALC880_HP_EVENT:
17835 alc663_g71v_hp_automute(codec);
17836 break;
17837 case ALC880_FRONT_EVENT:
17838 alc663_g71v_front_automute(codec);
17839 break;
17840 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017841 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017842 break;
17843 }
17844}
17845
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017846#define alc663_g71v_setup alc663_m51va_setup
17847
Kailang Yang6dda9f42008-05-27 12:05:31 +020017848static void alc663_g71v_inithook(struct hda_codec *codec)
17849{
17850 alc663_g71v_front_automute(codec);
17851 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017852 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017853}
17854
17855static void alc663_g50v_unsol_event(struct hda_codec *codec,
17856 unsigned int res)
17857{
17858 switch (res >> 26) {
17859 case ALC880_HP_EVENT:
17860 alc663_m51va_speaker_automute(codec);
17861 break;
17862 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017863 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017864 break;
17865 }
17866}
17867
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017868#define alc663_g50v_setup alc663_m51va_setup
17869
Kailang Yang6dda9f42008-05-27 12:05:31 +020017870static void alc663_g50v_inithook(struct hda_codec *codec)
17871{
17872 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017873 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017874}
17875
Kailang Yangf1d4e282008-08-26 14:03:29 +020017876static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17877 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017878 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017879
17880 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17881 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17882 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17883
17884 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17885 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17886 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17887 { } /* end */
17888};
17889
Chris Pockelé9541ba12009-05-12 08:08:53 +020017890static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17891 /* Master Playback automatically created from Speaker and Headphone */
17892 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17893 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17894 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17896
17897 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17898 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17899 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17900
17901 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17902 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17903 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17904 { } /* end */
17905};
17906
Takashi Iwaicb53c622007-08-10 17:21:45 +020017907#ifdef CONFIG_SND_HDA_POWER_SAVE
17908#define alc662_loopbacks alc880_loopbacks
17909#endif
17910
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017911
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017912/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017913#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17914#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17915#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17916#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17917
17918/*
17919 * configuration and preset
17920 */
17921static const char *alc662_models[ALC662_MODEL_LAST] = {
17922 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17923 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17924 [ALC662_3ST_6ch] = "3stack-6ch",
17925 [ALC662_5ST_DIG] = "6stack-dig",
17926 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017927 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017928 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017929 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017930 [ALC663_ASUS_M51VA] = "m51va",
17931 [ALC663_ASUS_G71V] = "g71v",
17932 [ALC663_ASUS_H13] = "h13",
17933 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017934 [ALC663_ASUS_MODE1] = "asus-mode1",
17935 [ALC662_ASUS_MODE2] = "asus-mode2",
17936 [ALC663_ASUS_MODE3] = "asus-mode3",
17937 [ALC663_ASUS_MODE4] = "asus-mode4",
17938 [ALC663_ASUS_MODE5] = "asus-mode5",
17939 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017940 [ALC663_ASUS_MODE7] = "asus-mode7",
17941 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017942 [ALC272_DELL] = "dell",
17943 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017944 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017945 [ALC662_AUTO] = "auto",
17946};
17947
17948static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017949 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017950 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17951 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017952 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17953 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017954 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017955 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17956 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17957 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17958 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017959 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17960 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017961 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017962 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17963 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17964 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17965 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17966 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017967 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017968 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17969 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017970 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17971 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17972 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17973 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017974 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017975 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17976 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17977 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017978 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17979 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17980 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17981 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017982 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017983 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17984 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017985 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017986 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17987 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17988 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017989 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017990 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017991 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17992 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017993 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17994 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17995 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017996 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017997 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17998 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017999 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018000 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018001 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018002 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18003 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18004 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018005 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018006 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18007 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018008 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018009 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018010 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018011 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018012 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18013 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018014 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018015 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018016 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18017 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018018 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018019 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018020 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018021 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018022 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018023 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018024 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18025 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018026 {}
18027};
18028
18029static struct alc_config_preset alc662_presets[] = {
18030 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018031 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018032 .init_verbs = { alc662_init_verbs },
18033 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18034 .dac_nids = alc662_dac_nids,
18035 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018036 .dig_in_nid = ALC662_DIGIN_NID,
18037 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18038 .channel_mode = alc662_3ST_2ch_modes,
18039 .input_mux = &alc662_capture_source,
18040 },
18041 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018042 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018043 .init_verbs = { alc662_init_verbs },
18044 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18045 .dac_nids = alc662_dac_nids,
18046 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018047 .dig_in_nid = ALC662_DIGIN_NID,
18048 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18049 .channel_mode = alc662_3ST_6ch_modes,
18050 .need_dac_fix = 1,
18051 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018052 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018053 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018054 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018055 .init_verbs = { alc662_init_verbs },
18056 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18057 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018058 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18059 .channel_mode = alc662_3ST_6ch_modes,
18060 .need_dac_fix = 1,
18061 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018062 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018063 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018064 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018065 .init_verbs = { alc662_init_verbs },
18066 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18067 .dac_nids = alc662_dac_nids,
18068 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018069 .dig_in_nid = ALC662_DIGIN_NID,
18070 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18071 .channel_mode = alc662_5stack_modes,
18072 .input_mux = &alc662_capture_source,
18073 },
18074 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018075 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018076 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18077 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18078 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018079 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18080 .channel_mode = alc662_3ST_2ch_modes,
18081 .input_mux = &alc662_lenovo_101e_capture_source,
18082 .unsol_event = alc662_lenovo_101e_unsol_event,
18083 .init_hook = alc662_lenovo_101e_all_automute,
18084 },
Kailang Yang291702f2007-10-16 14:28:03 +020018085 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018086 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018087 .init_verbs = { alc662_init_verbs,
18088 alc662_eeepc_sue_init_verbs },
18089 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18090 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018091 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18092 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018093 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018094 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018095 .init_hook = alc662_eeepc_inithook,
18096 },
Kailang Yang8c427222008-01-10 13:03:59 +010018097 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018098 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018099 alc662_chmode_mixer },
18100 .init_verbs = { alc662_init_verbs,
18101 alc662_eeepc_ep20_sue_init_verbs },
18102 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18103 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018104 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18105 .channel_mode = alc662_3ST_6ch_modes,
18106 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018107 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018108 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018109 .init_hook = alc662_eeepc_ep20_inithook,
18110 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018111 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018112 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018113 .init_verbs = { alc662_init_verbs,
18114 alc662_ecs_init_verbs },
18115 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18116 .dac_nids = alc662_dac_nids,
18117 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18118 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018119 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018120 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018121 .init_hook = alc662_eeepc_inithook,
18122 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018123 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018124 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018125 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18126 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18127 .dac_nids = alc662_dac_nids,
18128 .dig_out_nid = ALC662_DIGOUT_NID,
18129 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18130 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018131 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018132 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018133 .init_hook = alc663_m51va_inithook,
18134 },
18135 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018136 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018137 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18138 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18139 .dac_nids = alc662_dac_nids,
18140 .dig_out_nid = ALC662_DIGOUT_NID,
18141 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18142 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018143 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018144 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018145 .init_hook = alc663_g71v_inithook,
18146 },
18147 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018148 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018149 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18150 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18151 .dac_nids = alc662_dac_nids,
18152 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18153 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018154 .unsol_event = alc663_m51va_unsol_event,
18155 .init_hook = alc663_m51va_inithook,
18156 },
18157 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018158 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018159 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18160 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18161 .dac_nids = alc662_dac_nids,
18162 .dig_out_nid = ALC662_DIGOUT_NID,
18163 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18164 .channel_mode = alc662_3ST_6ch_modes,
18165 .input_mux = &alc663_capture_source,
18166 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018167 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018168 .init_hook = alc663_g50v_inithook,
18169 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018170 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018171 .mixers = { alc663_m51va_mixer },
18172 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018173 .init_verbs = { alc662_init_verbs,
18174 alc663_21jd_amic_init_verbs },
18175 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18176 .hp_nid = 0x03,
18177 .dac_nids = alc662_dac_nids,
18178 .dig_out_nid = ALC662_DIGOUT_NID,
18179 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18180 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018181 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018182 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018183 .init_hook = alc663_mode1_inithook,
18184 },
18185 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018186 .mixers = { alc662_1bjd_mixer },
18187 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018188 .init_verbs = { alc662_init_verbs,
18189 alc662_1bjd_amic_init_verbs },
18190 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18191 .dac_nids = alc662_dac_nids,
18192 .dig_out_nid = ALC662_DIGOUT_NID,
18193 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18194 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018195 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018196 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018197 .init_hook = alc662_mode2_inithook,
18198 },
18199 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018200 .mixers = { alc663_two_hp_m1_mixer },
18201 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018202 .init_verbs = { alc662_init_verbs,
18203 alc663_two_hp_amic_m1_init_verbs },
18204 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18205 .hp_nid = 0x03,
18206 .dac_nids = alc662_dac_nids,
18207 .dig_out_nid = ALC662_DIGOUT_NID,
18208 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18209 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018210 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018211 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018212 .init_hook = alc663_mode3_inithook,
18213 },
18214 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018215 .mixers = { alc663_asus_21jd_clfe_mixer },
18216 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018217 .init_verbs = { alc662_init_verbs,
18218 alc663_21jd_amic_init_verbs},
18219 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18220 .hp_nid = 0x03,
18221 .dac_nids = alc662_dac_nids,
18222 .dig_out_nid = ALC662_DIGOUT_NID,
18223 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18224 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018225 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018226 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018227 .init_hook = alc663_mode4_inithook,
18228 },
18229 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018230 .mixers = { alc663_asus_15jd_clfe_mixer },
18231 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018232 .init_verbs = { alc662_init_verbs,
18233 alc663_15jd_amic_init_verbs },
18234 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18235 .hp_nid = 0x03,
18236 .dac_nids = alc662_dac_nids,
18237 .dig_out_nid = ALC662_DIGOUT_NID,
18238 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18239 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018240 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018241 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018242 .init_hook = alc663_mode5_inithook,
18243 },
18244 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018245 .mixers = { alc663_two_hp_m2_mixer },
18246 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018247 .init_verbs = { alc662_init_verbs,
18248 alc663_two_hp_amic_m2_init_verbs },
18249 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18250 .hp_nid = 0x03,
18251 .dac_nids = alc662_dac_nids,
18252 .dig_out_nid = ALC662_DIGOUT_NID,
18253 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18254 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018255 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018256 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018257 .init_hook = alc663_mode6_inithook,
18258 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018259 [ALC663_ASUS_MODE7] = {
18260 .mixers = { alc663_mode7_mixer },
18261 .cap_mixer = alc662_auto_capture_mixer,
18262 .init_verbs = { alc662_init_verbs,
18263 alc663_mode7_init_verbs },
18264 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18265 .hp_nid = 0x03,
18266 .dac_nids = alc662_dac_nids,
18267 .dig_out_nid = ALC662_DIGOUT_NID,
18268 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18269 .channel_mode = alc662_3ST_2ch_modes,
18270 .unsol_event = alc663_mode7_unsol_event,
18271 .setup = alc663_mode7_setup,
18272 .init_hook = alc663_mode7_inithook,
18273 },
18274 [ALC663_ASUS_MODE8] = {
18275 .mixers = { alc663_mode8_mixer },
18276 .cap_mixer = alc662_auto_capture_mixer,
18277 .init_verbs = { alc662_init_verbs,
18278 alc663_mode8_init_verbs },
18279 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18280 .hp_nid = 0x03,
18281 .dac_nids = alc662_dac_nids,
18282 .dig_out_nid = ALC662_DIGOUT_NID,
18283 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18284 .channel_mode = alc662_3ST_2ch_modes,
18285 .unsol_event = alc663_mode8_unsol_event,
18286 .setup = alc663_mode8_setup,
18287 .init_hook = alc663_mode8_inithook,
18288 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018289 [ALC272_DELL] = {
18290 .mixers = { alc663_m51va_mixer },
18291 .cap_mixer = alc272_auto_capture_mixer,
18292 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18293 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18294 .dac_nids = alc662_dac_nids,
18295 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18296 .adc_nids = alc272_adc_nids,
18297 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18298 .capsrc_nids = alc272_capsrc_nids,
18299 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018300 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018301 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018302 .init_hook = alc663_m51va_inithook,
18303 },
18304 [ALC272_DELL_ZM1] = {
18305 .mixers = { alc663_m51va_mixer },
18306 .cap_mixer = alc662_auto_capture_mixer,
18307 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18308 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18309 .dac_nids = alc662_dac_nids,
18310 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18311 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018312 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018313 .capsrc_nids = alc662_capsrc_nids,
18314 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018315 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018316 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018317 .init_hook = alc663_m51va_inithook,
18318 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018319 [ALC272_SAMSUNG_NC10] = {
18320 .mixers = { alc272_nc10_mixer },
18321 .init_verbs = { alc662_init_verbs,
18322 alc663_21jd_amic_init_verbs },
18323 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18324 .dac_nids = alc272_dac_nids,
18325 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18326 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018327 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018328 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018329 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018330 .init_hook = alc663_mode4_inithook,
18331 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018332};
18333
18334
18335/*
18336 * BIOS auto configuration
18337 */
18338
Takashi Iwai7085ec12009-10-02 09:03:58 +020018339/* convert from MIX nid to DAC */
18340static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18341{
18342 if (nid == 0x0f)
18343 return 0x02;
18344 else if (nid >= 0x0c && nid <= 0x0e)
18345 return nid - 0x0c + 0x02;
18346 else
18347 return 0;
18348}
18349
18350/* get MIX nid connected to the given pin targeted to DAC */
18351static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18352 hda_nid_t dac)
18353{
18354 hda_nid_t mix[4];
18355 int i, num;
18356
18357 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18358 for (i = 0; i < num; i++) {
18359 if (alc662_mix_to_dac(mix[i]) == dac)
18360 return mix[i];
18361 }
18362 return 0;
18363}
18364
18365/* look for an empty DAC slot */
18366static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18367{
18368 struct alc_spec *spec = codec->spec;
18369 hda_nid_t srcs[5];
18370 int i, j, num;
18371
18372 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18373 if (num < 0)
18374 return 0;
18375 for (i = 0; i < num; i++) {
18376 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18377 if (!nid)
18378 continue;
18379 for (j = 0; j < spec->multiout.num_dacs; j++)
18380 if (spec->multiout.dac_nids[j] == nid)
18381 break;
18382 if (j >= spec->multiout.num_dacs)
18383 return nid;
18384 }
18385 return 0;
18386}
18387
18388/* fill in the dac_nids table from the parsed pin configuration */
18389static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18390 const struct auto_pin_cfg *cfg)
18391{
18392 struct alc_spec *spec = codec->spec;
18393 int i;
18394 hda_nid_t dac;
18395
18396 spec->multiout.dac_nids = spec->private_dac_nids;
18397 for (i = 0; i < cfg->line_outs; i++) {
18398 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18399 if (!dac)
18400 continue;
18401 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18402 }
18403 return 0;
18404}
18405
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018406static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018407 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018408{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018409 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018410 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18411}
18412
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018413static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018414 hda_nid_t nid, unsigned int chs)
18415{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018416 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018417 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18418}
18419
18420#define alc662_add_stereo_vol(spec, pfx, nid) \
18421 alc662_add_vol_ctl(spec, pfx, nid, 3)
18422#define alc662_add_stereo_sw(spec, pfx, nid) \
18423 alc662_add_sw_ctl(spec, pfx, nid, 3)
18424
18425/* add playback controls from the parsed DAC table */
18426static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18427 const struct auto_pin_cfg *cfg)
18428{
18429 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018430 static const char *chname[4] = {
18431 "Front", "Surround", NULL /*CLFE*/, "Side"
18432 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018433 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018434 int i, err;
18435
18436 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018437 nid = spec->multiout.dac_nids[i];
18438 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018439 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018440 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18441 if (!mix)
18442 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018443 if (i == 2) {
18444 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018445 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018446 if (err < 0)
18447 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018448 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018449 if (err < 0)
18450 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018451 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018452 if (err < 0)
18453 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018454 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018455 if (err < 0)
18456 return err;
18457 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018458 const char *pfx;
18459 if (cfg->line_outs == 1 &&
18460 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018461 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018462 pfx = "Speaker";
18463 else
18464 pfx = "PCM";
18465 } else
18466 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018467 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018468 if (err < 0)
18469 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018470 if (cfg->line_outs == 1 &&
18471 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18472 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018473 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018474 if (err < 0)
18475 return err;
18476 }
18477 }
18478 return 0;
18479}
18480
18481/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018482/* return DAC nid if any new DAC is assigned */
18483static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018484 const char *pfx)
18485{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018486 struct alc_spec *spec = codec->spec;
18487 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018488 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018489
18490 if (!pin)
18491 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018492 nid = alc662_look_for_dac(codec, pin);
18493 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018494 /* the corresponding DAC is already occupied */
18495 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18496 return 0; /* no way */
18497 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018498 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018499 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18500 }
18501
18502 mix = alc662_dac_to_mix(codec, pin, nid);
18503 if (!mix)
18504 return 0;
18505 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18506 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018507 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018508 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18509 if (err < 0)
18510 return err;
18511 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018512}
18513
18514/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018515#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018516 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018517
18518static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18519 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018520 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018521{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018522 int i, num;
18523 hda_nid_t srcs[4];
18524
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018525 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018526 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018527 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18528 if (num <= 1)
18529 return;
18530 for (i = 0; i < num; i++) {
18531 if (alc662_mix_to_dac(srcs[i]) != dac)
18532 continue;
18533 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18534 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018535 }
18536}
18537
18538static void alc662_auto_init_multi_out(struct hda_codec *codec)
18539{
18540 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018541 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018542 int i;
18543
18544 for (i = 0; i <= HDA_SIDE; i++) {
18545 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18546 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018547 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018548 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018549 }
18550}
18551
18552static void alc662_auto_init_hp_out(struct hda_codec *codec)
18553{
18554 struct alc_spec *spec = codec->spec;
18555 hda_nid_t pin;
18556
18557 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018558 if (pin)
18559 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18560 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018561 pin = spec->autocfg.speaker_pins[0];
18562 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018563 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18564 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018565}
18566
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018567#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18568
18569static void alc662_auto_init_analog_input(struct hda_codec *codec)
18570{
18571 struct alc_spec *spec = codec->spec;
18572 int i;
18573
18574 for (i = 0; i < AUTO_PIN_LAST; i++) {
18575 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018576 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018577 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018578 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018579 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018580 snd_hda_codec_write(codec, nid, 0,
18581 AC_VERB_SET_AMP_GAIN_MUTE,
18582 AMP_OUT_MUTE);
18583 }
18584 }
18585}
18586
Takashi Iwaif511b012008-08-15 16:46:42 +020018587#define alc662_auto_init_input_src alc882_auto_init_input_src
18588
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018589static int alc662_parse_auto_config(struct hda_codec *codec)
18590{
18591 struct alc_spec *spec = codec->spec;
18592 int err;
18593 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18594
18595 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18596 alc662_ignore);
18597 if (err < 0)
18598 return err;
18599 if (!spec->autocfg.line_outs)
18600 return 0; /* can't find valid BIOS pin config */
18601
Takashi Iwai7085ec12009-10-02 09:03:58 +020018602 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018603 if (err < 0)
18604 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018605 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018606 if (err < 0)
18607 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018608 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018609 spec->autocfg.speaker_pins[0],
18610 "Speaker");
18611 if (err < 0)
18612 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018613 if (err)
18614 spec->multiout.extra_out_nid[0] = err;
18615 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018616 "Headphone");
18617 if (err < 0)
18618 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018619 if (err)
18620 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018621 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018622 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018623 return err;
18624
18625 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18626
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018627 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018628 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18629
Takashi Iwai603c4012008-07-30 15:01:44 +020018630 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018631 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018632
18633 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018634 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018635
Kailang Yangcec27c82010-02-04 14:18:18 +010018636 add_verb(spec, alc662_init_verbs);
18637 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18638 codec->vendor_id == 0x10ec0665)
18639 add_verb(spec, alc663_init_verbs);
18640
18641 if (codec->vendor_id == 0x10ec0272)
18642 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018643
18644 err = alc_auto_add_mic_boost(codec);
18645 if (err < 0)
18646 return err;
18647
Kailang Yang6227cdc2010-02-25 08:36:52 +010018648 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18649 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18650 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18651 else
18652 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018653
Takashi Iwai8c872862007-06-19 12:11:16 +020018654 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018655}
18656
18657/* additional initialization for auto-configuration model */
18658static void alc662_auto_init(struct hda_codec *codec)
18659{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018660 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018661 alc662_auto_init_multi_out(codec);
18662 alc662_auto_init_hp_out(codec);
18663 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018664 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018665 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018666 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018667}
18668
18669static int patch_alc662(struct hda_codec *codec)
18670{
18671 struct alc_spec *spec;
18672 int err, board_config;
18673
18674 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18675 if (!spec)
18676 return -ENOMEM;
18677
18678 codec->spec = spec;
18679
Kailang Yangda00c242010-03-19 11:23:45 +010018680 alc_auto_parse_customize_define(codec);
18681
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018682 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18683
Kailang Yangc027ddc2010-03-19 11:33:06 +010018684 if (alc_read_coef_idx(codec, 0) == 0x8020)
18685 alc_codec_rename(codec, "ALC661");
18686 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18687 codec->bus->pci->subsystem_vendor == 0x1025 &&
18688 spec->cdefine.platform_type == 1)
18689 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010018690
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018691 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18692 alc662_models,
18693 alc662_cfg_tbl);
18694 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018695 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18696 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018697 board_config = ALC662_AUTO;
18698 }
18699
18700 if (board_config == ALC662_AUTO) {
18701 /* automatic parse from the BIOS config */
18702 err = alc662_parse_auto_config(codec);
18703 if (err < 0) {
18704 alc_free(codec);
18705 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020018706 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018707 printk(KERN_INFO
18708 "hda_codec: Cannot set up configuration "
18709 "from BIOS. Using base mode...\n");
18710 board_config = ALC662_3ST_2ch_DIG;
18711 }
18712 }
18713
Takashi Iwaidc1eae22010-07-29 15:30:02 +020018714 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020018715 err = snd_hda_attach_beep_device(codec, 0x1);
18716 if (err < 0) {
18717 alc_free(codec);
18718 return err;
18719 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018720 }
18721
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018722 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018723 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018724
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018725 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18726 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18727
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018728 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18729 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18730
Takashi Iwaidd704692009-08-11 08:45:11 +020018731 if (!spec->adc_nids) {
18732 spec->adc_nids = alc662_adc_nids;
18733 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18734 }
18735 if (!spec->capsrc_nids)
18736 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018737
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018738 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018739 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018740
Takashi Iwaidc1eae22010-07-29 15:30:02 +020018741 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010018742 switch (codec->vendor_id) {
18743 case 0x10ec0662:
18744 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18745 break;
18746 case 0x10ec0272:
18747 case 0x10ec0663:
18748 case 0x10ec0665:
18749 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18750 break;
18751 case 0x10ec0273:
18752 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18753 break;
18754 }
Kailang Yangcec27c82010-02-04 14:18:18 +010018755 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018756 spec->vmaster_nid = 0x02;
18757
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018758 codec->patch_ops = alc_patch_ops;
18759 if (board_config == ALC662_AUTO)
18760 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018761#ifdef CONFIG_SND_HDA_POWER_SAVE
18762 if (!spec->loopback.amplist)
18763 spec->loopback.amplist = alc662_loopbacks;
18764#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018765
18766 return 0;
18767}
18768
Kailang Yang274693f2009-12-03 10:07:50 +010018769static int patch_alc888(struct hda_codec *codec)
18770{
18771 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18772 kfree(codec->chip_name);
18773 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018774 if (!codec->chip_name) {
18775 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018776 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018777 }
18778 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018779 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018780 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018781}
18782
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018783/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018784 * patch entries
18785 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018786static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018787 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018788 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018789 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018790 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018791 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018792 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018793 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018794 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018795 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018796 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018797 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18798 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18799 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018800 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai49535502009-06-30 15:28:30 +020018801 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018802 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18803 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018804 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018805 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018806 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018807 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018808 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020018809 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018810 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020018811 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018812 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020018813 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018814 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020018815 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018816 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai49535502009-06-30 15:28:30 +020018817 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018818 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai49535502009-06-30 15:28:30 +020018819 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018820 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018821 {} /* terminator */
18822};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018823
18824MODULE_ALIAS("snd-hda-codec-id:10ec*");
18825
18826MODULE_LICENSE("GPL");
18827MODULE_DESCRIPTION("Realtek HD-audio codec");
18828
18829static struct hda_codec_preset_list realtek_list = {
18830 .preset = snd_hda_preset_realtek,
18831 .owner = THIS_MODULE,
18832};
18833
18834static int __init patch_realtek_init(void)
18835{
18836 return snd_hda_add_codec_preset(&realtek_list);
18837}
18838
18839static void __exit patch_realtek_exit(void)
18840{
18841 snd_hda_delete_codec_preset(&realtek_list);
18842}
18843
18844module_init(patch_realtek_init)
18845module_exit(patch_realtek_exit)